From e9f50cb85d141b75a468c9ba3b71ec072331f007 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 25 Feb 2026 19:22:01 -0800 Subject: [PATCH 1/5] fix(linter): add help text to sort_imports, no_extend_native, no_useless_backreference --- .../src/rules/eslint/no_extend_native.rs | 3 + .../rules/eslint/no_useless_backreference.rs | 27 ++++-- .../src/rules/eslint/sort_imports.rs | 6 +- .../snapshots/eslint_no_extend_native.snap | 27 ++++++ .../eslint_no_useless_backreference.snap | 93 +++++++++++++++++++ .../src/snapshots/eslint_sort_imports.snap | 44 ++++++--- 6 files changed, 177 insertions(+), 23 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_extend_native.rs b/crates/oxc_linter/src/rules/eslint/no_extend_native.rs index ce652652307a5..7c0db7155a6e0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_extend_native.rs +++ b/crates/oxc_linter/src/rules/eslint/no_extend_native.rs @@ -114,7 +114,9 @@ impl Rule for NoExtendNative { ctx.diagnostic( OxcDiagnostic::error(format!( "{name} prototype is read-only, properties should not be added." + )) + .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") .with_label(prop_assign.span()), ); } @@ -126,6 +128,7 @@ impl Rule for NoExtendNative { OxcDiagnostic::error(format!( "{name} prototype is read-only, properties should not be added." )) + .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") .with_label(define_property_call.span()), ); } diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs b/crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs index 6465a5fe4e738..a6191e9b8488d 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs @@ -15,13 +15,26 @@ fn no_useless_backreference_diagnostic( back_reference: &str, group: &str, ) -> OxcDiagnostic { - match problem { - Problem::Nested =>OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' from within that group.")).with_label(span), - Problem::Disjunctive => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which is in another alternative.")).with_label(span), - Problem::Forward => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which appears later in the pattern.")).with_label(span), - Problem::Backward => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which appears before in the same lookbehind.")).with_label(span), - Problem::IntoNegativeLookaround => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which is in a negative lookaround.")).with_label(span), - } + let diagnostic = match problem { + Problem::Nested => OxcDiagnostic::warn(format!( + "Backreference '{back_reference}' will be ignored. It references group '{group}' from within that group." + )), + Problem::Disjunctive => OxcDiagnostic::warn(format!( + "Backreference '{back_reference}' will be ignored. It references group '{group}' which is in another alternative." + )), + Problem::Forward => OxcDiagnostic::warn(format!( + "Backreference '{back_reference}' will be ignored. It references group '{group}' which appears later in the pattern." + )), + Problem::Backward => OxcDiagnostic::warn(format!( + "Backreference '{back_reference}' will be ignored. It references group '{group}' which appears before in the same lookbehind." + )), + Problem::IntoNegativeLookaround => OxcDiagnostic::warn(format!( + "Backreference '{back_reference}' will be ignored. It references group '{group}' which is in a negative lookaround." + )), + }; + diagnostic + .with_help("Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation.") + .with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index 358e18647bea7..598ddc4d0b04b 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -24,17 +24,21 @@ fn unexpected_syntax_order_diagnostic( span: Span, ) -> OxcDiagnostic { OxcDiagnostic::warn(format!("Expected '{curr_kind}' syntax before '{prev_kind}' syntax.")) + .with_help("Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option.") .with_label(span) } fn sort_imports_alphabetically_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Imports should be sorted alphabetically.").with_label(span) + OxcDiagnostic::warn("Imports should be sorted alphabetically.") + .with_help("Reorder import declarations alphabetically by the first member or alias name.") + .with_label(span) } fn sort_members_alphabetically_diagnostic(name: &str, span: Span) -> OxcDiagnostic { OxcDiagnostic::warn(format!( "Member '{name}' of the import declaration should be sorted alphabetically." )) + .with_help("Reorder the members in the import declaration alphabetically.") .with_label(span) } diff --git a/crates/oxc_linter/src/snapshots/eslint_no_extend_native.snap b/crates/oxc_linter/src/snapshots/eslint_no_extend_native.snap index e93c463c597de..688d6454ad48d 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_extend_native.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_extend_native.snap @@ -7,159 +7,186 @@ source: crates/oxc_linter/src/tester.rs 1 │ Object.prototype.p = 0 · ────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): BigInt prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ BigInt.prototype.p = 0 · ────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): WeakRef prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ WeakRef.prototype.p = 0 · ─────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): FinalizationRegistry prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ FinalizationRegistry.prototype.p = 0 · ──────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): AggregateError prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ AggregateError.prototype.p = 0 · ────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Function prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Function.prototype['p'] = 0 · ─────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): String prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ String['prototype'].p = 0 · ───────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Number prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Number['prototype']['p'] = 0 · ──────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object.defineProperty(Array.prototype, 'p', {value: 0}) · ─────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object['defineProperty'](Array.prototype, 'p', {value: 0}) · ────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object['defineProperty'](Array['prototype'], 'p', {value: 0}) · ───────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object.defineProperties(Array.prototype, {p: {value: 0}}) · ───────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object.defineProperties(Array.prototype, {p: {value: 0}, q: {value: 0}}) · ──────────────────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Number prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Number['prototype']['p'] = 0 · ──────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object.prototype.p = 0; Object.prototype.q = 0 · ────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:25] 1 │ Object.prototype.p = 0; Object.prototype.q = 0 · ────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:18] 1 │ function foo() { Object.prototype.p = 0 } · ────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ (Object?.prototype).p = 0 · ───────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ (Object?.['prototype'])['p'] = 0 · ──────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object.defineProperty(Object?.prototype, 'p', { value: 0 }) · ─────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object?.defineProperty(Object.prototype, 'p', { value: 0 }) · ─────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Object?.['defineProperty'](Object?.['prototype'], 'p', {value: 0}) · ────────────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ (Object?.defineProperty)(Object.prototype, 'p', { value: 0 }) · ───────────────────────────────────────────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Array.prototype.p &&= 0 · ─────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Array.prototype.p ||= 0 · ─────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ Array.prototype.p ??= 0 · ─────────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. ⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added. ╭─[no_extend_native.tsx:1:1] 1 │ [Array.prototype.p] = [() => {}] · ─────────────────── ╰──── + help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype. diff --git a/crates/oxc_linter/src/snapshots/eslint_no_useless_backreference.snap b/crates/oxc_linter/src/snapshots/eslint_no_useless_backreference.snap index 73f8015f201e3..e0e58d49d7b7c 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_useless_backreference.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_useless_backreference.snap @@ -7,555 +7,648 @@ source: crates/oxc_linter/src/tester.rs 1 │ /(b)(\2a)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\k(?bar)/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\\1' will be ignored. It references group '(a|bc)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:16] 1 │ RegExp('(a|bc)|\\1') · ─── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\\1' will be ignored. It references group '(?\\n)' which is in a negative lookaround. ╭─[no_useless_backreference.tsx:1:28] 1 │ new RegExp('(?!(?\\n))\\1') · ─── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears later in the pattern. ╭─[no_useless_backreference.tsx:1:9] 1 │ /(?(.)b\1)' from within that group. ╭─[no_useless_backreference.tsx:1:14] 1 │ /a(?(.)b\1)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?\k)' from within that group. ╭─[no_useless_backreference.tsx:1:10] 1 │ /a(?\k)b/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(\1)' from within that group. ╭─[no_useless_backreference.tsx:1:4] 1 │ /^(\1)*$/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '((?:\1))' from within that group. ╭─[no_useless_backreference.tsx:1:15] 1 │ /^(?:a)(?:((?:\1)))*$/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(\1)' from within that group. ╭─[no_useless_backreference.tsx:1:6] 1 │ /(?!(\1))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(b\1c)' from within that group. ╭─[no_useless_backreference.tsx:1:6] 1 │ /a|(b\1c)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a|(\1))' from within that group. ╭─[no_useless_backreference.tsx:1:6] 1 │ /(a|(\1))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\2' will be ignored. It references group '(\2)' from within that group. ╭─[no_useless_backreference.tsx:1:6] 1 │ /(a|(\2))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(\1)' from within that group. ╭─[no_useless_backreference.tsx:1:8] 1 │ /(?:a|(\1))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\3' will be ignored. It references group '(\3)' from within that group. ╭─[no_useless_backreference.tsx:1:11] 1 │ /(a)?(b)*(\3)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a\1)' from within that group. ╭─[no_useless_backreference.tsx:1:8] 1 │ /(?<=(a\1))b/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\1(a)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\1.(a)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:5] 1 │ /(?:\1)(?:(a))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '((a))' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:5] 1 │ /(?:\1)(?:((a)))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\2' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:5] 1 │ /(?:\2)(?:((a)))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '((?:a))' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:5] 1 │ /(?:\1)(?:((?:a)))/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\2' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:3] 1 │ /(\2)(a)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\\2' will be ignored. It references group '(b)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:12] 1 │ RegExp('(a)\\2(b)') · ─── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\2' will be ignored. It references group '(c)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:10] 1 │ /(?:a)(b)\2(c)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\k(?a)/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\2' will be ignored. It references group '(c)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:9] 1 │ /(?:a(b)\2)(c)/ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\\3' will be ignored. It references group '(c)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:19] 1 │ new RegExp('(a)(b)\\3(c)') · ─── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\1(?<=(a))./ · ── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\1' will be ignored. It references group '(a)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\1(?' will be ignored. It references group '(?bar)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\k((?bar)|(?baz))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:15] 1 │ /((?bar)|\k(?baz))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which appears before in the same lookbehind. ╭─[no_useless_backreference.tsx:1:2] 1 │ /\k((?bar)|(?baz)|(?qux))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:15] 1 │ /((?bar)|\k(?baz)|(?qux))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:15] 1 │ /((?bar)|\k|(?baz))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:15] 1 │ /((?bar)|\k|(?baz)|(?qux))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:25] 1 │ /((?bar)|(?baz\k)|(?qux\k))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in another alternative. ╭─[no_useless_backreference.tsx:1:44] 1 │ /((?bar)|(?baz\k)|(?qux\k))/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which appears later in the pattern. ╭─[no_useless_backreference.tsx:1:31] 1 │ /(?<=((?bar)|(?baz))\k)/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. ⚠ eslint(no-useless-backreference): Backreference '\k' will be ignored. It references group '(?bar)' which is in a negative lookaround. ╭─[no_useless_backreference.tsx:1:35] 1 │ /((?!(?bar))|(?!(?baz)))\k/ · ─────── ╰──── + help: Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation. diff --git a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap index a48611a91029e..029b477161c7e 100644 --- a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap +++ b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap @@ -8,6 +8,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import A from 'bar.js'; · ─────────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -15,6 +16,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'bar.js'; · ─────────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -22,6 +24,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {a, d} from 'bar.js'; · ──────────────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -29,6 +32,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as bar from 'bar.js'; · ────────────────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Expected 'Multiple' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -36,6 +40,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {b, c} from 'bar.js'; · ──────────────────────────── ╰──── + help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -43,6 +48,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as b from 'bar.js'; · ──────────────────────────── ╰──── + help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. ⚠ eslint(sort-imports): Expected 'None' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -50,6 +56,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import 'bar.js'; · ──────────────── ╰──── + help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -57,13 +64,14 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as a from 'foo.js'; · ──────────────────────────── ╰──── + help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] 1 │ import {b, a, d, c} from 'foo.js'; · ─ ╰──── - help: Replace `b, a, d, c` with `a, b, c, d`. + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] @@ -71,38 +79,42 @@ source: crates/oxc_linter/src/tester.rs · ─ 2 │ import {e, f, g, h} from 'bar.js'; ╰──── - help: Replace `b, a, d, c` with `a, b, c, d`. + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'B' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] 1 │ import {a, B, c, D} from 'foo.js'; · ─ ╰──── - help: Replace `a, B, c, D` with `B, D, a, c`. + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz, /* comment */ aaaaa} from 'foo.js'; · ───── ╰──── + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz /* comment */, aaaaa} from 'foo.js'; · ───── ╰──── + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {/* comment */ zzzzz, aaaaa} from 'foo.js'; · ───── ╰──── + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:16] 1 │ import {zzzzz, aaaaa /* comment */} from 'foo.js'; · ───── ╰──── + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'qux' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:6:17] @@ -111,17 +123,7 @@ source: crates/oxc_linter/src/tester.rs · ────────── 7 │ bar, ╰──── - help: Replace `boop, - foo, - zoo, - baz as qux, - bar, - beep` with `bar, - beep, - boop, - foo, - baz as qux, - zoo`. + help: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -129,6 +131,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -136,6 +139,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -143,18 +147,21 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:1:19] 1 │ import b from 'b';import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:1:34] 1 │ import b from 'b'; /* comment */ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -162,6 +169,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:28] @@ -169,6 +177,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ /* comment 2 */import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:35] @@ -176,6 +185,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ comment line 2 */ import { a } from 'a'; · ────────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:23] @@ -183,6 +193,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ ╭─▶ from 'b'; import a 3 │ ╰─▶ from 'a'; ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:32] @@ -190,6 +201,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ ╭─▶ 'b'; /* comment */ import 3 │ ╰─▶ { a } from 'a'; ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:3:13] @@ -197,6 +209,7 @@ source: crates/oxc_linter/src/tester.rs 3 │ ╭─▶ import 4 │ ╰─▶ { a } from 'a'; ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:4:13] @@ -204,6 +217,7 @@ source: crates/oxc_linter/src/tester.rs 4 │ import a from 'a'; · ────────────────── ╰──── + help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:3:25] @@ -211,4 +225,4 @@ source: crates/oxc_linter/src/tester.rs 3 │ import { c, a } from 'c'; · ─ ╰──── - help: Replace `c, a` with `a, c`. + help: Reorder the members in the import declaration alphabetically. From ccd25424d4fe870b277f793e518b3ba4140ff808 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 25 Feb 2026 21:03:30 -0800 Subject: [PATCH 2/5] fix(linter): address copilot feedback for sort_imports and no_extend_native --- .../src/rules/eslint/no_extend_native.rs | 5 ++- .../src/rules/eslint/sort_imports.rs | 2 +- .../src/snapshots/eslint_sort_imports.snap | 33 ++++++++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_extend_native.rs b/crates/oxc_linter/src/rules/eslint/no_extend_native.rs index 7c0db7155a6e0..540fac67c3267 100644 --- a/crates/oxc_linter/src/rules/eslint/no_extend_native.rs +++ b/crates/oxc_linter/src/rules/eslint/no_extend_native.rs @@ -114,9 +114,8 @@ impl Rule for NoExtendNative { ctx.diagnostic( OxcDiagnostic::error(format!( "{name} prototype is read-only, properties should not be added." - )) - .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") + .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") .with_label(prop_assign.span()), ); } @@ -128,7 +127,7 @@ impl Rule for NoExtendNative { OxcDiagnostic::error(format!( "{name} prototype is read-only, properties should not be added." )) - .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") + .with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.") .with_label(define_property_call.span()), ); } diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index 598ddc4d0b04b..7a7e4cb51d991 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -38,7 +38,7 @@ fn sort_members_alphabetically_diagnostic(name: &str, span: Span) -> OxcDiagnost OxcDiagnostic::warn(format!( "Member '{name}' of the import declaration should be sorted alphabetically." )) - .with_help("Reorder the members in the import declaration alphabetically.") + .with_note("Reorder the members in the import declaration alphabetically.") .with_label(span) } diff --git a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap index 029b477161c7e..5ca84f343b22f 100644 --- a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap +++ b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap @@ -71,7 +71,8 @@ source: crates/oxc_linter/src/tester.rs 1 │ import {b, a, d, c} from 'foo.js'; · ─ ╰──── - help: Reorder the members in the import declaration alphabetically. + help: Replace `b, a, d, c` with `a, b, c, d`. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] @@ -79,42 +80,44 @@ source: crates/oxc_linter/src/tester.rs · ─ 2 │ import {e, f, g, h} from 'bar.js'; ╰──── - help: Reorder the members in the import declaration alphabetically. + help: Replace `b, a, d, c` with `a, b, c, d`. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'B' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] 1 │ import {a, B, c, D} from 'foo.js'; · ─ ╰──── - help: Reorder the members in the import declaration alphabetically. + help: Replace `a, B, c, D` with `B, D, a, c`. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz, /* comment */ aaaaa} from 'foo.js'; · ───── ╰──── - help: Reorder the members in the import declaration alphabetically. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz /* comment */, aaaaa} from 'foo.js'; · ───── ╰──── - help: Reorder the members in the import declaration alphabetically. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {/* comment */ zzzzz, aaaaa} from 'foo.js'; · ───── ╰──── - help: Reorder the members in the import declaration alphabetically. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:16] 1 │ import {zzzzz, aaaaa /* comment */} from 'foo.js'; · ───── ╰──── - help: Reorder the members in the import declaration alphabetically. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'qux' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:6:17] @@ -123,7 +126,18 @@ source: crates/oxc_linter/src/tester.rs · ────────── 7 │ bar, ╰──── - help: Reorder the members in the import declaration alphabetically. + help: Replace `boop, + foo, + zoo, + baz as qux, + bar, + beep` with `bar, + beep, + boop, + foo, + baz as qux, + zoo`. + note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -225,4 +239,5 @@ source: crates/oxc_linter/src/tester.rs 3 │ import { c, a } from 'c'; · ─ ╰──── - help: Reorder the members in the import declaration alphabetically. + help: Replace `c, a` with `a, c`. + note: Reorder the members in the import declaration alphabetically. From 887831f796bacbfd6e23d2e13b1d313f886c058d Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 26 Feb 2026 18:13:01 -0800 Subject: [PATCH 3/5] fix(linter): pass memberSyntaxSortOrder config into sort_imports help text --- crates/oxc_linter/src/rules/eslint/sort_imports.rs | 5 ++++- crates/oxc_linter/src/snapshots/eslint_sort_imports.snap | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index 7a7e4cb51d991..33efd3257703f 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -21,10 +21,12 @@ use crate::{ fn unexpected_syntax_order_diagnostic( curr_kind: &ImportKind, prev_kind: &ImportKind, + sort_order: &MemberSyntaxSortOrder, span: Span, ) -> OxcDiagnostic { + let order_str = sort_order.iter().join(", "); OxcDiagnostic::warn(format!("Expected '{curr_kind}' syntax before '{prev_kind}' syntax.")) - .with_help("Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option.") + .with_help(format!("Use the memberSyntaxSortOrder [{order_str}] to determine the correct order.")) .with_label(span) } @@ -199,6 +201,7 @@ impl SortImports { ctx.diagnostic(unexpected_syntax_order_diagnostic( current_kind, previous_kind, + &self.member_syntax_sort_order, current.span, )); } diff --git a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap index 5ca84f343b22f..50d37d03267e8 100644 --- a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap +++ b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap @@ -40,7 +40,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {b, c} from 'bar.js'; · ──────────────────────────── ╰──── - help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. + help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -48,7 +48,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as b from 'bar.js'; · ──────────────────────────── ╰──── - help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. + help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'None' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -56,7 +56,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import 'bar.js'; · ──────────────── ╰──── - help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. + help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -64,7 +64,7 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as a from 'foo.js'; · ──────────────────────────── ╰──── - help: Import declarations should be sorted by the used member syntax, following the order specified in the 'memberSyntaxSortOrder' option. + help: Use the memberSyntaxSortOrder [All, Single, Multiple, None] to determine the correct order. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] From 47c61164eba71cb994c96b895b74f1918cc7862f Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 02:14:11 +0000 Subject: [PATCH 4/5] [autofix.ci] apply automated fixes --- crates/oxc_linter/src/rules/eslint/sort_imports.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index 33efd3257703f..ee381b8a3bce6 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -26,7 +26,9 @@ fn unexpected_syntax_order_diagnostic( ) -> OxcDiagnostic { let order_str = sort_order.iter().join(", "); OxcDiagnostic::warn(format!("Expected '{curr_kind}' syntax before '{prev_kind}' syntax.")) - .with_help(format!("Use the memberSyntaxSortOrder [{order_str}] to determine the correct order.")) + .with_help(format!( + "Use the memberSyntaxSortOrder [{order_str}] to determine the correct order." + )) .with_label(span) } From e1d5bebf5694e8165fff071efa487ba0268bc2e1 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Fri, 27 Feb 2026 18:02:00 +0000 Subject: [PATCH 5/5] remove non-actionable sort imports diagnostics --- .../src/rules/eslint/sort_imports.rs | 11 +------ .../src/snapshots/eslint_sort_imports.snap | 29 ------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index ee381b8a3bce6..358e18647bea7 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -21,28 +21,20 @@ use crate::{ fn unexpected_syntax_order_diagnostic( curr_kind: &ImportKind, prev_kind: &ImportKind, - sort_order: &MemberSyntaxSortOrder, span: Span, ) -> OxcDiagnostic { - let order_str = sort_order.iter().join(", "); OxcDiagnostic::warn(format!("Expected '{curr_kind}' syntax before '{prev_kind}' syntax.")) - .with_help(format!( - "Use the memberSyntaxSortOrder [{order_str}] to determine the correct order." - )) .with_label(span) } fn sort_imports_alphabetically_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Imports should be sorted alphabetically.") - .with_help("Reorder import declarations alphabetically by the first member or alias name.") - .with_label(span) + OxcDiagnostic::warn("Imports should be sorted alphabetically.").with_label(span) } fn sort_members_alphabetically_diagnostic(name: &str, span: Span) -> OxcDiagnostic { OxcDiagnostic::warn(format!( "Member '{name}' of the import declaration should be sorted alphabetically." )) - .with_note("Reorder the members in the import declaration alphabetically.") .with_label(span) } @@ -203,7 +195,6 @@ impl SortImports { ctx.diagnostic(unexpected_syntax_order_diagnostic( current_kind, previous_kind, - &self.member_syntax_sort_order, current.span, )); } diff --git a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap index 50d37d03267e8..a48611a91029e 100644 --- a/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap +++ b/crates/oxc_linter/src/snapshots/eslint_sort_imports.snap @@ -8,7 +8,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import A from 'bar.js'; · ─────────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -16,7 +15,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'bar.js'; · ─────────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -24,7 +22,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {a, d} from 'bar.js'; · ──────────────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -32,7 +29,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as bar from 'bar.js'; · ────────────────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Expected 'Multiple' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -40,7 +36,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {b, c} from 'bar.js'; · ──────────────────────────── ╰──── - help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -48,7 +43,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as b from 'bar.js'; · ──────────────────────────── ╰──── - help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'None' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -56,7 +50,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import 'bar.js'; · ──────────────── ╰──── - help: Use the memberSyntaxSortOrder [None, All, Multiple, Single] to determine the correct order. ⚠ eslint(sort-imports): Expected 'All' syntax before 'Single' syntax. ╭─[sort_imports.tsx:2:13] @@ -64,7 +57,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import * as a from 'foo.js'; · ──────────────────────────── ╰──── - help: Use the memberSyntaxSortOrder [All, Single, Multiple, None] to determine the correct order. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] @@ -72,7 +64,6 @@ source: crates/oxc_linter/src/tester.rs · ─ ╰──── help: Replace `b, a, d, c` with `a, b, c, d`. - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] @@ -81,7 +72,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import {e, f, g, h} from 'bar.js'; ╰──── help: Replace `b, a, d, c` with `a, b, c, d`. - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'B' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:12] @@ -89,35 +79,30 @@ source: crates/oxc_linter/src/tester.rs · ─ ╰──── help: Replace `a, B, c, D` with `B, D, a, c`. - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz, /* comment */ aaaaa} from 'foo.js'; · ───── ╰──── - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {zzzzz /* comment */, aaaaa} from 'foo.js'; · ───── ╰──── - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:30] 1 │ import {/* comment */ zzzzz, aaaaa} from 'foo.js'; · ───── ╰──── - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'aaaaa' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:1:16] 1 │ import {zzzzz, aaaaa /* comment */} from 'foo.js'; · ───── ╰──── - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Member 'qux' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:6:17] @@ -137,7 +122,6 @@ source: crates/oxc_linter/src/tester.rs foo, baz as qux, zoo`. - note: Reorder the members in the import declaration alphabetically. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -145,7 +129,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -153,7 +136,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -161,21 +143,18 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:1:19] 1 │ import b from 'b';import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:1:34] 1 │ import b from 'b'; /* comment */ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:13] @@ -183,7 +162,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:28] @@ -191,7 +169,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ /* comment 2 */import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:35] @@ -199,7 +176,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ comment line 2 */ import { a } from 'a'; · ────────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:23] @@ -207,7 +183,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ ╭─▶ from 'b'; import a 3 │ ╰─▶ from 'a'; ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:32] @@ -215,7 +190,6 @@ source: crates/oxc_linter/src/tester.rs 2 │ ╭─▶ 'b'; /* comment */ import 3 │ ╰─▶ { a } from 'a'; ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:3:13] @@ -223,7 +197,6 @@ source: crates/oxc_linter/src/tester.rs 3 │ ╭─▶ import 4 │ ╰─▶ { a } from 'a'; ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:4:13] @@ -231,7 +204,6 @@ source: crates/oxc_linter/src/tester.rs 4 │ import a from 'a'; · ────────────────── ╰──── - help: Reorder import declarations alphabetically by the first member or alias name. ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:3:25] @@ -240,4 +212,3 @@ source: crates/oxc_linter/src/tester.rs · ─ ╰──── help: Replace `c, a` with `a, c`. - note: Reorder the members in the import declaration alphabetically.