Allow legacy C and T selectors in JSON schema (#3889)

This commit is contained in:
Charlie Marsh 2023-04-05 13:58:36 -04:00 committed by GitHub
parent 7b6e55a2e0
commit e0bccfd2d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 31 deletions

View file

@ -207,7 +207,18 @@ impl JsonSchema for RuleSelector {
Schema::Object(SchemaObject {
instance_type: Some(InstanceType::String.into()),
enum_values: Some(
std::iter::once("ALL".to_string())
[
// Include the non-standard "ALL" selector.
"ALL".to_string(),
// Include the legacy "C" and "T" selectors.
"C".to_string(),
"T".to_string(),
// Include some common redirect targets for those legacy selectors.
"C9".to_string(),
"T1".to_string(),
"T2".to_string(),
]
.into_iter()
.chain(
RuleCodePrefix::iter()
.filter(|p| {
@ -232,9 +243,9 @@ impl JsonSchema for RuleSelector {
.chain(Linter::iter().filter_map(|l| {
let prefix = l.common_prefix();
(!prefix.is_empty()).then(|| prefix.to_string())
}))
.sorted(),
})),
)
.sorted()
.map(Value::String)
.collect(),
),

7
ruff.schema.json generated
View file

@ -1438,13 +1438,13 @@
"RuleSelector": {
"type": "string",
"enum": [
"ALL",
"A",
"A0",
"A00",
"A001",
"A002",
"A003",
"ALL",
"ANN",
"ANN0",
"ANN00",
@ -1518,6 +1518,7 @@
"BLE0",
"BLE00",
"BLE001",
"C",
"C4",
"C40",
"C400",
@ -1537,6 +1538,7 @@
"C415",
"C416",
"C417",
"C9",
"C90",
"C901",
"COM",
@ -2175,8 +2177,11 @@
"SLF0",
"SLF00",
"SLF001",
"T",
"T1",
"T10",
"T100",
"T2",
"T20",
"T201",
"T203",