diff --git a/apps/oxlint/fixtures/cross_module_extended_config/.oxlintrc.json b/apps/oxlint/fixtures/cross_module_extended_config/.oxlintrc.json new file mode 100644 index 0000000000000..82edc543b5df5 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_extended_config/.oxlintrc.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "./config/.oxlintrc.json" + ] +} diff --git a/apps/oxlint/fixtures/cross_module_extended_config/config/.oxlintrc.json b/apps/oxlint/fixtures/cross_module_extended_config/config/.oxlintrc.json new file mode 100644 index 0000000000000..7d258733b4493 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_extended_config/config/.oxlintrc.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "import" + ], + "rules": { + "import/no-cycle": "error" + } +} diff --git a/apps/oxlint/fixtures/cross_module_extended_config/dep-a.ts b/apps/oxlint/fixtures/cross_module_extended_config/dep-a.ts new file mode 100644 index 0000000000000..8e71bdb54e2e8 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_extended_config/dep-a.ts @@ -0,0 +1,4 @@ +// should report cycle detected +import { b } from './dep-b.ts'; + +b(); diff --git a/apps/oxlint/fixtures/cross_module_extended_config/dep-b.ts b/apps/oxlint/fixtures/cross_module_extended_config/dep-b.ts new file mode 100644 index 0000000000000..137d96df50b3f --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_extended_config/dep-b.ts @@ -0,0 +1,4 @@ +// this file is also included in dep-a.ts and dep-a.ts should report a no-cycle diagnostic +import './dep-a.ts'; + +export function b() { /* ... */ } diff --git a/apps/oxlint/fixtures/cross_module_nested_config/dep-a.ts b/apps/oxlint/fixtures/cross_module_nested_config/dep-a.ts new file mode 100644 index 0000000000000..8e71bdb54e2e8 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_nested_config/dep-a.ts @@ -0,0 +1,4 @@ +// should report cycle detected +import { b } from './dep-b.ts'; + +b(); diff --git a/apps/oxlint/fixtures/cross_module_nested_config/dep-b.ts b/apps/oxlint/fixtures/cross_module_nested_config/dep-b.ts new file mode 100644 index 0000000000000..137d96df50b3f --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_nested_config/dep-b.ts @@ -0,0 +1,4 @@ +// this file is also included in dep-a.ts and dep-a.ts should report a no-cycle diagnostic +import './dep-a.ts'; + +export function b() { /* ... */ } diff --git a/apps/oxlint/fixtures/cross_module_nested_config/folder/.oxlintrc.json b/apps/oxlint/fixtures/cross_module_nested_config/folder/.oxlintrc.json new file mode 100644 index 0000000000000..7d258733b4493 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_nested_config/folder/.oxlintrc.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "import" + ], + "rules": { + "import/no-cycle": "error" + } +} diff --git a/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-a.ts b/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-a.ts new file mode 100644 index 0000000000000..55b132fd4d57a --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-a.ts @@ -0,0 +1,4 @@ +// should report cycle detected +import { b } from './folder-dep-b.ts'; + +b(); diff --git a/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-b.ts b/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-b.ts new file mode 100644 index 0000000000000..935ceddca1e82 --- /dev/null +++ b/apps/oxlint/fixtures/cross_module_nested_config/folder/folder-dep-b.ts @@ -0,0 +1,4 @@ +// this file is also included in folder-dep-a.ts and folder-dep-a.ts should report a no-cycle diagnostic +import './folder-dep-a.ts'; + +export function b() { /* ... */ } diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 6ad29b9fa1042..afcfb4f3b0a1c 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -1075,4 +1075,20 @@ mod test { let args = &["issue_10054"]; Tester::new().with_cwd("fixtures".into()).test_and_snapshot(args); } + + #[test] + fn test_cross_modules_with_nested_config() { + let args = &[]; + Tester::new() + .with_cwd("fixtures/cross_module_nested_config".into()) + .test_and_snapshot(args); + } + + #[test] + fn test_cross_modules_with_extended_config() { + let args = &[]; + Tester::new() + .with_cwd("fixtures/cross_module_extended_config".into()) + .test_and_snapshot(args); + } } diff --git a/apps/oxlint/src/snapshots/fixtures__cross_module_extended_config_@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__cross_module_extended_config_@oxlint.snap new file mode 100644 index 0000000000000..24e274d76745d --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__cross_module_extended_config_@oxlint.snap @@ -0,0 +1,35 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: +working directory: fixtures/cross_module_extended_config +---------- + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html\eslint-plugin-import(no-cycle)]8;;\: Dependency cycle detected + ,-[dep-a.ts:2:19] + 1 | // should report cycle detected + 2 | import { b } from './dep-b.ts'; + : ^^^^^^^^^^^^ + 3 | + `---- + help: These paths form a cycle: + -> ./dep-b.ts - fixtures/cross_module_extended_config/dep-b.ts + -> ./dep-a.ts - fixtures/cross_module_extended_config/dep-a.ts + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html\eslint-plugin-import(no-cycle)]8;;\: Dependency cycle detected + ,-[dep-b.ts:2:8] + 1 | // this file is also included in dep-a.ts and dep-a.ts should report a no-cycle diagnostic + 2 | import './dep-a.ts'; + : ^^^^^^^^^^^^ + 3 | + `---- + help: These paths form a cycle: + -> ./dep-a.ts - fixtures/cross_module_extended_config/dep-a.ts + -> ./dep-b.ts - fixtures/cross_module_extended_config/dep-b.ts + +Found 0 warnings and 2 errors. +Finished in ms on 2 files using 1 threads. +---------- +CLI result: LintFoundErrors +---------- diff --git a/apps/oxlint/src/snapshots/fixtures__cross_module_nested_config_@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__cross_module_nested_config_@oxlint.snap new file mode 100644 index 0000000000000..d0ae5d298784b --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__cross_module_nested_config_@oxlint.snap @@ -0,0 +1,35 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: +working directory: fixtures/cross_module_nested_config +---------- + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html\eslint-plugin-import(no-cycle)]8;;\: Dependency cycle detected + ,-[folder/folder-dep-a.ts:2:19] + 1 | // should report cycle detected + 2 | import { b } from './folder-dep-b.ts'; + : ^^^^^^^^^^^^^^^^^^^ + 3 | + `---- + help: These paths form a cycle: + -> ./folder-dep-b.ts - fixtures/cross_module_nested_config/folder/folder-dep-b.ts + -> ./folder-dep-a.ts - fixtures/cross_module_nested_config/folder/folder-dep-a.ts + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html\eslint-plugin-import(no-cycle)]8;;\: Dependency cycle detected + ,-[folder/folder-dep-b.ts:2:8] + 1 | // this file is also included in folder-dep-a.ts and folder-dep-a.ts should report a no-cycle diagnostic + 2 | import './folder-dep-a.ts'; + : ^^^^^^^^^^^^^^^^^^^ + 3 | + `---- + help: These paths form a cycle: + -> ./folder-dep-a.ts - fixtures/cross_module_nested_config/folder/folder-dep-a.ts + -> ./folder-dep-b.ts - fixtures/cross_module_nested_config/folder/folder-dep-b.ts + +Found 0 warnings and 2 errors. +Finished in ms on 4 files using 1 threads. +---------- +CLI result: LintFoundErrors +----------