diff --git a/apps/oxlint/fixtures/disable_directive_issue_13311/.oxlintrc.json b/apps/oxlint/fixtures/disable_directive_issue_13311/.oxlintrc.json new file mode 100644 index 0000000000000..88601593e44c1 --- /dev/null +++ b/apps/oxlint/fixtures/disable_directive_issue_13311/.oxlintrc.json @@ -0,0 +1,10 @@ +{ + "plugins": ["eslint", "typescript", "react"], + "categories": { + "correctness": "off" + }, + "rules": { + "react/exhaustive-deps": "warn", + "typescript/no-unsafe-declaration-merging": "error" + } +} diff --git a/apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/test.jsx b/apps/oxlint/fixtures/disable_directive_issue_13311/test.jsx similarity index 98% rename from apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/test.jsx rename to apps/oxlint/fixtures/disable_directive_issue_13311/test.jsx index 1161547bd4db6..fb6285de0eb55 100644 --- a/apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/test.jsx +++ b/apps/oxlint/fixtures/disable_directive_issue_13311/test.jsx @@ -10,4 +10,5 @@ function Component() { }, []); return null; -} \ No newline at end of file +} + diff --git a/apps/oxlint/fixtures/disable_directive_issue_13311/test2.d.ts b/apps/oxlint/fixtures/disable_directive_issue_13311/test2.d.ts new file mode 100644 index 0000000000000..9590d6ee91c05 --- /dev/null +++ b/apps/oxlint/fixtures/disable_directive_issue_13311/test2.d.ts @@ -0,0 +1,9 @@ +// oxlint-disable-next-line typescript/no-unsafe-declaration-merging +export interface Component {} + +export abstract class Component {} + +// oxlint-disable-next-line typescript/no-unsafe-declaration-merging +export abstract class Component2 {} + +export interface Component2 {} diff --git a/apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/.oxlintrc.json b/apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/.oxlintrc.json deleted file mode 100644 index ebb97dbdd8791..0000000000000 --- a/apps/oxlint/fixtures/exhaustive_deps_disable_directive_issue_13311/.oxlintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": ["react"], - "categories": { - "correctness": "off" - }, - "rules": { - "react/exhaustive-deps": "warn" - } -} \ No newline at end of file diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 40f41f25bfa7f..e267634fa3a37 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -1252,13 +1252,13 @@ mod test { } #[test] - fn test_exhaustive_deps_disable_directive_issue_13311() { + fn test_disable_directive_issue_13311() { // Test that exhaustive-deps diagnostics are reported at the dependency array // so that disable directives work correctly // Issue: https://github.com/oxc-project/oxc/issues/13311 - let args = &["test.jsx"]; + let args = &["test.jsx", "test2.d.ts"]; Tester::new() - .with_cwd("fixtures/exhaustive_deps_disable_directive_issue_13311".into()) + .with_cwd("fixtures/disable_directive_issue_13311".into()) .test_and_snapshot(args); } diff --git a/apps/oxlint/src/snapshots/fixtures__disable_directive_issue_13311_test.jsx test2.d.ts@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__disable_directive_issue_13311_test.jsx test2.d.ts@oxlint.snap new file mode 100644 index 0000000000000..591a3fd493920 --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__disable_directive_issue_13311_test.jsx test2.d.ts@oxlint.snap @@ -0,0 +1,12 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: test.jsx test2.d.ts +working directory: fixtures/disable_directive_issue_13311 +---------- +Found 0 warnings and 0 errors. +Finished in ms on 2 files using 1 threads. +---------- +CLI result: LintSucceeded +---------- diff --git a/apps/oxlint/src/snapshots/fixtures__exhaustive_deps_disable_directive_issue_13311_test.jsx@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__exhaustive_deps_disable_directive_issue_13311_test.jsx@oxlint.snap deleted file mode 100644 index f7ac5d3d86675..0000000000000 --- a/apps/oxlint/src/snapshots/fixtures__exhaustive_deps_disable_directive_issue_13311_test.jsx@oxlint.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: apps/oxlint/src/tester.rs ---- -########## -arguments: test.jsx -working directory: fixtures/exhaustive_deps_disable_directive_issue_13311 ----------- -Found 0 warnings and 0 errors. -Finished in ms on 1 file using 1 threads. ----------- -CLI result: LintSucceeded ----------- diff --git a/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs b/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs index ae7ae2310705e..c9d686999f48b 100644 --- a/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs +++ b/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs @@ -13,7 +13,7 @@ use crate::{ fn no_unsafe_declaration_merging_diagnostic(span: Span, span1: Span) -> OxcDiagnostic { OxcDiagnostic::warn("Unsafe declaration merging between classes and interfaces.") .with_help("The TypeScript compiler doesn't check whether properties are initialized, which can lead to TypeScript not detecting code that will cause runtime errors.") - .with_labels([span, span1]) + .with_labels(if span < span1 { [span, span1]} else { [span1, span] }) } #[derive(Debug, Default, Clone)]