Skip to content

Commit 0bf2bcf

Browse files
authoredFeb 1, 2025··
test(oxlint): test two real rules with same name but from different plugins (#8821)
Related to #8814 This test case is designed to verify that two different rules, having the same name but coming from different plugins, are treated as distinct rules rather than simple aliases. In `unicorn`, there is only one rule, `no-negated-condition`, which is aliased to `eslint`. https://github.com/oxc-project/oxc/blob/655b2126889a3307929a1a20047b317c1eefb140/crates/oxc_linter/src/config/rules.rs#L166-L178
1 parent b00b8c8 commit 0bf2bcf

File tree

7 files changed

+38
-4
lines changed

7 files changed

+38
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"plugins": [],
33
"rules": {
4-
"eslint/no-nested-ternary": "off"
4+
"eslint/no-negated-condition": "off"
55
}
66
}

Diff for: ‎apps/oxlint/fixtures/disable_eslint_and_unicorn_alias_rules/.oxlintrc-unicorn.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"unicorn"
44
],
55
"rules": {
6-
"unicorn/no-nested-ternary": "off"
6+
"unicorn/no-negated-condition": "off"
77
}
88
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
console.log(bar ? baz : qux === quxx ? bing : bam);
1+
if (!condition) {
2+
console.log(123)
3+
} else {
4+
console.log(666)
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": [
3+
"unicorn"
4+
],
5+
"rules": {
6+
"eslint/no-nested-ternary": "off",
7+
"unicorn/no-nested-ternary": "off"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(bar ? baz : qux === quxx ? bing : bam);

Diff for: ‎apps/oxlint/src/lint.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -826,14 +826,22 @@ mod test {
826826

827827
#[test]
828828
fn test_disable_eslint_and_unicorn_alias_rules() {
829-
// Issue: <https://github.com/oxc-project/oxc/issues/8485>
830829
let args_1 = &["-c", ".oxlintrc-eslint.json", "test.js"];
831830
let args_2 = &["-c", ".oxlintrc-unicorn.json", "test.js"];
832831
Tester::new()
833832
.with_cwd("fixtures/disable_eslint_and_unicorn_alias_rules".into())
834833
.test_and_snapshot_multiple(&[args_1, args_2]);
835834
}
836835

836+
#[test]
837+
fn test_two_rules_with_same_rule_name_from_different_plugins() {
838+
// Issue: <https://github.com/oxc-project/oxc/issues/8485>
839+
let args = &["-c", ".oxlintrc.json", "test.js"];
840+
Tester::new()
841+
.with_cwd("fixtures/two_rules_with_same_rule_name".into())
842+
.test_and_snapshot(args);
843+
}
844+
837845
#[test]
838846
fn test_adjust_ignore_patterns() {
839847
let base = PathBuf::from("/project/root");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: apps/oxlint/src/tester.rs
3+
---
4+
##########
5+
arguments: -c .oxlintrc.json test.js
6+
working directory: fixtures/two_rules_with_same_rule_name
7+
----------
8+
Found 0 warnings and 0 errors.
9+
Finished in <variable>ms on 1 file with 61 rules using 1 threads.
10+
----------
11+
CLI result: LintSucceeded
12+
----------

0 commit comments

Comments
 (0)
Please sign in to comment.