Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: oxc-project/oxc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e84a98e3b38e587a22a427a46b662363cb94a639
Choose a base ref
..
head repository: oxc-project/oxc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21f5b713a6582f1d04d923ada088fe79d24fe31f
Choose a head ref
26 changes: 26 additions & 0 deletions apps/oxlint/fixtures/overrides/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"rules": {
"no-var": "error",
"no-console": "error"
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"no-console": "warn"
}
},
{
"files": ["*.{js,jsx}"],
"rules": {
"no-console": "off"
}
},
{
"files": ["*.ts"],
"rules": {
"no-console": "warn"
}
}
]
}
2 changes: 2 additions & 0 deletions apps/oxlint/fixtures/overrides/other.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var msg = "hello";
console.log(msg);
2 changes: 2 additions & 0 deletions apps/oxlint/fixtures/overrides/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var msg = "hello";
console.log(msg);
2 changes: 2 additions & 0 deletions apps/oxlint/fixtures/overrides/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var msg = "hello";
console.log(msg);
21 changes: 21 additions & 0 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
@@ -629,4 +629,25 @@ mod test {
std::fs::read_to_string("fixtures/print_config/ban_rules/expect.json").unwrap();
assert_eq!(config, expect_json.trim());
}

#[test]
fn test_overrides() {
let result =
test(&["-c", "fixtures/overrides/.oxlintrc.json", "fixtures/overrides/test.js"]);
assert_eq!(result.number_of_files, 1);
assert_eq!(result.number_of_warnings, 0);
assert_eq!(result.number_of_errors, 1);

let result =
test(&["-c", "fixtures/overrides/.oxlintrc.json", "fixtures/overrides/test.ts"]);
assert_eq!(result.number_of_files, 1);
assert_eq!(result.number_of_warnings, 1);
assert_eq!(result.number_of_errors, 1);

let result =
test(&["-c", "fixtures/overrides/.oxlintrc.json", "fixtures/overrides/other.jsx"]);
assert_eq!(result.number_of_files, 1);
assert_eq!(result.number_of_warnings, 0);
assert_eq!(result.number_of_errors, 1);
}
}