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 { Schema::Object(SchemaObject {
instance_type: Some(InstanceType::String.into()), instance_type: Some(InstanceType::String.into()),
enum_values: Some( 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( .chain(
RuleCodePrefix::iter() RuleCodePrefix::iter()
.filter(|p| { .filter(|p| {
@ -232,9 +243,9 @@ impl JsonSchema for RuleSelector {
.chain(Linter::iter().filter_map(|l| { .chain(Linter::iter().filter_map(|l| {
let prefix = l.common_prefix(); let prefix = l.common_prefix();
(!prefix.is_empty()).then(|| prefix.to_string()) (!prefix.is_empty()).then(|| prefix.to_string())
})) })),
.sorted(),
) )
.sorted()
.map(Value::String) .map(Value::String)
.collect(), .collect(),
), ),

7
ruff.schema.json generated
View file

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