mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Remove the PREVIEW
rule selector (#7389)
The rule selector is not useful because `--select PREVIEW` only targets Ruff developers and `--ignore PREVIEW` has no effect due to its low specificity. We may restore it later if useful.
This commit is contained in:
parent
d39eae2713
commit
b9bb6bf780
3 changed files with 37 additions and 65 deletions
|
@ -588,11 +588,12 @@ impl Configuration {
|
|||
#[allow(deprecated)]
|
||||
if matches!(selector, RuleSelector::Nursery) {
|
||||
let suggestion = if preview.is_disabled() {
|
||||
"Use the `--preview` flag instead."
|
||||
" Use the `--preview` flag instead."
|
||||
} else {
|
||||
"Use the `PREVIEW` selector instead."
|
||||
// We have no suggested alternative since there is intentionally no "PREVIEW" selector
|
||||
""
|
||||
};
|
||||
warn_user_once!("The `NURSERY` selector has been deprecated. {suggestion}");
|
||||
warn_user_once!("The `NURSERY` selector has been deprecated.{suggestion}");
|
||||
}
|
||||
|
||||
if preview.is_disabled() {
|
||||
|
@ -1092,6 +1093,27 @@ mod tests {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_all_preview() {
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![RuleSelector::All]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Disabled),
|
||||
);
|
||||
assert!(!actual.intersects(&RuleSet::from_rules(PREVIEW_RULES)));
|
||||
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![RuleSelector::All]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Enabled),
|
||||
);
|
||||
assert!(actual.intersects(&RuleSet::from_rules(PREVIEW_RULES)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_linter_preview() {
|
||||
let actual = resolve_rules(
|
||||
|
@ -1161,31 +1183,6 @@ mod tests {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_preview() {
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![RuleSelector::Preview]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Disabled),
|
||||
);
|
||||
let expected = RuleSet::empty();
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![RuleSelector::Preview]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Enabled),
|
||||
);
|
||||
|
||||
let expected =
|
||||
RuleSet::from_rules(NURSERY_RULES).union(&RuleSet::from_rules(PREVIEW_RULES));
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nursery_select_code() {
|
||||
// Backwards compatible behavior allows selection of nursery rules with their exact code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue