-
-
Notifications
You must be signed in to change notification settings - Fork 821
fix(linter): add help/note text to ~150 diagnostics #19135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Closes #19121 Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds actionable with_help / contextual with_note text to many OxcDiagnostic chains across the linter rule set, and updates corresponding snapshot expectations so diagnostic output includes the new guidance (closes #19121).
Changes:
- Append
.with_help(...)and/or.with_note(...)to diagnostics across multiple rule plugins (eslint/import/jest/react/typescript/unicorn/vue/promise/oxc). - Refresh snapshot files to assert the new
help:/note:lines in diagnostic output. - Minor refactors in a few diagnostics to conditionally add help text.
Reviewed changes
Copilot reviewed 188 out of 188 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/vue/require_default_export.rs | Add help text to Vue default-export diagnostics |
| crates/oxc_linter/src/rules/vue/no_export_in_script_setup.rs | Add help text to Vue <script setup> export diagnostics |
| crates/oxc_linter/src/rules/vue/define_props_destructuring.rs | Add help text to defineProps destructuring diagnostics |
| crates/oxc_linter/src/rules/unicorn/no_unreadable_array_destructuring.rs | Add help text for unreadable array destructuring |
| crates/oxc_linter/src/rules/unicorn/no_typeof_undefined.rs | Add help text to typeof-undefined diagnostic |
| crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs | Add help text for object-literal default params |
| crates/oxc_linter/src/rules/unicorn/no_anonymous_default_export.rs | Add help text for anonymous default exports |
| crates/oxc_linter/src/rules/typescript/prefer_enum_initializers.rs | Add help text for enum initializer requirement |
| crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs | Add help text about using primitive types |
| crates/oxc_linter/src/rules/typescript/no_extra_non_null_assertion.rs | Add help text to remove extra non-null assertions |
| crates/oxc_linter/src/rules/typescript/no_empty_interface.rs | Add help text for empty interface diagnostics |
| crates/oxc_linter/src/rules/typescript/no_dynamic_delete.rs | Add help text suggesting Reflect.deleteProperty |
| crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs | Add help text for missing boundary types |
| crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs | Add help text for type/value import guidance |
| crates/oxc_linter/src/rules/typescript/consistent_type_assertions.rs | Add help text suggesting annotation/satisfies |
| crates/oxc_linter/src/rules/typescript/ban_types.rs | Add help/note text for banned TS types diagnostics |
| crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs | Add help text for removing/updating @ts- directives |
| crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs | Add help text to keep overloads adjacent |
| crates/oxc_linter/src/rules/react/style_prop_object.rs | Add help text for style prop object requirement |
| crates/oxc_linter/src/rules/react/rules_of_hooks.rs | Add help text for Rules of Hooks violations |
| crates/oxc_linter/src/rules/react/prefer_es6_class.rs | Add help text for createReactClass vs class usage |
| crates/oxc_linter/src/rules/react/only_export_components.rs | Add help text for fast-refresh export constraints |
| crates/oxc_linter/src/rules/react/no_unescaped_entities.rs | Add help text for escaping entities in JSX |
| crates/oxc_linter/src/rules/react/no_set_state.rs | Add help text discouraging setState |
| crates/oxc_linter/src/rules/react/no_redundant_should_component_update.rs | Add help text to remove redundant SCU |
| crates/oxc_linter/src/rules/react/no_namespace.rs | Add help text for disallowing namespaced JSX |
| crates/oxc_linter/src/rules/react/jsx_props_no_spreading.rs | Add help text for avoiding JSX prop spreading |
| crates/oxc_linter/src/rules/react/jsx_pascal_case.rs | Add help text for PascalCase JSX components |
| crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs | Add help text for removing useless fragments |
| crates/oxc_linter/src/rules/react/jsx_no_undef.rs | Add help text to import/declare missing components |
| crates/oxc_linter/src/rules/react/jsx_no_comment_textnodes.rs | Add help text for JSX comment braces |
| crates/oxc_linter/src/rules/react/jsx_max_depth.rs | Add help text suggesting extracting nested JSX |
| crates/oxc_linter/src/rules/react/jsx_key.rs | Add help text to add key props |
| crates/oxc_linter/src/rules/react/forbid_dom_props.rs | Add help text to remove forbidden DOM props |
| crates/oxc_linter/src/rules/promise/valid_params.rs | Add help text for incorrect Promise method arity |
| crates/oxc_linter/src/rules/promise/spec_only.rs | Add help text to use standard Promise methods |
| crates/oxc_linter/src/rules/promise/no_multiple_resolved.rs | Add help text to early-return after resolve/reject |
| crates/oxc_linter/src/rules/promise/avoid_new.rs | Add help text suggesting async/await |
| crates/oxc_linter/src/rules/oxc/no_rest_spread_properties.rs | Add help text for avoiding object rest/spread |
| crates/oxc_linter/src/rules/jest/no_test_return_statement.rs | Add help text to use await in tests |
| crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs | Add help text for restricted matcher chains |
| crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs | Add help text for restricted jest/vi methods |
| crates/oxc_linter/src/rules/jest/no_hooks.rs | Add help text to use helpers instead of hooks |
| crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs | Add help text for jest.setTimeout placement |
| crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs | Add help text for conditionals in tests |
| crates/oxc_linter/src/rules/import/no_self_import.rs | Add help text for self-import removal |
| crates/oxc_linter/src/rules/import/no_nodejs_modules.rs | Add help text about allowlist/alternatives |
| crates/oxc_linter/src/rules/import/no_mutable_exports.rs | Add help text to use const exports |
| crates/oxc_linter/src/rules/import/no_default_export.rs | Add help text to prefer named exports |
| crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs | Add help text to name default exports |
| crates/oxc_linter/src/rules/import/no_absolute_path.rs | Add help text to use relative paths |
| crates/oxc_linter/src/rules/import/namespace.rs | Add help/note text for namespace import diagnostics |
| crates/oxc_linter/src/rules/import/exports_last.rs | Add help text to move exports to file end |
| crates/oxc_linter/src/rules/import/export.rs | Add help text for export/re-export issues |
| crates/oxc_linter/src/rules/eslint/symbol_description.rs | Add help text to add Symbol description |
| crates/oxc_linter/src/rules/eslint/require_yield.rs | Add help text to add yield |
| crates/oxc_linter/src/rules/eslint/radix.rs | Add help text for parseInt radix usage |
| crates/oxc_linter/src/rules/eslint/prefer_promise_reject_errors.rs | Add help text to reject with Error |
| crates/oxc_linter/src/rules/eslint/no_useless_catch.rs | Add help text for removing redundant try/catch |
| crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs | Add explanatory note to useless backreference diagnostics |
| crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs | Add help text to remove unused private members |
| crates/oxc_linter/src/rules/eslint/no_unreachable.rs | Add help text to remove unreachable code |
| crates/oxc_linter/src/rules/eslint/no_undefined.rs | Add help text to use void 0 |
| crates/oxc_linter/src/rules/eslint/no_undef.rs | Add help text to declare/fix references |
| crates/oxc_linter/src/rules/eslint/no_throw_literal.rs | Add help text to throw Error objects |
| crates/oxc_linter/src/rules/eslint/no_setter_return.rs | Add help text to remove setter return value |
| crates/oxc_linter/src/rules/eslint/no_self_assign.rs | Add help text to remove self-assignment |
| crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs | Conditionally add help when no suffix guidance exists |
| crates/oxc_linter/src/rules/eslint/no_redeclare.rs | Add help text for redeclarations |
| crates/oxc_linter/src/rules/eslint/no_param_reassign.rs | Add help text to use locals instead of param reassignment |
| crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs | Add help text to use Unicode escapes |
| crates/oxc_linter/src/rules/eslint/no_new_func.rs | Add help text to avoid Function constructor |
| crates/oxc_linter/src/rules/eslint/no_new.rs | Add help text to avoid new for side effects |
| crates/oxc_linter/src/rules/eslint/no_nested_ternary.rs | Add help text to refactor nested ternaries |
| crates/oxc_linter/src/rules/eslint/no_multi_str.rs | Add help text to use template literals/concat |
| crates/oxc_linter/src/rules/eslint/no_misleading_character_class.rs | Add explanatory notes about multi-code-point chars |
| crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs | Add help text for consts / extracting constants |
| crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs | Add help text to use BigInt/adjust value |
| crates/oxc_linter/src/rules/eslint/no_lone_blocks.rs | Add help text to remove redundant blocks |
| crates/oxc_linter/src/rules/eslint/no_labels.rs | Add help text to use control flow statements |
| crates/oxc_linter/src/rules/eslint/no_label_var.rs | Add help text to rename label/variable |
| crates/oxc_linter/src/rules/eslint/no_global_assign.rs | Add help text to assign locally instead |
| crates/oxc_linter/src/rules/eslint/no_func_assign.rs | Add help text to use different variable name |
| crates/oxc_linter/src/rules/eslint/no_fallthrough.rs | Add help text for break/return or comment removal |
| crates/oxc_linter/src/rules/eslint/no_extend_native.rs | Add help text to avoid modifying native prototypes |
| crates/oxc_linter/src/rules/eslint/no_eval.rs | Add help text suggesting safer alternatives |
| crates/oxc_linter/src/rules/eslint/no_delete_var.rs | Add note about delete validity |
| crates/oxc_linter/src/rules/eslint/no_control_regex.rs | Add help text to use Unicode escapes |
| crates/oxc_linter/src/rules/eslint/no_constructor_return.rs | Add help text to remove constructor return value |
| crates/oxc_linter/src/rules/eslint/no_const_assign.rs | Add help text suggesting let when needed |
| crates/oxc_linter/src/rules/eslint/no_class_assign.rs | Add help text to use different variable name |
| crates/oxc_linter/src/rules/eslint/no_case_declarations.rs | Add help text to wrap case in braces |
| crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs | Add help text suggesting Promise aggregation |
| crates/oxc_linter/src/rules/eslint/no_async_promise_executor.rs | Add help text to remove async from executor |
| crates/oxc_linter/src/snapshots/vue_require_default_export.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/vue_no_export_in_script_setup.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/vue_define_props_destructuring.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/unicorn_no_typeof_undefined.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/unicorn_no_object_as_default_parameter.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/typescript_prefer_enum_initializers.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/typescript_no_wrapper_object_types.snap | Snapshot updated to include updated help text |
| crates/oxc_linter/src/snapshots/typescript_no_extra_non_null_assertion.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/typescript_no_empty_interface.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/typescript_no_dynamic_delete.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_style_prop_object.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_prefer_es6_class.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_only_export_components.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_no_unescaped_entities.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_no_set_state.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_no_redundant_should_component_update.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_no_namespace.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_props_no_spreading.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_pascal_case.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_no_undef.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_no_comment_textnodes.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_max_depth.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_jsx_key.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/react_forbid_dom_props.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/promise_valid_params.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/promise_spec_only.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/promise_no_multiple_resolved.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/promise_avoid_new.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/oxc_no_rest_spread_properties.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/jest_no_test_return_statement.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/jest_no_restricted_matchers.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/jest_no_restricted_jest_methods.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/jest_no_hooks.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_no_nodejs_modules.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_no_mutable_exports.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_no_default_export.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_no_anonymous_default_export.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_no_absolute_path.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_exports_last.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/import_export.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_symbol_description.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_require_yield.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_radix.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_useless_catch.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_unreachable.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_restricted_globals.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_new_func.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_new.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_nested_ternary.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_multi_str.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_label_var.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_global_assign.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_func_assign.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_delete_var.snap | Snapshot updated to include new note line |
| crates/oxc_linter/src/snapshots/[email protected] | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_constructor_return.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_class_assign.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_case_declarations.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_await_in_loop.snap | Snapshot updated to include new help lines |
| crates/oxc_linter/src/snapshots/eslint_no_async_promise_executor.snap | Snapshot updated to include new help lines |
| OxcDiagnostic::warn(format!("Assignment to member of namespace {namespace_name:?}.'")) | ||
| .with_note("Imported namespace members are read-only.") | ||
| .with_label(span) |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diagnostic message has a stray .' at the end ("...{namespace_name:?}.'"), which will show up in user-facing output. Remove the extra punctuation/quote so the message reads cleanly (e.g. ends with a single period).
| OxcDiagnostic::warn("<script setup>` cannot contain ES module exports.") | ||
| .with_help("Use `defineExpose` instead") | ||
| .with_label(span) |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message has mismatched backticks: "<script setup> cannot contain ES module exports."is missing the opening backtick before<script setup>. This renders oddly in diagnostics; wrap the full tag in backticks (e.g. `` <script setup>` cannot ... ``).
| 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), | ||
| Problem::Nested =>OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' from within that group.")).with_note("This backreference always matches the empty string.").with_label(span), | ||
| Problem::Disjunctive => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which is in another alternative.")).with_note("This backreference always matches the empty string.").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_note("This backreference always matches the empty string.").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_note("This backreference always matches the empty string.").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_note("This backreference always matches the empty string.").with_label(span), |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This match arm chain is not rustfmt-formatted (e.g. missing space after =>, very long single-line chains). If CI runs cargo fmt --check, this will fail; please run rustfmt and split the diagnostic builder across lines for readability.
| OxcDiagnostic::warn("'The `Object` type actually means \"any non-nullish value\"") | ||
| .with_help("Use `object` or define an explicit object shape.") | ||
| .with_note("The `Object` type includes primitives like strings and numbers, which is rarely intended.") | ||
| .with_label(span) |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Object diagnostic message starts with an extra leading apostrophe ("'The ..."), which will appear in the user-facing output. Remove the stray ' so the message renders correctly.
Merging this PR will not alter performance
Comparing Footnotes
|
| assign_span.label(format!("{name} is re-assigned here")), | ||
| ]) | ||
| OxcDiagnostic::warn(format!("Unexpected re-assignment of class {name}")) | ||
| .with_help("Use a different variable name.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure if this is good advice. honestly with the whole point of this rule I feel like the only advice we can give is just: don't do it? don't assign to a class?
| } else { | ||
| "Unexpected control character" | ||
| }) | ||
| .with_help("Use a Unicode escape sequence instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't actually fix the issue because we report on unicode escapes too. i think if they meant to use a control character, they should disable the rule for this line/file or the rule altogether. this isn't really any specific help I can think of
| fn no_eval_diagnostic(span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn("eval can be harmful.").with_label(span) | ||
| OxcDiagnostic::warn("eval can be harmful.") | ||
| .with_help("Use 'JSON.parse()' or a function call instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .with_help("Use 'JSON.parse()' or a function call instead.") | |
| .with_help("For parsing JSON, consider using 'JSON.parse()'. Otherwise, try refactoring the code to not use `eval` at all.") |
|
|
||
| fn no_func_assign_diagnostic(name: &str, span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn(format!("'{name}' is a function.")) | ||
| .with_help("Use a different variable name.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to no-class-assign, I don't think this is the right help message. you just shouldn't assign to it at all really. i'm not exactly sure what to suggest.
| fn no_labels_diagnostic(message: &'static str, label_span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn(message).with_label(label_span) | ||
| OxcDiagnostic::warn(message) | ||
| .with_help("Use control flow statements instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit vague still, could probably be more like
| .with_help("Use control flow statements instead.") | |
| .with_help("Use control flow statements like if/while/case/for instead.") |
| fn no_loss_of_precision_diagnostic(span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn("This number literal will lose precision at runtime.").with_label(span) | ||
| OxcDiagnostic::warn("This number literal will lose precision at runtime.") | ||
| .with_help("Use 'BigInt' or adjust the value.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth adding a note here about 9007199254740991 and Number.MAX_SAFE_INTEGER and how any number larger than that might be rounded to a different integer
| OxcDiagnostic::warn(format!("No magic number: {raw}")) | ||
| .with_help("Extract into a named constant.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message here is also not very good:
| OxcDiagnostic::warn(format!("No magic number: {raw}")) | |
| .with_help("Extract into a named constant.") | |
| OxcDiagnostic::warn(format!("The number {raw} is used, but has no name given to it.")) | |
| .with_help("Extract into a named constant.") |
camchenry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Boshen there are too many changes to review here I think. I've reviewed quite a few of these files already, and i have enough concerns as it is to say we shouldn't merge this in its current state. i think it would be easier to split this up into smaller chunks, no more than 5 or so and get more eyes on it.
| OxcDiagnostic::warn("The Function constructor is eval.") | ||
| .with_help("Use a function expression or declaration.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's also another PR open to address this, but we should also update the message here too
| fn no_nonoctal_decimal_escape_diagnostic(escape_sequence: &str, span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn(format!("Don't use '{escape_sequence}' escape sequence.")).with_label(span) | ||
| OxcDiagnostic::warn(format!("Don't use '{escape_sequence}' escape sequence.")) | ||
| .with_help("Use a Unicode escape sequence instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure this is good advice either, you probably shouldn't use these at all. at best, we could recommend replacing it with how it's interpreted (\8 -> 8)?
| OxcDiagnostic::warn("this expression is assigned to itself") | ||
| .with_help("Remove this self-assignment.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| OxcDiagnostic::warn("this expression is assigned to itself") | |
| .with_help("Remove this self-assignment.") | |
| OxcDiagnostic::warn("This expression is assigning to itself") | |
| .with_help("Remove this expression.") |
| fn no_undef_diagnostic(name: &str, span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn(format!("'{name}' is not defined.")).with_label(span) | ||
| OxcDiagnostic::warn(format!("'{name}' is not defined.")) | ||
| .with_help("Declare the variable or fix the reference.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably worth mentioning this might be due to missing entries in globals too, and we might want to include a link to the oxlint docs on that
| fn no_undefined_diagnostic(span: Span) -> OxcDiagnostic { | ||
| OxcDiagnostic::warn("Unexpected use of `undefined`").with_label(span) | ||
| OxcDiagnostic::warn("Unexpected use of `undefined`") | ||
| .with_help("Use 'void 0' instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably wrong quite often, it depends on the context. for example you can't replace const undefined = "foo"; with const void 0 = "foo";. we could at least say like: consider using void 0 for expressions, and consider using a different name otherwise
Summary
Closes #19121
.with_help()to ~150 linter diagnostics across all plugin groups (eslint, import, jest, react, typescript, unicorn, vue, promise, oxc).with_note()where explanatory context is more appropriate than actionable advice.warn()message already contains actionable guidance (e.g. "Prefer X over Y" rules)🤖 Generated with Claude Code