mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Update rule selection to respect preview mode (#7195)
## Summary <!-- What's the purpose of the change? What does it do, and why? --> Extends work in #7046 (some relevant discussion there) Changes: - All nursery rules are now referred to as preview rules - Documentation for the nursery is updated to describe preview - Adds a "PREVIEW" selector for preview rules - This is primarily to allow `--preview --ignore PREVIEW --extend-select FOO001,BAR200` - Using `--preview` enables preview rules that match selectors Notable decisions: - Preview rules are not selectable by their rule code without enabling preview - Retains the "NURSERY" selector for backwards compatibility - Nursery rules are selectable by their rule code for backwards compatiblity Additional work: - Selection of preview rules without the "--preview" flag should display a warning - Use of deprecated nursery selection behavior should display a warning - Nursery selection should be removed after some time ## Test Plan <!-- How was it tested? --> Manual confirmation (i.e. we don't have an preview rules yet just nursery rules so I added a preview rule for manual testing) New unit tests --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
7c9bbcf4e2
commit
6566d00295
15 changed files with 607 additions and 233 deletions
|
@ -11,7 +11,7 @@ use ruff_diagnostics::AutofixKind;
|
|||
use ruff_workspace::options::Options;
|
||||
|
||||
const FIX_SYMBOL: &str = "🛠";
|
||||
const NURSERY_SYMBOL: &str = "🌅";
|
||||
const PREVIEW_SYMBOL: &str = "🌅";
|
||||
|
||||
fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>, linter: &Linter) {
|
||||
table_out.push_str("| Code | Name | Message | |");
|
||||
|
@ -25,12 +25,12 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
|
|||
}
|
||||
AutofixKind::None => format!("<span style='opacity: 0.1'>{FIX_SYMBOL}</span>"),
|
||||
};
|
||||
let nursery_token = if rule.is_nursery() {
|
||||
format!("<span style='opacity: 1'>{NURSERY_SYMBOL}</span>")
|
||||
let preview_token = if rule.is_preview() {
|
||||
format!("<span style='opacity: 1'>{PREVIEW_SYMBOL}</span>")
|
||||
} else {
|
||||
format!("<span style='opacity: 0.1'>{NURSERY_SYMBOL}</span>")
|
||||
format!("<span style='opacity: 0.1'>{PREVIEW_SYMBOL}</span>")
|
||||
};
|
||||
let status_token = format!("{fix_token} {nursery_token}");
|
||||
let status_token = format!("{fix_token} {preview_token}");
|
||||
|
||||
let rule_name = rule.as_ref();
|
||||
|
||||
|
@ -61,7 +61,7 @@ pub(crate) fn generate() -> String {
|
|||
table_out.push('\n');
|
||||
|
||||
table_out.push_str(&format!(
|
||||
"The {NURSERY_SYMBOL} emoji indicates that a rule is part of the [\"nursery\"](../faq/#what-is-the-nursery)."
|
||||
"The {PREVIEW_SYMBOL} emoji indicates that a rule in [\"preview\"](../faq/#what-is-preview)."
|
||||
));
|
||||
table_out.push('\n');
|
||||
table_out.push('\n');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue