Skip to content

Commit b2273d7

Browse files
committed
Ensure that no unknown fields are allowed in OxlintOverride struct.
Add test to validate that this fails when there is an unknown field in an override config.
1 parent e0d8001 commit b2273d7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

crates/oxc_linter/src/config/overrides.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl JsonSchema for OxlintOverrides {
7676

7777
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]
7878
#[non_exhaustive]
79+
#[serde(deny_unknown_fields)]
7980
pub struct OxlintOverride {
8081
/// A list of glob patterns to override.
8182
///

crates/oxc_linter/src/snapshots/schema_json.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ expression: json
509509
}
510510
]
511511
}
512-
}
512+
},
513+
"additionalProperties": false
513514
},
514515
"OxlintOverrides": {
515516
"type": "array",

npm/oxlint/configuration_schema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@
505505
}
506506
]
507507
}
508-
}
508+
},
509+
"additionalProperties": false
509510
},
510511
"OxlintOverrides": {
511512
"type": "array",
@@ -660,4 +661,4 @@
660661
}
661662
},
662663
"markdownDescription": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json --import-plugin`\n\n::: danger NOTE\n\nOnly the `.json` format is supported. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json\n{\n\"$schema\": \"./node_modules/oxlint/configuration_schema.json\",\n\"plugins\": [\"import\", \"typescript\", \"unicorn\"],\n\"env\": {\n\"browser\": true\n},\n\"globals\": {\n\"foo\": \"readonly\"\n},\n\"settings\": {\n},\n\"rules\": {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\n\"overrides\": [\n{\n\"files\": [\"*.test.ts\", \"*.spec.ts\"],\n\"rules\": {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n}\n```"
663-
}
664+
}

0 commit comments

Comments
 (0)