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`.


655b212688/crates/oxc_linter/src/config/rules.rs (L166-L178)
This commit is contained in:
dalaoshu 2025-02-01 21:29:23 +08:00 committed by GitHub
parent b00b8c8b46
commit 0bf2bcf359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{
"plugins": [],
"rules": {
"eslint/no-nested-ternary": "off"
"eslint/no-negated-condition": "off"
}
}

View file

@ -3,6 +3,6 @@
"unicorn"
],
"rules": {
"unicorn/no-nested-ternary": "off"
"unicorn/no-negated-condition": "off"
}
}

View file

@ -1 +1,5 @@
console.log(bar ? baz : qux === quxx ? bing : bam);
if (!condition) {
console.log(123)
} else {
console.log(666)
}

View file

@ -0,0 +1,9 @@
{
"plugins": [
"unicorn"
],
"rules": {
"eslint/no-nested-ternary": "off",
"unicorn/no-nested-ternary": "off"
}
}

View file

@ -0,0 +1 @@
console.log(bar ? baz : qux === quxx ? bing : bam);

View file

@ -826,7 +826,6 @@ mod test {
#[test]
fn test_disable_eslint_and_unicorn_alias_rules() {
// Issue: <https://github.com/oxc-project/oxc/issues/8485>
let args_1 = &["-c", ".oxlintrc-eslint.json", "test.js"];
let args_2 = &["-c", ".oxlintrc-unicorn.json", "test.js"];
Tester::new()
@ -834,6 +833,15 @@ mod test {
.test_and_snapshot_multiple(&[args_1, args_2]);
}
#[test]
fn test_two_rules_with_same_rule_name_from_different_plugins() {
// Issue: <https://github.com/oxc-project/oxc/issues/8485>
let args = &["-c", ".oxlintrc.json", "test.js"];
Tester::new()
.with_cwd("fixtures/two_rules_with_same_rule_name".into())
.test_and_snapshot(args);
}
#[test]
fn test_adjust_ignore_patterns() {
let base = PathBuf::from("/project/root");

View file

@ -0,0 +1,12 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c .oxlintrc.json test.js
working directory: fixtures/two_rules_with_same_rule_name
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 61 rules using 1 threads.
----------
CLI result: LintSucceeded
----------