From c11f20f1e8bec68c6331fa4f079804c0cbf502de Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Thu, 18 Jul 2024 11:27:34 -0400 Subject: [PATCH] style: clippy fixes --- crates/oxc_diagnostics/src/lib.rs | 17 +- crates/oxc_language_server/src/linter.rs | 9 +- crates/oxc_linter/src/context.rs | 64 ++- crates/oxc_linter/src/frameworks.rs | 85 +++ crates/oxc_linter/src/lib.rs | 55 +- crates/oxc_linter/src/options.rs | 6 +- .../rules/eslint/array_callback_return/mod.rs | 16 +- .../src/rules/eslint/constructor_super.rs | 4 +- .../src/rules/eslint/default_case.rs | 2 +- .../src/rules/eslint/default_case_last.rs | 6 +- .../src/rules/eslint/default_param_last.rs | 2 +- crates/oxc_linter/src/rules/eslint/eqeqeq.rs | 2 +- .../src/rules/eslint/for_direction.rs | 2 +- .../src/rules/eslint/getter_return.rs | 2 +- .../src/rules/eslint/guard_for_in.rs | 2 +- .../src/rules/eslint/max_classes_per_file.rs | 8 +- .../oxc_linter/src/rules/eslint/max_lines.rs | 2 +- .../oxc_linter/src/rules/eslint/max_params.rs | 2 +- .../src/rules/eslint/no_array_constructor.rs | 2 +- .../rules/eslint/no_async_promise_executor.rs | 5 +- .../src/rules/eslint/no_await_in_loop.rs | 3 +- .../oxc_linter/src/rules/eslint/no_bitwise.rs | 2 +- .../oxc_linter/src/rules/eslint/no_caller.rs | 2 +- .../src/rules/eslint/no_case_declarations.rs | 5 +- .../src/rules/eslint/no_class_assign.rs | 9 +- .../src/rules/eslint/no_compare_neg_zero.rs | 8 +- .../src/rules/eslint/no_cond_assign.rs | 8 +- .../oxc_linter/src/rules/eslint/no_console.rs | 2 +- .../src/rules/eslint/no_const_assign.rs | 5 +- .../eslint/no_constant_binary_expression.rs | 28 +- .../src/rules/eslint/no_constant_condition.rs | 2 +- .../src/rules/eslint/no_constructor_return.rs | 5 +- .../src/rules/eslint/no_continue.rs | 2 +- .../src/rules/eslint/no_control_regex.rs | 2 +- .../src/rules/eslint/no_debugger.rs | 3 +- .../src/rules/eslint/no_delete_var.rs | 2 +- .../src/rules/eslint/no_div_regex.rs | 8 +- .../src/rules/eslint/no_dupe_class_members.rs | 2 +- .../src/rules/eslint/no_dupe_else_if.rs | 2 +- .../src/rules/eslint/no_dupe_keys.rs | 2 +- .../src/rules/eslint/no_duplicate_case.rs | 2 +- .../oxc_linter/src/rules/eslint/no_empty.rs | 2 +- .../rules/eslint/no_empty_character_class.rs | 2 +- .../src/rules/eslint/no_empty_function.rs | 2 +- .../src/rules/eslint/no_empty_pattern.rs | 2 +- .../src/rules/eslint/no_empty_static_block.rs | 2 +- .../oxc_linter/src/rules/eslint/no_eq_null.rs | 2 +- crates/oxc_linter/src/rules/eslint/no_eval.rs | 2 +- .../src/rules/eslint/no_ex_assign.rs | 2 +- .../src/rules/eslint/no_extra_boolean_cast.rs | 4 +- .../src/rules/eslint/no_fallthrough.rs | 12 +- .../src/rules/eslint/no_func_assign.rs | 2 +- .../src/rules/eslint/no_global_assign.rs | 6 +- .../src/rules/eslint/no_import_assign.rs | 2 +- .../src/rules/eslint/no_inner_declarations.rs | 2 +- .../rules/eslint/no_irregular_whitespace.rs | 2 +- .../src/rules/eslint/no_iterator.rs | 2 +- .../src/rules/eslint/no_label_var.rs | 12 +- .../src/rules/eslint/no_loss_of_precision.rs | 5 +- .../src/rules/eslint/no_multi_str.rs | 2 +- crates/oxc_linter/src/rules/eslint/no_new.rs | 2 +- .../eslint/no_new_native_nonconstructor.rs | 5 +- .../src/rules/eslint/no_new_wrappers.rs | 2 +- .../eslint/no_nonoctal_decimal_escape.rs | 16 +- .../src/rules/eslint/no_obj_calls.rs | 2 +- .../oxc_linter/src/rules/eslint/no_proto.rs | 2 +- .../src/rules/eslint/no_prototype_builtins.rs | 6 +- .../src/rules/eslint/no_redeclare.rs | 10 +- .../src/rules/eslint/no_regex_spaces.rs | 2 +- .../src/rules/eslint/no_restricted_globals.rs | 4 +- .../src/rules/eslint/no_script_url.rs | 2 +- .../src/rules/eslint/no_self_assign.rs | 3 +- .../src/rules/eslint/no_self_compare.rs | 8 +- .../src/rules/eslint/no_setter_return.rs | 2 +- .../eslint/no_shadow_restricted_names.rs | 2 +- .../src/rules/eslint/no_sparse_arrays.rs | 10 +- .../eslint/no_template_curly_in_string.rs | 8 +- .../oxc_linter/src/rules/eslint/no_ternary.rs | 2 +- .../src/rules/eslint/no_this_before_super.rs | 2 +- .../oxc_linter/src/rules/eslint/no_undef.rs | 2 +- .../src/rules/eslint/no_undefined.rs | 2 +- .../src/rules/eslint/no_unreachable.rs | 2 +- .../src/rules/eslint/no_unsafe_finally.rs | 2 +- .../eslint/no_unsafe_optional_chaining.rs | 10 +- .../src/rules/eslint/no_unused_labels.rs | 2 +- .../eslint/no_unused_private_class_members.rs | 5 +- .../src/rules/eslint/no_useless_catch.rs | 4 +- .../src/rules/eslint/no_useless_concat.rs | 2 +- .../rules/eslint/no_useless_constructor.rs | 4 +- .../src/rules/eslint/no_useless_escape.rs | 3 +- .../src/rules/eslint/no_useless_rename.rs | 8 +- crates/oxc_linter/src/rules/eslint/no_var.rs | 2 +- crates/oxc_linter/src/rules/eslint/no_void.rs | 2 +- crates/oxc_linter/src/rules/eslint/no_with.rs | 2 +- .../eslint/prefer_exponentiation_operator.rs | 5 +- crates/oxc_linter/src/rules/eslint/radix.rs | 12 +- .../src/rules/eslint/require_await.rs | 3 +- .../src/rules/eslint/require_yield.rs | 3 +- .../src/rules/eslint/sort_imports.rs | 14 +- .../src/rules/eslint/symbol_description.rs | 3 +- .../src/rules/eslint/unicode_bom.rs | 4 +- .../oxc_linter/src/rules/eslint/use_isnan.rs | 8 +- .../src/rules/eslint/valid_typeof.rs | 9 +- crates/oxc_linter/src/rules/import/default.rs | 8 +- crates/oxc_linter/src/rules/import/export.rs | 14 +- .../src/rules/import/max_dependencies.rs | 2 +- crates/oxc_linter/src/rules/import/named.rs | 2 +- .../oxc_linter/src/rules/import/namespace.rs | 21 +- crates/oxc_linter/src/rules/import/no_amd.rs | 8 +- .../oxc_linter/src/rules/import/no_cycle.rs | 2 +- .../src/rules/import/no_default_export.rs | 3 +- .../src/rules/import/no_deprecated.rs | 2 +- .../src/rules/import/no_duplicates.rs | 7 +- .../src/rules/import/no_named_as_default.rs | 2 +- .../import/no_named_as_default_member.rs | 8 +- .../src/rules/import/no_self_import.rs | 5 +- .../src/rules/import/no_unused_modules.rs | 2 +- .../rules/import/no_webpack_loader_syntax.rs | 8 +- .../src/rules/jest/consistent_test_it.rs | 36 +- .../src/rules/jest/expect_expect.rs | 13 +- .../oxc_linter/src/rules/jest/max_expects.rs | 2 +- .../src/rules/jest/max_nested_describe.rs | 8 +- .../src/rules/jest/no_alias_methods.rs | 18 +- .../src/rules/jest/no_commented_out_tests.rs | 8 +- .../src/rules/jest/no_conditional_expect.rs | 2 +- .../rules/jest/no_confusing_set_timeout.rs | 11 +- .../src/rules/jest/no_deprecated_functions.rs | 8 +- .../src/rules/jest/no_disabled_tests.rs | 53 +- .../src/rules/jest/no_done_callback.rs | 16 +- .../src/rules/jest/no_duplicate_hooks.rs | 8 +- crates/oxc_linter/src/rules/jest/no_export.rs | 2 +- .../src/rules/jest/no_focused_tests.rs | 58 +-- crates/oxc_linter/src/rules/jest/no_hooks.rs | 3 +- .../src/rules/jest/no_identical_title.rs | 6 +- .../jest/no_interpolation_in_snapshots.rs | 2 +- .../src/rules/jest/no_jasmine_globals.rs | 4 +- .../src/rules/jest/no_large_snapshots.rs | 4 +- .../src/rules/jest/no_mocks_import.rs | 2 +- .../rules/jest/no_restricted_jest_methods.rs | 16 +- .../src/rules/jest/no_restricted_matchers.rs | 16 +- .../src/rules/jest/no_standalone_expect.rs | 8 +- .../src/rules/jest/no_test_prefixes.rs | 17 +- .../rules/jest/no_test_return_statement.rs | 5 +- .../src/rules/jest/no_untyped_mock_factory.rs | 8 +- .../src/rules/jest/prefer_called_with.rs | 4 +- .../rules/jest/prefer_comparison_matcher.rs | 2 +- .../src/rules/jest/prefer_equality_matcher.rs | 2 +- .../src/rules/jest/prefer_expect_resolves.rs | 2 +- .../src/rules/jest/prefer_hooks_in_order.rs | 23 +- .../src/rules/jest/prefer_hooks_on_top.rs | 8 +- .../src/rules/jest/prefer_jest_mocked.rs | 8 +- .../src/rules/jest/prefer_lowercase_title.rs | 2 +- .../jest/prefer_mock_promise_shorthand.rs | 4 +- .../src/rules/jest/prefer_spy_on.rs | 2 +- .../src/rules/jest/prefer_strict_equal.rs | 2 +- .../oxc_linter/src/rules/jest/prefer_to_be.rs | 17 +- .../src/rules/jest/prefer_to_contain.rs | 3 +- .../src/rules/jest/prefer_to_have_length.rs | 5 +- .../oxc_linter/src/rules/jest/prefer_todo.rs | 6 +- .../oxc_linter/src/rules/jest/require_hook.rs | 8 +- .../rules/jest/require_to_throw_message.rs | 8 +- .../rules/jest/require_top_level_describe.rs | 26 +- .../src/rules/jest/valid_describe_callback.rs | 16 +- .../oxc_linter/src/rules/jest/valid_expect.rs | 28 +- .../oxc_linter/src/rules/jest/valid_title.rs | 4 +- .../src/rules/jsdoc/check_access.rs | 16 +- .../src/rules/jsdoc/check_property_names.rs | 18 +- .../src/rules/jsdoc/check_tag_names.rs | 4 +- .../oxc_linter/src/rules/jsdoc/empty_tags.rs | 8 +- .../src/rules/jsdoc/implements_on_classes.rs | 2 +- .../oxc_linter/src/rules/jsdoc/no_defaults.rs | 4 +- .../src/rules/jsdoc/require_param.rs | 2 +- .../rules/jsdoc/require_param_description.rs | 8 +- .../src/rules/jsdoc/require_param_name.rs | 2 +- .../src/rules/jsdoc/require_param_type.rs | 2 +- .../src/rules/jsdoc/require_property.rs | 8 +- .../jsdoc/require_property_description.rs | 8 +- .../src/rules/jsdoc/require_property_name.rs | 8 +- .../src/rules/jsdoc/require_property_type.rs | 8 +- .../src/rules/jsdoc/require_returns.rs | 10 +- .../jsdoc/require_returns_description.rs | 8 +- .../src/rules/jsdoc/require_returns_type.rs | 2 +- .../src/rules/jsdoc/require_yields.rs | 6 +- .../oxc_linter/src/rules/jsx_a11y/alt_text.rs | 22 +- .../src/rules/jsx_a11y/anchor_has_content.rs | 4 +- .../src/rules/jsx_a11y/anchor_is_valid.rs | 24 +- .../aria_activedescendant_has_tabindex.rs | 6 +- .../src/rules/jsx_a11y/aria_props.rs | 4 +- .../src/rules/jsx_a11y/aria_role.rs | 2 +- .../jsx_a11y/aria_unsupported_elements.rs | 2 +- .../src/rules/jsx_a11y/autocomplete_valid.rs | 2 +- .../jsx_a11y/click_events_have_key_events.rs | 2 +- .../src/rules/jsx_a11y/heading_has_content.rs | 8 +- .../src/rules/jsx_a11y/html_has_lang.rs | 4 +- .../src/rules/jsx_a11y/iframe_has_title.rs | 2 +- .../src/rules/jsx_a11y/img_redundant_alt.rs | 2 +- crates/oxc_linter/src/rules/jsx_a11y/lang.rs | 2 +- .../src/rules/jsx_a11y/media_has_caption.rs | 2 +- .../jsx_a11y/mouse_events_have_key_events.rs | 4 +- .../src/rules/jsx_a11y/no_access_key.rs | 2 +- .../jsx_a11y/no_aria_hidden_on_focusable.rs | 2 +- .../src/rules/jsx_a11y/no_autofocus.rs | 2 +- .../rules/jsx_a11y/no_distracting_elements.rs | 2 +- .../src/rules/jsx_a11y/no_redundant_roles.rs | 2 +- .../rules/jsx_a11y/prefer_tag_over_role.rs | 2 +- .../jsx_a11y/role_has_required_aria_props.rs | 2 +- .../jsx_a11y/role_supports_aria_props.rs | 4 +- crates/oxc_linter/src/rules/jsx_a11y/scope.rs | 8 +- .../rules/jsx_a11y/tabindex_no_positive.rs | 8 +- .../src/rules/nextjs/google_font_display.rs | 16 +- .../rules/nextjs/google_font_preconnect.rs | 2 +- .../src/rules/nextjs/inline_script_id.rs | 8 +- .../src/rules/nextjs/next_script_for_ga.rs | 8 +- .../rules/nextjs/no_assign_module_variable.rs | 8 +- .../rules/nextjs/no_async_client_component.rs | 2 +- ...ore_interactive_script_outside_document.rs | 2 +- .../src/rules/nextjs/no_css_tags.rs | 2 +- .../nextjs/no_document_import_in_page.rs | 2 +- .../src/rules/nextjs/no_duplicate_head.rs | 2 +- .../src/rules/nextjs/no_head_element.rs | 2 +- .../nextjs/no_head_import_in_document.rs | 2 +- .../src/rules/nextjs/no_img_element.rs | 2 +- .../src/rules/nextjs/no_page_custom_font.rs | 4 +- .../nextjs/no_script_component_in_head.rs | 2 +- .../rules/nextjs/no_styled_jsx_in_document.rs | 2 +- .../src/rules/nextjs/no_sync_scripts.rs | 2 +- .../rules/nextjs/no_title_in_document_head.rs | 2 +- .../oxc_linter/src/rules/nextjs/no_typos.rs | 8 +- .../rules/nextjs/no_unwanted_polyfillio.rs | 8 +- .../src/rules/oxc/approx_constant.rs | 2 +- .../oxc/bad_array_method_on_arguments.rs | 2 +- .../src/rules/oxc/bad_bitwise_operator.rs | 2 +- .../src/rules/oxc/bad_char_at_comparison.rs | 2 +- .../src/rules/oxc/bad_comparison_sequence.rs | 2 +- .../src/rules/oxc/bad_min_max_func.rs | 12 +- .../oxc/bad_object_literal_comparison.rs | 4 +- .../src/rules/oxc/bad_replace_all_arg.rs | 2 +- .../src/rules/oxc/const_comparisons.rs | 14 +- .../src/rules/oxc/double_comparisons.rs | 2 +- crates/oxc_linter/src/rules/oxc/erasing_op.rs | 2 +- .../src/rules/oxc/misrefactored_assign_op.rs | 8 +- .../oxc_linter/src/rules/oxc/missing_throw.rs | 2 +- .../src/rules/oxc/no_accumulating_spread.rs | 6 +- .../src/rules/oxc/no_async_await.rs | 2 +- .../src/rules/oxc/no_barrel_file.rs | 2 +- .../oxc_linter/src/rules/oxc/no_const_enum.rs | 2 +- .../src/rules/oxc/no_optional_chaining.rs | 5 +- .../rules/oxc/no_rest_spread_properties.rs | 3 +- .../src/rules/oxc/number_arg_out_of_range.rs | 10 +- .../src/rules/oxc/only_used_in_recursion.rs | 2 +- .../src/rules/oxc/uninvoked_array_callback.rs | 2 +- .../oxc_linter/src/rules/promise/avoid_new.rs | 3 +- .../src/rules/promise/no_new_statics.rs | 5 +- .../src/rules/promise/param_names.rs | 3 +- .../src/rules/react/button_has_type.rs | 4 +- .../checked_requires_onchange_or_readonly.rs | 4 +- crates/oxc_linter/src/rules/react/jsx_key.rs | 7 +- .../rules/react/jsx_no_comment_textnodes.rs | 3 +- .../src/rules/react/jsx_no_duplicate_props.rs | 2 +- .../src/rules/react/jsx_no_target_blank.rs | 6 +- .../src/rules/react/jsx_no_undef.rs | 2 +- .../rules/react/jsx_no_useless_fragment.rs | 4 +- .../src/rules/react/no_children_prop.rs | 8 +- .../oxc_linter/src/rules/react/no_danger.rs | 2 +- .../rules/react/no_direct_mutation_state.rs | 8 +- .../src/rules/react/no_find_dom_node.rs | 2 +- .../src/rules/react/no_is_mounted.rs | 2 +- .../src/rules/react/no_render_return_value.rs | 2 +- .../src/rules/react/no_set_state.rs | 2 +- .../src/rules/react/no_string_refs.rs | 6 +- .../src/rules/react/no_unescaped_entities.rs | 5 +- .../src/rules/react/no_unknown_property.rs | 14 +- .../src/rules/react/prefer_es6_class.rs | 6 +- .../src/rules/react/react_in_jsx_scope.rs | 2 +- .../src/rules/react/require_render_return.rs | 2 +- .../src/rules/react/rules_of_hooks.rs | 29 +- .../react/void_dom_elements_no_children.rs | 8 +- .../rules/react_perf/jsx_no_jsx_as_prop.rs | 2 +- .../react_perf/jsx_no_new_array_as_prop.rs | 2 +- .../react_perf/jsx_no_new_function_as_prop.rs | 2 +- .../react_perf/jsx_no_new_object_as_prop.rs | 2 +- .../no_side_effects_in_initialization/mod.rs | 44 +- .../adjacent_overload_signatures.rs | 4 +- .../src/rules/typescript/array_type.rs | 17 +- .../src/rules/typescript/ban_ts_comment.rs | 12 +- .../rules/typescript/ban_tslint_comment.rs | 5 +- .../src/rules/typescript/ban_types.rs | 16 +- .../consistent_indexed_object_style.rs | 8 +- .../typescript/consistent_type_definitions.rs | 4 +- .../typescript/consistent_type_imports.rs | 20 +- .../explicit_function_return_type.rs | 8 +- .../no_confusing_non_null_assertion.rs | 4 +- .../typescript/no_duplicate_enum_values.rs | 8 +- .../src/rules/typescript/no_dynamic_delete.rs | 8 +- .../rules/typescript/no_empty_interface.rs | 8 +- .../src/rules/typescript/no_explicit_any.rs | 2 +- .../typescript/no_extra_non_null_assertion.rs | 3 +- .../typescript/no_import_type_side_effects.rs | 2 +- .../src/rules/typescript/no_misused_new.rs | 10 +- .../src/rules/typescript/no_namespace.rs | 8 +- ...no_non_null_asserted_nullish_coalescing.rs | 2 +- .../no_non_null_asserted_optional_chain.rs | 2 +- .../rules/typescript/no_non_null_assertion.rs | 2 +- .../src/rules/typescript/no_this_alias.rs | 8 +- .../no_unnecessary_type_constraint.rs | 8 +- .../no_unsafe_declaration_merging.rs | 2 +- .../typescript/no_useless_empty_export.rs | 8 +- .../src/rules/typescript/no_var_requires.rs | 8 +- .../src/rules/typescript/prefer_as_const.rs | 2 +- .../typescript/prefer_enum_initializers.rs | 2 +- .../src/rules/typescript/prefer_for_of.rs | 8 +- .../rules/typescript/prefer_function_type.rs | 2 +- .../typescript/prefer_literal_enum_member.rs | 8 +- .../typescript/prefer_ts_expect_error.rs | 2 +- .../typescript/triple_slash_reference.rs | 2 +- .../src/rules/unicorn/catch_error_name.rs | 6 +- .../src/rules/unicorn/empty_brace_spaces.rs | 2 +- .../src/rules/unicorn/error_message.rs | 13 +- .../src/rules/unicorn/escape_case.rs | 3 +- .../rules/unicorn/explicit_length_check.rs | 7 +- .../src/rules/unicorn/filename_case.rs | 5 +- .../src/rules/unicorn/new_for_builtins.rs | 10 +- .../unicorn/no_abusive_eslint_disable.rs | 8 +- .../unicorn/no_anonymous_default_export.rs | 2 +- .../src/rules/unicorn/no_array_for_each.rs | 2 +- .../src/rules/unicorn/no_array_reduce.rs | 8 +- .../unicorn/no_await_expression_member.rs | 2 +- .../unicorn/no_await_in_promise_methods.rs | 2 +- .../src/rules/unicorn/no_console_spaces.rs | 2 +- .../src/rules/unicorn/no_document_cookie.rs | 8 +- .../src/rules/unicorn/no_empty_file.rs | 2 +- .../src/rules/unicorn/no_hex_escape.rs | 5 +- .../src/rules/unicorn/no_instanceof_array.rs | 2 +- .../no_invalid_remove_event_listener.rs | 2 +- .../src/rules/unicorn/no_lonely_if.rs | 2 +- .../unicorn/no_magic_array_flat_depth.rs | 2 +- .../src/rules/unicorn/no_negated_condition.rs | 8 +- .../unicorn/no_negation_in_equality_check.rs | 12 +- .../src/rules/unicorn/no_nested_ternary.rs | 10 +- .../src/rules/unicorn/no_new_array.rs | 2 +- .../src/rules/unicorn/no_new_buffer.rs | 2 +- .../oxc_linter/src/rules/unicorn/no_null.rs | 4 +- .../unicorn/no_object_as_default_parameter.rs | 5 +- .../src/rules/unicorn/no_process_exit.rs | 2 +- .../no_single_promise_in_promise_methods.rs | 8 +- .../src/rules/unicorn/no_static_only_class.rs | 2 +- .../src/rules/unicorn/no_thenable.rs | 6 +- .../src/rules/unicorn/no_this_assignment.rs | 8 +- .../src/rules/unicorn/no_typeof_undefined.rs | 3 +- .../src/rules/unicorn/no_unnecessary_await.rs | 8 +- .../no_unreadable_array_destructuring.rs | 2 +- .../src/rules/unicorn/no_unreadable_iife.rs | 2 +- .../unicorn/no_useless_fallback_in_spread.rs | 2 +- .../rules/unicorn/no_useless_length_check.rs | 4 +- .../no_useless_promise_resolve_reject.rs | 4 +- .../src/rules/unicorn/no_useless_spread.rs | 18 +- .../rules/unicorn/no_useless_switch_case.rs | 8 +- .../src/rules/unicorn/no_useless_undefined.rs | 6 +- .../src/rules/unicorn/no_zero_fractions.rs | 16 +- .../src/rules/unicorn/number_literal_case.rs | 28 +- .../rules/unicorn/numeric_separators_style.rs | 8 +- .../unicorn/prefer_add_event_listener.rs | 3 +- .../src/rules/unicorn/prefer_array_flat.rs | 2 +- .../rules/unicorn/prefer_array_flat_map.rs | 2 +- .../src/rules/unicorn/prefer_array_some.rs | 5 +- .../unicorn/prefer_blob_reading_methods.rs | 3 +- .../src/rules/unicorn/prefer_code_point.rs | 8 +- .../src/rules/unicorn/prefer_date_now.rs | 24 +- .../rules/unicorn/prefer_dom_node_append.rs | 2 +- .../rules/unicorn/prefer_dom_node_dataset.rs | 12 +- .../rules/unicorn/prefer_dom_node_remove.rs | 2 +- .../unicorn/prefer_dom_node_text_content.rs | 2 +- .../src/rules/unicorn/prefer_event_target.rs | 2 +- .../src/rules/unicorn/prefer_includes.rs | 5 +- .../prefer_logical_operator_over_ternary.rs | 2 +- .../src/rules/unicorn/prefer_math_trunc.rs | 6 +- .../rules/unicorn/prefer_modern_dom_apis.rs | 5 +- .../rules/unicorn/prefer_modern_math_apis.rs | 15 +- .../prefer_native_coercion_functions.rs | 5 +- .../src/rules/unicorn/prefer_node_protocol.rs | 2 +- .../rules/unicorn/prefer_number_properties.rs | 2 +- .../unicorn/prefer_optional_catch_binding.rs | 3 +- .../rules/unicorn/prefer_prototype_methods.rs | 7 +- .../rules/unicorn/prefer_query_selector.rs | 2 +- .../src/rules/unicorn/prefer_reflect_apply.rs | 8 +- .../src/rules/unicorn/prefer_regexp_test.rs | 2 +- .../src/rules/unicorn/prefer_set_size.rs | 5 +- .../src/rules/unicorn/prefer_spread.rs | 8 +- .../unicorn/prefer_string_replace_all.rs | 4 +- .../src/rules/unicorn/prefer_string_slice.rs | 5 +- .../unicorn/prefer_string_starts_ends_with.rs | 4 +- .../unicorn/prefer_string_trim_start_end.rs | 8 +- .../src/rules/unicorn/prefer_type_error.rs | 8 +- .../unicorn/require_array_join_separator.rs | 2 +- ...require_number_to_fixed_digits_argument.rs | 2 +- .../src/rules/unicorn/switch_case_braces.rs | 8 +- .../unicorn/text_encoding_identifier_case.rs | 5 +- .../src/rules/unicorn/throw_new_error.rs | 2 +- crates/oxc_linter/src/service.rs | 6 +- .../src/snapshots/bad_bitwise_operator.snap | 10 +- .../consistent_indexed_object_style.snap | 56 +- .../src/snapshots/consistent_test_it.snap | 121 +++-- .../consistent_type_definitions.snap | 85 ++- .../src/snapshots/expect_expect.snap | 59 ++- .../src/snapshots/heading_has_content.snap | 18 +- .../src/snapshots/no_alias_methods.snap | 37 +- .../snapshots/no_confusing_set_timeout.snap | 62 +-- .../src/snapshots/no_disabled_tests.snap | 144 +++--- .../src/snapshots/no_focused_tests.snap | 4 +- .../src/snapshots/no_is_mounted.snap | 6 +- .../src/snapshots/no_test_prefixes.snap | 46 +- .../src/snapshots/no_unsafe_negation.snap | 22 +- .../snapshots/no_useless_length_check.snap | 54 +- ..._es_6_class.snap => prefer_es6_class.snap} | 6 +- .../prefer_exponentiation_operator.snap | 24 +- .../src/snapshots/prefer_hooks_in_order.snap | 89 ++-- .../snapshots/valid_describe_callback.snap | 245 +++++---- .../src/snapshots/valid_expect.snap | 485 +++++++++--------- crates/oxc_linter/src/utils/mod.rs | 41 -- .../oxc_macros/src/declare_all_lint_rules.rs | 2 +- crates/oxc_macros/src/declare_oxc_lint.rs | 9 +- crates/oxc_wasm/src/lib.rs | 5 +- tasks/benchmark/benches/linter.rs | 15 +- 423 files changed, 2015 insertions(+), 2208 deletions(-) create mode 100644 crates/oxc_linter/src/frameworks.rs rename crates/oxc_linter/src/snapshots/{prefer_es_6_class.snap => prefer_es6_class.snap} (88%) diff --git a/crates/oxc_diagnostics/src/lib.rs b/crates/oxc_diagnostics/src/lib.rs index cfe5b6655a8bb4..f4a51c1b13cc76 100644 --- a/crates/oxc_diagnostics/src/lib.rs +++ b/crates/oxc_diagnostics/src/lib.rs @@ -100,6 +100,11 @@ impl Diagnostic for OxcDiagnostic { .map(Box::new) .map(|b| b as Box>) } + + fn code<'a>(&'a self) -> Option> { + // self.code.is_some().then(|| Box::new(&self.code) as Box) + None + } } impl OxcDiagnostic { @@ -138,21 +143,29 @@ impl OxcDiagnostic { #[inline] pub fn with_error_code_scope>>(mut self, code_scope: T) -> Self { - self.inner.code.scope = Some(code_scope.into()); + self.inner.code.scope = match self.inner.code.scope { + Some(scope) => Some(scope), + None => Some(code_scope.into()), + }; debug_assert!( self.inner.code.scope.as_ref().is_some_and(|s| !s.is_empty()), "Error code scopes cannot be empty" ); + self } #[inline] pub fn with_error_code_num>>(mut self, code_num: T) -> Self { - self.inner.code.number = Some(code_num.into()); + self.inner.code.number = match self.inner.code.number { + Some(num) => Some(num), + None => Some(code_num.into()), + }; debug_assert!( self.inner.code.number.as_ref().is_some_and(|n| !n.is_empty()), "Error code numbers cannot be empty" ); + self } diff --git a/crates/oxc_language_server/src/linter.rs b/crates/oxc_language_server/src/linter.rs index be86e2a5d57f76..fcd8dcc8d3a810 100644 --- a/crates/oxc_language_server/src/linter.rs +++ b/crates/oxc_language_server/src/linter.rs @@ -13,7 +13,7 @@ use oxc_linter::{ AstroPartialLoader, JavaScriptSource, SveltePartialLoader, VuePartialLoader, LINT_PARTIAL_LOADER_EXT, }, - FixKind, LintContext, Linter, + FixKind, Linter, }; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; @@ -304,12 +304,7 @@ impl IsolatedLintHandler { return Some(Self::wrap_diagnostics(path, &original_source_text, reports, start)); }; - let lint_ctx = LintContext::new( - path.to_path_buf().into_boxed_path(), - Rc::new(semantic_ret.semantic), - ); - - let result = linter.run(lint_ctx); + let result = linter.run(path, Rc::new(semantic_ret.semantic)); let reports = result .into_iter() diff --git a/crates/oxc_linter/src/context.rs b/crates/oxc_linter/src/context.rs index 8aa469a042b52e..8db8b2436ace25 100644 --- a/crates/oxc_linter/src/context.rs +++ b/crates/oxc_linter/src/context.rs @@ -12,10 +12,11 @@ use crate::{ disable_directives::{DisableDirectives, DisableDirectivesBuilder}, fixer::{FixKind, Message, RuleFix, RuleFixer}, javascript_globals::GLOBALS, - AllowWarnDeny, OxlintConfig, OxlintEnv, OxlintGlobals, OxlintSettings, + AllowWarnDeny, FrameworkFlags, OxlintConfig, OxlintEnv, OxlintGlobals, OxlintSettings, }; #[derive(Clone)] +#[must_use] pub struct LintContext<'a> { semantic: Rc>, @@ -38,6 +39,7 @@ pub struct LintContext<'a> { eslint_config: Arc, // states + current_plugin_prefix: &'static str, current_rule_name: &'static str, /// Current rule severity. Allows for user severity overrides, e.g. @@ -50,6 +52,7 @@ pub struct LintContext<'a> { /// } /// ``` severity: Severity, + frameworks: FrameworkFlags, } impl<'a> LintContext<'a> { @@ -74,36 +77,51 @@ impl<'a> LintContext<'a> { fix: FixKind::None, file_path: file_path.into(), eslint_config: Arc::new(OxlintConfig::default()), + current_plugin_prefix: "eslint", current_rule_name: "", severity: Severity::Warning, + frameworks: FrameworkFlags::empty(), } } /// Enable/disable automatic code fixes. - #[must_use] pub fn with_fix(mut self, fix: FixKind) -> Self { self.fix = fix; self } - #[must_use] pub fn with_eslint_config(mut self, eslint_config: &Arc) -> Self { self.eslint_config = Arc::clone(eslint_config); self } - #[must_use] + pub fn with_plugin_name(mut self, plugin: &'static str) -> Self { + self.current_plugin_prefix = plugin_name_to_prefix(plugin); + self + } + pub fn with_rule_name(mut self, name: &'static str) -> Self { self.current_rule_name = name; self } - #[must_use] pub fn with_severity(mut self, severity: AllowWarnDeny) -> Self { self.severity = Severity::from(severity); self } + /// Set [`FrameworkFlags`], overwriting any existing flags. + pub fn with_frameworks(mut self, frameworks: FrameworkFlags) -> Self { + self.frameworks = frameworks; + self + } + + /// Add additional [`FrameworkFlags`] + pub fn and_frameworks(mut self, frameworks: FrameworkFlags) -> Self { + self.frameworks |= frameworks; + self + } + pub fn semantic(&self) -> &Rc> { &self.semantic } @@ -182,6 +200,8 @@ impl<'a> LintContext<'a> { fn add_diagnostic(&self, message: Message<'a>) { if !self.disable_directives.contains(self.current_rule_name, message.span()) { let mut message = message; + message.error = + message.error.with_error_code(self.current_plugin_prefix, self.current_rule_name); if message.error.severity != self.severity { message.error = message.error.with_severity(self.severity); } @@ -306,6 +326,10 @@ impl<'a> LintContext<'a> { } } + pub fn frameworks(&self) -> FrameworkFlags { + self.frameworks + } + /// AST nodes /// /// Shorthand for `self.semantic().nodes()`. @@ -340,4 +364,34 @@ impl<'a> LintContext<'a> { pub fn jsdoc(&self) -> &JSDocFinder<'a> { self.semantic().jsdoc() } + + // #[inline] + // fn plugin_name_to_prefix(&self, plugin_name: &'static str) -> &'static str { + // let plugin_name = if self. plugin_name == "jest" && self.frameworks.contains(FrameworkFlags::Vitest) { + // "vitest" + // } else { + // plugin_name + // }; + // PLUGIN_PREFIXES.get(plugin_name).copied().unwrap_or(plugin_name) + // } } + +#[inline] +fn plugin_name_to_prefix(plugin_name: &'static str) -> &'static str { + PLUGIN_PREFIXES.get(plugin_name).copied().unwrap_or(plugin_name) +} + +const PLUGIN_PREFIXES: phf::Map<&'static str, &'static str> = phf::phf_map! { + "import" => "eslint-plugin-import", + "jest" => "eslint-plugin-jest", + "jsdoc" => "eslint-plugin-jsdoc", + "jsx_a11y" => "eslint-plugin-jsx-a11y", + "nextjs" => "eslint-plugin-next", + "promise" => "eslint-plugin-promise", + "react_perf" => "eslint-plugin-react-perf", + "react" => "eslint-plugin-react", + "tree_shaking" => "eslint-plugin-tree-shaking", + "typescript" => "typescript-eslint", + "unicorn" => "eslint-plugin-unicorn", + "vitest" => "eslint-plugin-vitest", +}; diff --git a/crates/oxc_linter/src/frameworks.rs b/crates/oxc_linter/src/frameworks.rs new file mode 100644 index 00000000000000..83d73282deb5de --- /dev/null +++ b/crates/oxc_linter/src/frameworks.rs @@ -0,0 +1,85 @@ +use bitflags::bitflags; +use oxc_semantic::ModuleRecord; +use std::{hash, path::Path}; + +bitflags! { + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub struct FrameworkFlags: u32 { + // front-end frameworks + + /// Uses [React](https://reactjs.org/). + /// + /// May be part of a meta-framework like Next.js. + const React = 1 << 0; + /// Uses [Preact](https://preactjs.com/). + const Preact = 1 << 1; + /// Uses [Next.js](https://nextjs.org/). + const NextOnly = 1 << 2; + const Next = Self::NextOnly.bits() | Self::React.bits(); + const JsxLike = Self::React.bits() | Self::Preact.bits() | Self::Next.bits(); + + const Vue = 1 << 3; + const NuxtOnly = 1 << 4; + const Nuxt = Self::NuxtOnly.bits() | Self::Vue.bits(); + + const Angular = 1 << 5; + + const Svelte = 1 << 6; + const SvelteKitOnly = 1 << 7; + const SvelteKit = Self::SvelteKitOnly.bits() | Self::Svelte.bits(); + + const Astro = 1 << 8; + + // Testing frameworks + const Jest = 1 << 9; + const Vitest = 1 << 10; + const OtherTest = 1 << 11; + const Test = Self::Jest.bits() | Self::Vitest.bits() | Self::OtherTest.bits(); + } +} + +impl Default for FrameworkFlags { + #[inline] + fn default() -> Self { + Self::empty() + } +} +impl hash::Hash for FrameworkFlags { + #[inline] + fn hash(&self, state: &mut H) { + state.write_u32(self.bits()); + } +} + +impl FrameworkFlags { + #[inline] + pub const fn is_test(self) -> bool { + self.intersects(Self::Test) + } + + #[inline] + pub const fn is_vitest(self) -> bool { + self.contains(Self::Vitest) + } +} + +/// +pub(crate) fn is_jestlike_file(path: &Path) -> bool { + use std::ffi::OsStr; + + if path.components().any(|c| match c { + std::path::Component::Normal(p) => p == OsStr::new("__tests__"), + _ => false, + }) { + return true; + } + + path.file_name() // foo/bar/baz.test.ts -> baz.test.ts + .and_then(OsStr::to_str) + .and_then(|filename| filename.split('.').rev().nth(1)) // baz.test.ts -> test + .is_some_and(|name_or_first_ext| name_or_first_ext == "test" || name_or_first_ext == "spec") +} + +pub(crate) fn has_vitest_imports(module_record: &ModuleRecord) -> bool { + module_record.import_entries.iter().any(|entry| entry.module_request.name() == "vitest") +} diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 372d799ced51b4..61a46acad07d9c 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -8,6 +8,7 @@ mod config; mod context; mod disable_directives; mod fixer; +mod frameworks; mod globals; mod javascript_globals; mod options; @@ -19,15 +20,16 @@ mod utils; pub mod partial_loader; pub mod table; -use std::{io::Write, rc::Rc, sync::Arc}; +use std::{io::Write, path::Path, rc::Rc, sync::Arc}; use oxc_diagnostics::Error; -use oxc_semantic::AstNode; +use oxc_semantic::{AstNode, Semantic}; pub use crate::{ config::OxlintConfig, context::LintContext, fixer::FixKind, + frameworks::FrameworkFlags, options::{AllowWarnDeny, LintOptions}, rule::{RuleCategory, RuleMeta, RuleWithSeverity}, service::{LintService, LintServiceOptions}, @@ -109,7 +111,9 @@ impl Linter { self.rules.len() } - pub fn run<'a>(&self, ctx: LintContext<'a>) -> Vec> { + // pub fn run<'a>(&self, ctx: LintContext<'a>) -> Vec> { + pub fn run<'a>(&self, path: &Path, semantic: Rc>) -> Vec> { + let ctx = self.create_ctx(path, semantic); let semantic = Rc::clone(ctx.semantic()); let ctx = ctx.with_fix(self.options.fix).with_eslint_config(&self.eslint_config); @@ -117,7 +121,16 @@ impl Linter { .rules .iter() .map(|rule| { - (rule, ctx.clone().with_rule_name(rule.name()).with_severity(rule.severity)) + let rule_name = rule.name(); + let plugin_name = self.map_jest(rule.plugin_name(), rule_name); + + ( + rule, + ctx.clone() + .with_plugin_name(plugin_name) + .with_rule_name(rule_name) + .with_severity(rule.severity), + ) }) .collect::>(); @@ -149,6 +162,40 @@ impl Linter { writeln!(writer, "Default: {}", table.turned_on_by_default_count).unwrap(); writeln!(writer, "Total: {}", table.total).unwrap(); } + + fn create_ctx<'a>(&self, path: &Path, semantic: Rc>) -> LintContext<'a> { + let mut ctx = LintContext::new(path.to_path_buf().into_boxed_path(), semantic) + .with_fix(self.options.fix) + .with_eslint_config(&self.eslint_config) + .with_frameworks(self.options.framework_hints); + + // set file-specific jest/vitest flags + if self.options.jest_plugin || self.options.vitest_plugin { + let mut test_flags = FrameworkFlags::empty(); + + if frameworks::is_jestlike_file(path) { + test_flags.set(FrameworkFlags::Jest, self.options.jest_plugin); + test_flags.set(FrameworkFlags::Vitest, self.options.vitest_plugin); + } else if frameworks::has_vitest_imports(ctx.module_record()) { + test_flags.set(FrameworkFlags::Vitest, true); + } + + ctx = ctx.and_frameworks(test_flags); + } + + ctx + } + + fn map_jest(&self, plugin_name: &'static str, rule_name: &str) -> &'static str { + if self.options.vitest_plugin + && plugin_name == "jest" + && utils::is_jest_rule_adapted_to_vitest(rule_name) + { + "vitest" + } else { + plugin_name + } + } } #[cfg(test)] diff --git a/crates/oxc_linter/src/options.rs b/crates/oxc_linter/src/options.rs index d30d917ea088ca..4954c239a65d90 100644 --- a/crates/oxc_linter/src/options.rs +++ b/crates/oxc_linter/src/options.rs @@ -7,7 +7,7 @@ use serde_json::{Number, Value}; use crate::{ config::OxlintConfig, fixer::FixKind, rules::RULES, utils::is_jest_rule_adapted_to_vitest, - RuleCategory, RuleEnum, RuleWithSeverity, + FrameworkFlags, RuleCategory, RuleEnum, RuleWithSeverity, }; #[derive(Debug)] @@ -33,6 +33,8 @@ pub struct LintOptions { pub nextjs_plugin: bool, pub react_perf_plugin: bool, pub promise_plugin: bool, + + pub framework_hints: FrameworkFlags, } impl Default for LintOptions { @@ -53,6 +55,8 @@ impl Default for LintOptions { nextjs_plugin: false, react_perf_plugin: false, promise_plugin: false, + + framework_hints: FrameworkFlags::default(), } } } diff --git a/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs b/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs index 32c8720c4cd6aa..fe5206796e690e 100644 --- a/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs +++ b/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs @@ -18,19 +18,15 @@ use crate::{ }; fn expect_return(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(array-callback-return): Missing return on some path for array method {x0:?}" - )) - .with_help(format!("Array method {x0:?} needs to have valid return on all code paths")) - .with_label(span1) + OxcDiagnostic::warn(format!("Missing return on some path for array method {x0:?}")) + .with_help(format!("Array method {x0:?} needs to have valid return on all code paths")) + .with_label(span1) } fn expect_no_return(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(array-callback-return): Unexpected return for array method {x0:?}" - )) - .with_help(format!("Array method {x0:?} expects no useless return from the function")) - .with_label(span1) + OxcDiagnostic::warn(format!("Unexpected return for array method {x0:?}")) + .with_help(format!("Array method {x0:?} expects no useless return from the function")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/constructor_super.rs b/crates/oxc_linter/src/rules/eslint/constructor_super.rs index 23f5a55eabdce2..339f27d4e9f9f6 100644 --- a/crates/oxc_linter/src/rules/eslint/constructor_super.rs +++ b/crates/oxc_linter/src/rules/eslint/constructor_super.rs @@ -4,12 +4,12 @@ use oxc_macros::declare_oxc_lint; use crate::{context::LintContext, rule::Rule, AstNode}; // #[derive(Debug, Error, Diagnostic)] -// #[error("eslint(constructor-super): Expected to call 'super()'.")] +// #[error("Expected to call 'super()'.")] // #[diagnostic(severity(warning), help("Ensure 'super()' is called from constructor"))] // struct ConstructorSuperDiagnostic(#[label] pub Span); // #[derive(Debug, Error, Diagnostic)] -// #[error("eslint(constructor-super): Unexpected 'super()' because 'super' is not a constructor.")] +// #[error("Unexpected 'super()' because 'super' is not a constructor.")] // #[diagnostic(severity(warning), help("Do not call 'super()' from constructor."))] // struct SuperNotConstructorDiagnostic( // #[label("unexpected 'super()'")] pub Span, diff --git a/crates/oxc_linter/src/rules/eslint/default_case.rs b/crates/oxc_linter/src/rules/eslint/default_case.rs index 32f1d15a7a257c..aef39fe4113a74 100644 --- a/crates/oxc_linter/src/rules/eslint/default_case.rs +++ b/crates/oxc_linter/src/rules/eslint/default_case.rs @@ -7,7 +7,7 @@ use regex::{Regex, RegexBuilder}; use crate::{context::LintContext, rule::Rule, AstNode}; fn default_case_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(default-case): Require default cases in switch statements.") + OxcDiagnostic::warn("Require default cases in switch statements.") .with_help("Add a default case.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/default_case_last.rs b/crates/oxc_linter/src/rules/eslint/default_case_last.rs index 381f5755331da4..763717e84c4333 100644 --- a/crates/oxc_linter/src/rules/eslint/default_case_last.rs +++ b/crates/oxc_linter/src/rules/eslint/default_case_last.rs @@ -6,10 +6,8 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn default_case_last_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(default-case-last): Enforce default clauses in switch statements to be last", - ) - .with_label(span0.label("Default clause should be the last clause.")) + OxcDiagnostic::warn("Enforce default clauses in switch statements to be last") + .with_label(span0.label("Default clause should be the last clause.")) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/default_param_last.rs b/crates/oxc_linter/src/rules/eslint/default_param_last.rs index c1d32537027fac..c028121e0e732a 100644 --- a/crates/oxc_linter/src/rules/eslint/default_param_last.rs +++ b/crates/oxc_linter/src/rules/eslint/default_param_last.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn default_param_last_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(default-param-last): Default parameters should be last") + OxcDiagnostic::warn("Default parameters should be last") .with_help("Enforce default parameters to be last.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/eqeqeq.rs b/crates/oxc_linter/src/rules/eslint/eqeqeq.rs index a3ca06acbe34b2..0d18f279bbaef8 100644 --- a/crates/oxc_linter/src/rules/eslint/eqeqeq.rs +++ b/crates/oxc_linter/src/rules/eslint/eqeqeq.rs @@ -10,7 +10,7 @@ use oxc_syntax::operator::{BinaryOperator, UnaryOperator}; use crate::{context::LintContext, rule::Rule, AstNode}; fn eqeqeq_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(eqeqeq): Expected {x1} and instead saw {x0}")) + OxcDiagnostic::warn(format!("Expected {x1} and instead saw {x0}")) .with_help(format!("Prefer {x1} operator")) .with_label(span2) } diff --git a/crates/oxc_linter/src/rules/eslint/for_direction.rs b/crates/oxc_linter/src/rules/eslint/for_direction.rs index 2ae16af5c3150d..7ee4f3fdafcbb4 100644 --- a/crates/oxc_linter/src/rules/eslint/for_direction.rs +++ b/crates/oxc_linter/src/rules/eslint/for_direction.rs @@ -13,7 +13,7 @@ use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, UnaryOperator, Up use crate::{context::LintContext, rule::Rule, AstNode}; fn for_direction_diagnostic(span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(for-direction): The update clause in this loop moves the variable in the wrong direction") + OxcDiagnostic::warn("The update clause in this loop moves the variable in the wrong direction") .with_help("Use while loop for intended infinite loop") .with_labels([ span0.label("This test moves in the wrong direction"), diff --git a/crates/oxc_linter/src/rules/eslint/getter_return.rs b/crates/oxc_linter/src/rules/eslint/getter_return.rs index 8ee0f581cfead0..9c3f864f67f032 100644 --- a/crates/oxc_linter/src/rules/eslint/getter_return.rs +++ b/crates/oxc_linter/src/rules/eslint/getter_return.rs @@ -19,7 +19,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn getter_return_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(getter-return): Expected to always return a value in getter.") + OxcDiagnostic::warn("Expected to always return a value in getter.") .with_help("Return a value from all code paths in getter.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/guard_for_in.rs b/crates/oxc_linter/src/rules/eslint/guard_for_in.rs index 12604a5f2feed9..71d33322ee07e7 100644 --- a/crates/oxc_linter/src/rules/eslint/guard_for_in.rs +++ b/crates/oxc_linter/src/rules/eslint/guard_for_in.rs @@ -6,7 +6,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn guard_for_in_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(guard-for-in): Require `for-in` loops to include an `if` statement") + OxcDiagnostic::warn("Require `for-in` loops to include an `if` statement") .with_help("The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/max_classes_per_file.rs b/crates/oxc_linter/src/rules/eslint/max_classes_per_file.rs index 761bf7a8bc26b9..662082a734b90c 100644 --- a/crates/oxc_linter/src/rules/eslint/max_classes_per_file.rs +++ b/crates/oxc_linter/src/rules/eslint/max_classes_per_file.rs @@ -8,11 +8,9 @@ use serde_json::Value; use crate::{context::LintContext, rule::Rule}; fn max_classes_per_file_diagnostic(total: usize, max: usize, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(max-classes-per-file): File has too many classes ({total}). Maximum allowed is {max}", - )) - .with_help("Reduce the number of classes in this file") - .with_label(span1) + OxcDiagnostic::warn(format!("File has too many classes ({total}). Maximum allowed is {max}",)) + .with_help("Reduce the number of classes in this file") + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/max_lines.rs b/crates/oxc_linter/src/rules/eslint/max_lines.rs index 28363beb633c04..3159d077ed00c5 100644 --- a/crates/oxc_linter/src/rules/eslint/max_lines.rs +++ b/crates/oxc_linter/src/rules/eslint/max_lines.rs @@ -6,7 +6,7 @@ use serde_json::Value; use crate::{context::LintContext, rule::Rule}; fn max_lines_diagnostic(count: usize, max: usize, span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(max-lines): File has too many lines ({count}).")) + OxcDiagnostic::warn(format!("File has too many lines ({count}).")) .with_help(format!("Maximum allowed is {max}.")) .with_label(span) } diff --git a/crates/oxc_linter/src/rules/eslint/max_params.rs b/crates/oxc_linter/src/rules/eslint/max_params.rs index 8b2441db54c796..afc3acda8aa4f2 100644 --- a/crates/oxc_linter/src/rules/eslint/max_params.rs +++ b/crates/oxc_linter/src/rules/eslint/max_params.rs @@ -7,7 +7,7 @@ use serde_json::Value; use crate::{context::LintContext, rule::Rule, AstNode}; fn max_params_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(max-params): {x0:?}")) + OxcDiagnostic::warn(format!("{x0:?}")) .with_help( "This rule enforces a maximum number of parameters allowed in function definitions.", ) diff --git a/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs index c30790e3f3f801..e0e1273286896b 100644 --- a/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_array_constructor_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-array-constructor): Disallow `Array` constructors") + OxcDiagnostic::warn("Disallow `Array` constructors") .with_help("Use array literal instead") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_async_promise_executor.rs b/crates/oxc_linter/src/rules/eslint/no_async_promise_executor.rs index 42979fd0c94052..30a3dec0cd3539 100644 --- a/crates/oxc_linter/src/rules/eslint/no_async_promise_executor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_async_promise_executor.rs @@ -9,10 +9,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_async_promise_executor_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-async-promise-executor): Promise executor functions should not be `async`.", - ) - .with_label(span0) + OxcDiagnostic::warn("Promise executor functions should not be `async`.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs b/crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs index 9658dbd4825a97..e2622c5c0195b9 100644 --- a/crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs +++ b/crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs @@ -9,8 +9,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_await_in_loop_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-await-in-loop): Unexpected `await` inside a loop.") - .with_label(span0) + OxcDiagnostic::warn("Unexpected `await` inside a loop.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_bitwise.rs b/crates/oxc_linter/src/rules/eslint/no_bitwise.rs index bd78c09d88fcf4..d92a5a5742d408 100644 --- a/crates/oxc_linter/src/rules/eslint/no_bitwise.rs +++ b/crates/oxc_linter/src/rules/eslint/no_bitwise.rs @@ -7,7 +7,7 @@ use oxc_syntax::operator::BinaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_bitwise_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-bitwise): Unexpected use of {x0:?}")) + OxcDiagnostic::warn(format!("Unexpected use of {x0:?}")) .with_help("bitwise operators are not allowed, maybe you mistyped `&&` or `||`") .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_caller.rs b/crates/oxc_linter/src/rules/eslint/no_caller.rs index 35869353d16ffc..e96265946d93c2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_caller.rs +++ b/crates/oxc_linter/src/rules/eslint/no_caller.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_caller_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-caller): Disallow the use of arguments.caller or arguments.callee") + OxcDiagnostic::warn("Disallow the use of arguments.caller or arguments.callee") .with_help("'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_case_declarations.rs b/crates/oxc_linter/src/rules/eslint/no_case_declarations.rs index 83081928ef713d..d654c7f24f8e7b 100644 --- a/crates/oxc_linter/src/rules/eslint/no_case_declarations.rs +++ b/crates/oxc_linter/src/rules/eslint/no_case_declarations.rs @@ -9,10 +9,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_case_declarations_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-case-declarations): Unexpected lexical declaration in case block.", - ) - .with_label(span0) + OxcDiagnostic::warn("Unexpected lexical declaration in case block.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_class_assign.rs b/crates/oxc_linter/src/rules/eslint/no_class_assign.rs index 5fac2638438268..dc1be943d1e791 100644 --- a/crates/oxc_linter/src/rules/eslint/no_class_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_class_assign.rs @@ -6,11 +6,10 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_class_assign_diagnostic(x0: &str, span1: Span, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-class-assign): Unexpected re-assignment of class {x0}")) - .with_labels([ - span1.label(format!("{x0} is declared as class here")), - span2.label(format!("{x0} is re-assigned here")), - ]) + OxcDiagnostic::warn(format!("Unexpected re-assignment of class {x0}")).with_labels([ + span1.label(format!("{x0} is declared as class here")), + span2.label(format!("{x0} is re-assigned here")), + ]) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_compare_neg_zero.rs b/crates/oxc_linter/src/rules/eslint/no_compare_neg_zero.rs index 1fb97f3d51d655..2c99118a27ae22 100644 --- a/crates/oxc_linter/src/rules/eslint/no_compare_neg_zero.rs +++ b/crates/oxc_linter/src/rules/eslint/no_compare_neg_zero.rs @@ -7,11 +7,9 @@ use oxc_syntax::operator::{BinaryOperator, UnaryOperator}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_compare_neg_zero_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-compare-neg-zero): Do not use the {x0} operator to compare against -0." - )) - .with_help("Use Object.is(x, -0) to test equality with -0 and use 0 for other cases") - .with_label(span1) + OxcDiagnostic::warn(format!("Do not use the {x0} operator to compare against -0.")) + .with_help("Use Object.is(x, -0) to test equality with -0 and use 0 for other cases") + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs b/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs index 6af28034746312..17c726fb3c55a4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs @@ -9,11 +9,9 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_cond_assign_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-cond-assign): Expected a conditional expression and instead saw an assignment", - ) - .with_help("Consider wrapping the assignment in additional parentheses") - .with_label(span0) + OxcDiagnostic::warn("Expected a conditional expression and instead saw an assignment") + .with_help("Consider wrapping the assignment in additional parentheses") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_console.rs b/crates/oxc_linter/src/rules/eslint/no_console.rs index 54b63c785f11b6..c42b64d3eea3fa 100644 --- a/crates/oxc_linter/src/rules/eslint/no_console.rs +++ b/crates/oxc_linter/src/rules/eslint/no_console.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_console_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-console): Unexpected console statement.").with_label(span0) + OxcDiagnostic::warn("Unexpected console statement.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_const_assign.rs b/crates/oxc_linter/src/rules/eslint/no_const_assign.rs index e5ba9949a56e58..998b8168605e93 100644 --- a/crates/oxc_linter/src/rules/eslint/no_const_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_const_assign.rs @@ -6,10 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_const_assign_diagnostic(x0: &str, span1: Span, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-const-assign): Unexpected re-assignment of const variable {x0}" - )) - .with_labels([ + OxcDiagnostic::warn(format!("Unexpected re-assignment of const variable {x0}")).with_labels([ span1.label(format!("{x0} is declared here as const")), span2.label(format!("{x0} is re-assigned here")), ]) diff --git a/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs b/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs index 12433072c7147f..3fde9dd6173ae8 100644 --- a/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs +++ b/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs @@ -49,29 +49,29 @@ declare_oxc_lint!( ); fn constant_short_circuit(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-constant-binary-expression): Unexpected constant {x0:?} on the left-hand side of a {x1:?} expression")) - .with_help("This expression always evaluates to the constant on the left-hand side") - .with_label(span2) + OxcDiagnostic::warn(format!( + "Unexpected constant {x0:?} on the left-hand side of a {x1:?} expression" + )) + .with_help("This expression always evaluates to the constant on the left-hand side") + .with_label(span2) } fn constant_binary_operand(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-constant-binary-expression): Unexpected constant binary expression", - ) - .with_help(format!("This compares constantly with the {x0}-hand side of the {x1}")) - .with_label(span2) + OxcDiagnostic::warn("Unexpected constant binary expression") + .with_help(format!("This compares constantly with the {x0}-hand side of the {x1}")) + .with_label(span2) } fn constant_always_new(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-constant-binary-expression): Unexpected comparison to newly constructed object", - ) - .with_help("These two values can never be equal") - .with_label(span0) + OxcDiagnostic::warn("Unexpected comparison to newly constructed object") + .with_help("These two values can never be equal") + .with_label(span0) } fn constant_both_always_new(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-constant-binary-expression): Unexpected comparison of two newly constructed objects").with_help("These two values can never be equal").with_label(span0) + OxcDiagnostic::warn("Unexpected comparison of two newly constructed objects") + .with_help("These two values can never be equal") + .with_label(span0) } impl Rule for NoConstantBinaryExpression { diff --git a/crates/oxc_linter/src/rules/eslint/no_constant_condition.rs b/crates/oxc_linter/src/rules/eslint/no_constant_condition.rs index 63d23636ae6dc9..2c16127c516763 100644 --- a/crates/oxc_linter/src/rules/eslint/no_constant_condition.rs +++ b/crates/oxc_linter/src/rules/eslint/no_constant_condition.rs @@ -6,7 +6,7 @@ use oxc_span::{GetSpan, Span}; use crate::{ast_util::IsConstant, context::LintContext, rule::Rule, AstNode}; fn no_constant_condition_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-constant-condition): Unexpected constant condition") + OxcDiagnostic::warn("Unexpected constant condition") .with_help("Constant expression as a test condition is not allowed") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs b/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs index b72c038159cb04..6c745b1970b2a7 100644 --- a/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs +++ b/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs @@ -10,10 +10,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_constructor_return_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-constructor-return): Unexpected return statement in constructor.", - ) - .with_label(span) + OxcDiagnostic::warn("Unexpected return statement in constructor.").with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_continue.rs b/crates/oxc_linter/src/rules/eslint/no_continue.rs index 8af14971e64ebf..dcca60785e98d3 100644 --- a/crates/oxc_linter/src/rules/eslint/no_continue.rs +++ b/crates/oxc_linter/src/rules/eslint/no_continue.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_continue_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-continue): Unexpected use of `continue` statement.") + OxcDiagnostic::warn("Unexpected use of `continue` statement.") .with_help("Do not use the `continue` statement.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_control_regex.rs b/crates/oxc_linter/src/rules/eslint/no_control_regex.rs index afdde2816ceb96..56c290c33bee5a 100644 --- a/crates/oxc_linter/src/rules/eslint/no_control_regex.rs +++ b/crates/oxc_linter/src/rules/eslint/no_control_regex.rs @@ -11,7 +11,7 @@ use regex::{Matches, Regex}; use crate::{ast_util::extract_regex_flags, context::LintContext, rule::Rule, AstNode}; fn no_control_regex_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-control-regex): Unexpected control character(s)") + OxcDiagnostic::warn("Unexpected control character(s)") .with_help(format!("Unexpected control character(s) in regular expression: \"{x0}\"")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_debugger.rs b/crates/oxc_linter/src/rules/eslint/no_debugger.rs index a0c19195b6332c..7a2fa7146b27c8 100644 --- a/crates/oxc_linter/src/rules/eslint/no_debugger.rs +++ b/crates/oxc_linter/src/rules/eslint/no_debugger.rs @@ -6,8 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_debugger_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-debugger): `debugger` statement is not allowed") - .with_label(span0) + OxcDiagnostic::warn("`debugger` statement is not allowed").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_delete_var.rs b/crates/oxc_linter/src/rules/eslint/no_delete_var.rs index 220c3a29bd81eb..94799cf50f57f9 100644 --- a/crates/oxc_linter/src/rules/eslint/no_delete_var.rs +++ b/crates/oxc_linter/src/rules/eslint/no_delete_var.rs @@ -7,7 +7,7 @@ use oxc_syntax::operator::UnaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_delete_var_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-delete-var): variables should not be deleted").with_label(span0) + OxcDiagnostic::warn("variables should not be deleted").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_div_regex.rs b/crates/oxc_linter/src/rules/eslint/no_div_regex.rs index eaa54763d01cb7..c71e1aabd1c32f 100644 --- a/crates/oxc_linter/src/rules/eslint/no_div_regex.rs +++ b/crates/oxc_linter/src/rules/eslint/no_div_regex.rs @@ -6,11 +6,9 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_div_regex_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-div-regex): A regular expression literal can be confused with '/='.", - ) - .with_help("Rewrite `/=` into `/[=]`") - .with_label(span0) + OxcDiagnostic::warn("A regular expression literal can be confused with '/='.") + .with_help("Rewrite `/=` into `/[=]`") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_dupe_class_members.rs b/crates/oxc_linter/src/rules/eslint/no_dupe_class_members.rs index 356ba48370a93a..671f6df343b305 100644 --- a/crates/oxc_linter/src/rules/eslint/no_dupe_class_members.rs +++ b/crates/oxc_linter/src/rules/eslint/no_dupe_class_members.rs @@ -10,7 +10,7 @@ fn no_dupe_class_members_diagnostic( span1: Span, span2: Span, ) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-dupe-class-members): Duplicate class member: {x0:?}")) + OxcDiagnostic::warn(format!("Duplicate class member: {x0:?}")) .with_help("The last declaration overwrites previous ones, remove one of them or rename if both should be retained") .with_labels([ span1.label(format!("{x0:?} is previously declared here")), diff --git a/crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs b/crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs index e90e8d35ae26bf..57f804bdfed8e0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs +++ b/crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs @@ -10,7 +10,7 @@ use oxc_syntax::operator::LogicalOperator; use crate::{ast_util::calculate_hash, context::LintContext, rule::Rule, AstNode}; fn no_dupe_else_if_diagnostic(span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-dupe-else-if): duplicate conditions in if-else-if chains") + OxcDiagnostic::warn("duplicate conditions in if-else-if chains") .with_help("This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain") .with_labels([span0, span1]) } diff --git a/crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs b/crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs index 972249550d4875..134e87f10b8eb3 100644 --- a/crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs +++ b/crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs @@ -10,7 +10,7 @@ use rustc_hash::{FxBuildHasher, FxHashMap}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_dupe_keys_diagnostic(span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-dupe-keys): Disallow duplicate keys in object literals") + OxcDiagnostic::warn("Disallow duplicate keys in object literals") .with_help("Consider removing the duplicated key") .with_labels([span0, span1]) } diff --git a/crates/oxc_linter/src/rules/eslint/no_duplicate_case.rs b/crates/oxc_linter/src/rules/eslint/no_duplicate_case.rs index 0bb9d094149598..3e3d6a5579cfc5 100644 --- a/crates/oxc_linter/src/rules/eslint/no_duplicate_case.rs +++ b/crates/oxc_linter/src/rules/eslint/no_duplicate_case.rs @@ -7,7 +7,7 @@ use rustc_hash::FxHashMap; use crate::{ast_util::calculate_hash, context::LintContext, rule::Rule, AstNode}; fn no_duplicate_case_diagnostic(span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-duplicate-case): Disallow duplicate case labels") + OxcDiagnostic::warn("Disallow duplicate case labels") .with_help("Remove the duplicated case") .with_labels([span0, span1]) } diff --git a/crates/oxc_linter/src/rules/eslint/no_empty.rs b/crates/oxc_linter/src/rules/eslint/no_empty.rs index 472942365440c2..4dba955b8487cb 100644 --- a/crates/oxc_linter/src/rules/eslint/no_empty.rs +++ b/crates/oxc_linter/src/rules/eslint/no_empty.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-empty): Disallow empty block statements") + OxcDiagnostic::warn("Disallow empty block statements") .with_help(format!("Add comment inside empty {x0} statement")) .with_label(span1.label(format!("Empty {x0} statement"))) } diff --git a/crates/oxc_linter/src/rules/eslint/no_empty_character_class.rs b/crates/oxc_linter/src/rules/eslint/no_empty_character_class.rs index b8fa160536fe7e..a2970e63dde990 100644 --- a/crates/oxc_linter/src/rules/eslint/no_empty_character_class.rs +++ b/crates/oxc_linter/src/rules/eslint/no_empty_character_class.rs @@ -9,7 +9,7 @@ use regex::Regex; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_character_class_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-empty-character-class): Empty character class") + OxcDiagnostic::warn("Empty character class") .with_help("Try to remove empty character class `[]` in regexp literal") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_empty_function.rs b/crates/oxc_linter/src/rules/eslint/no_empty_function.rs index 6382a8f9b14da9..64635b3379ab91 100644 --- a/crates/oxc_linter/src/rules/eslint/no_empty_function.rs +++ b/crates/oxc_linter/src/rules/eslint/no_empty_function.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_function_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-empty-function): Disallow empty functions") + OxcDiagnostic::warn("Disallow empty functions") .with_help("Unexpected empty function block") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_empty_pattern.rs b/crates/oxc_linter/src/rules/eslint/no_empty_pattern.rs index b4e46df4cbb6e7..1edddc6176cdaf 100644 --- a/crates/oxc_linter/src/rules/eslint/no_empty_pattern.rs +++ b/crates/oxc_linter/src/rules/eslint/no_empty_pattern.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_pattern_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-empty-pattern): Disallow empty destructuring patterns.") + OxcDiagnostic::warn("Disallow empty destructuring patterns.") .with_help("Passing `null` or `undefined` will result in runtime error because `null` and `undefined` cannot be destructured.") .with_label( span1.label(format!("Empty {x0} binding pattern")), diff --git a/crates/oxc_linter/src/rules/eslint/no_empty_static_block.rs b/crates/oxc_linter/src/rules/eslint/no_empty_static_block.rs index 22e5b71a7a3ce4..282a48827d940b 100644 --- a/crates/oxc_linter/src/rules/eslint/no_empty_static_block.rs +++ b/crates/oxc_linter/src/rules/eslint/no_empty_static_block.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_static_block_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-empty-static-block): Disallow empty static blocks") + OxcDiagnostic::warn("Disallow empty static blocks") .with_help("Unexpected empty static block.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_eq_null.rs b/crates/oxc_linter/src/rules/eslint/no_eq_null.rs index d59fd74300ed32..30ed9fb71ac212 100644 --- a/crates/oxc_linter/src/rules/eslint/no_eq_null.rs +++ b/crates/oxc_linter/src/rules/eslint/no_eq_null.rs @@ -9,7 +9,7 @@ use oxc_syntax::operator::BinaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_eq_null_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-eq-null): Use '===' to compare with null") + OxcDiagnostic::warn("Use '===' to compare with null") .with_help("Disallow `null` comparisons without type-checking operators.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_eval.rs b/crates/oxc_linter/src/rules/eslint/no_eval.rs index f092a39d0b492c..59ab1c7cf8ce25 100644 --- a/crates/oxc_linter/src/rules/eslint/no_eval.rs +++ b/crates/oxc_linter/src/rules/eslint/no_eval.rs @@ -8,7 +8,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_eval_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-eval): eval can be harmful.").with_label(span0) + OxcDiagnostic::warn("eval can be harmful.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs b/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs index 54d8f618bc819b..3bf015414ac4d0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_ex_assign_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-ex-assign): Do not assign to the exception parameter.").with_help("If a catch clause in a try statement accidentally (or purposely) assigns another value to the exception parameter, it is impossible to refer to the error from that point on. Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive.").with_label(span0) + OxcDiagnostic::warn("Do not assign to the exception parameter.").with_help("If a catch clause in a try statement accidentally (or purposely) assigns another value to the exception parameter, it is impossible to refer to the error from that point on. Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs b/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs index d19f0ee47ff34d..8e1383da944d0a 100644 --- a/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs +++ b/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs @@ -8,13 +8,13 @@ use oxc_syntax::operator::{LogicalOperator, UnaryOperator}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_extra_double_negation_cast_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-extra-boolean-cast): Redundant double negation") + OxcDiagnostic::warn("Redundant double negation") .with_help("Remove the double negation as it will already be coerced to a boolean") .with_label(span0) } fn no_extra_boolean_cast_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-extra-boolean-cast): Redundant Boolean call") + OxcDiagnostic::warn("Redundant Boolean call") .with_help("Remove the Boolean call as it will already be coerced to a boolean") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs b/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs index fa6c8225032c7c..19f968b247f3a9 100644 --- a/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs +++ b/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs @@ -21,18 +21,18 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_fallthrough_case_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::error("eslint(no-fallthrough): Expected a 'break' statement before 'case'.") - .with_label(span) + OxcDiagnostic::error("Expected a 'break' statement before 'case'.").with_label(span) } fn no_fallthrough_default_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::error("eslint(no-fallthrough): Expected a 'break' statement before 'default'.") - .with_label(span) + OxcDiagnostic::error("Expected a 'break' statement before 'default'.").with_label(span) } fn no_unused_fallthrough_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::error("eslint(no-fallthrough): Found a comment that would permit fallthrough, but case cannot fall through.") - .with_label(span) + OxcDiagnostic::error( + "Found a comment that would permit fallthrough, but case cannot fall through.", + ) + .with_label(span) } const DEFAULT_FALLTHROUGH_COMMENT_PATTERN: &str = r"falls?\s?through"; diff --git a/crates/oxc_linter/src/rules/eslint/no_func_assign.rs b/crates/oxc_linter/src/rules/eslint/no_func_assign.rs index 4bb1f98ec0e493..603e14ee723199 100644 --- a/crates/oxc_linter/src/rules/eslint/no_func_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_func_assign.rs @@ -7,7 +7,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_func_assign_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-func-assign): '{x0}' is a function.")) + OxcDiagnostic::warn(format!("'{x0}' is a function.")) .with_label(span1.label(format!("{x0} is re-assigned here"))) } diff --git a/crates/oxc_linter/src/rules/eslint/no_global_assign.rs b/crates/oxc_linter/src/rules/eslint/no_global_assign.rs index 6d502f324d0f29..8f9f1ccdbcb638 100644 --- a/crates/oxc_linter/src/rules/eslint/no_global_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_global_assign.rs @@ -5,10 +5,8 @@ use oxc_span::{CompactStr, Span}; use crate::{context::LintContext, rule::Rule}; fn no_global_assign_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-global-assign): Read-only global '{x0}' should not be modified." - )) - .with_label(span1.label(format!("Read-only global '{x0}' should not be modified."))) + OxcDiagnostic::warn(format!("Read-only global '{x0}' should not be modified.")) + .with_label(span1.label(format!("Read-only global '{x0}' should not be modified."))) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_import_assign.rs b/crates/oxc_linter/src/rules/eslint/no_import_assign.rs index 7d10ec08beb0b4..41cd693c36eff2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_import_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_import_assign.rs @@ -9,7 +9,7 @@ use phf::phf_set; use crate::{context::LintContext, rule::Rule}; fn no_import_assign_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-import-assign): do not assign to imported bindings") + OxcDiagnostic::warn("do not assign to imported bindings") .with_help("imported bindings are readonly") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_inner_declarations.rs b/crates/oxc_linter/src/rules/eslint/no_inner_declarations.rs index e7d08ca1ac7aaf..f9d8bd058d67d2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_inner_declarations.rs +++ b/crates/oxc_linter/src/rules/eslint/no_inner_declarations.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_inner_declarations_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-inner-declarations): Variable or `function` declarations are not allowed in nested blocks") + OxcDiagnostic::warn("Variable or `function` declarations are not allowed in nested blocks") .with_help(format!("Move {x0} declaration to {x1} root")) .with_label(span2) } diff --git a/crates/oxc_linter/src/rules/eslint/no_irregular_whitespace.rs b/crates/oxc_linter/src/rules/eslint/no_irregular_whitespace.rs index c164cbbf0dd98b..dd6a433153d29c 100644 --- a/crates/oxc_linter/src/rules/eslint/no_irregular_whitespace.rs +++ b/crates/oxc_linter/src/rules/eslint/no_irregular_whitespace.rs @@ -5,7 +5,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_irregular_whitespace_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-irregular-whitespace): Unexpected irregular whitespace") + OxcDiagnostic::warn("Unexpected irregular whitespace") .with_help("Try to remove the irregular whitespace") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_iterator.rs b/crates/oxc_linter/src/rules/eslint/no_iterator.rs index cedf8ddbae9224..4dd59842f10e1f 100644 --- a/crates/oxc_linter/src/rules/eslint/no_iterator.rs +++ b/crates/oxc_linter/src/rules/eslint/no_iterator.rs @@ -6,7 +6,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_iterator_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-iterator): Reserved name '__iterator__'") + OxcDiagnostic::warn("Reserved name '__iterator__'") .with_help("Disallow the use of the `__iterator__` property.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_label_var.rs b/crates/oxc_linter/src/rules/eslint/no_label_var.rs index 420e43aa2dee8a..304338a6b2f29a 100644 --- a/crates/oxc_linter/src/rules/eslint/no_label_var.rs +++ b/crates/oxc_linter/src/rules/eslint/no_label_var.rs @@ -6,13 +6,11 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_label_var_diagnostic(x0: &str, span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-label-var): Found identifier '{x0}' with the same name as a label." - )) - .with_labels([ - span0.label(format!("Identifier '{x0}' found here.")), - span1.label("Label with the same name."), - ]) + OxcDiagnostic::warn(format!("Found identifier '{x0}' with the same name as a label.")) + .with_labels([ + span0.label(format!("Identifier '{x0}' found here.")), + span1.label("Label with the same name."), + ]) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs b/crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs index 25863956bee850..0291766b456662 100644 --- a/crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs +++ b/crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs @@ -8,10 +8,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_loss_of_precision_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-loss-of-precision): This number literal will lose precision at runtime.", - ) - .with_label(span0) + OxcDiagnostic::warn("This number literal will lose precision at runtime.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_multi_str.rs b/crates/oxc_linter/src/rules/eslint/no_multi_str.rs index ba501bc8badab4..ae74b663e018f9 100644 --- a/crates/oxc_linter/src/rules/eslint/no_multi_str.rs +++ b/crates/oxc_linter/src/rules/eslint/no_multi_str.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_multi_str_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-multi-str): Unexpected multi string.").with_label(span0) + OxcDiagnostic::warn("Unexpected multi string.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_new.rs b/crates/oxc_linter/src/rules/eslint/no_new.rs index aaab565aa21cf3..06b5f8b6a73df2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_new.rs +++ b/crates/oxc_linter/src/rules/eslint/no_new.rs @@ -6,7 +6,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_new_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-new): Do not use 'new' for side effects.").with_label(span0) + OxcDiagnostic::warn("Do not use 'new' for side effects.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs b/crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs index 69e1dfdae078ac..ab665fc3640fe6 100644 --- a/crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs @@ -6,10 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_new_native_nonconstructor_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-new-native-nonconstructor): `{x0}` cannot be called as a constructor." - )) - .with_label(span1) + OxcDiagnostic::warn(format!("`{x0}` cannot be called as a constructor.")).with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs b/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs index 46ef6b6af8b2bf..bd01a882500187 100644 --- a/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs +++ b/crates/oxc_linter/src/rules/eslint/no_new_wrappers.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_new_wrappers_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-new-wrappers): Disallow new operators with the String, Number, and Boolean objects") + OxcDiagnostic::warn("Disallow new operators with the String, Number, and Boolean objects") .with_help(format!("do not use {x0} as a constructor, consider removing the new operator.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs b/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs index f303ddbf4d1698..ca6b322fa1d385 100644 --- a/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs @@ -8,19 +8,15 @@ use regex::{Captures, Regex}; use crate::{context::LintContext, rule::Rule, AstNode}; fn replacement(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-nonoctal-decimal-escape): Don't use '{x0}' escape sequence." - )) - .with_help(format!("Replace '{x0}' with '{x1}'. This maintains the current functionality.")) - .with_label(span2) + OxcDiagnostic::warn(format!("Don't use '{x0}' escape sequence.")) + .with_help(format!("Replace '{x0}' with '{x1}'. This maintains the current functionality.")) + .with_label(span2) } fn escape_backslash(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-nonoctal-decimal-escape): Don't use '{x0}' escape sequence." - )) - .with_help(format!("Replace '{x0}' with '{x1}' to include the actual backslash character.")) - .with_label(span2) + OxcDiagnostic::warn(format!("Don't use '{x0}' escape sequence.")) + .with_help(format!("Replace '{x0}' with '{x1}' to include the actual backslash character.")) + .with_label(span2) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs index a954edd6aa73c2..3a63a3d907e8c0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs +++ b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs @@ -13,7 +13,7 @@ const GLOBAL_THIS: &str = "globalThis"; const NON_CALLABLE_GLOBALS: [&str; 5] = ["Atomics", "Intl", "JSON", "Math", "Reflect"]; fn no_obj_calls_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-obj-calls): Disallow calling some global objects as functions") + OxcDiagnostic::warn("Disallow calling some global objects as functions") .with_help(format!("{x0} is not a function.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_proto.rs b/crates/oxc_linter/src/rules/eslint/no_proto.rs index 3e6a2395af0cba..a29dd0a60e6f65 100644 --- a/crates/oxc_linter/src/rules/eslint/no_proto.rs +++ b/crates/oxc_linter/src/rules/eslint/no_proto.rs @@ -6,7 +6,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_proto_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-proto): The '__proto__' property is deprecated") + OxcDiagnostic::warn("The '__proto__' property is deprecated") .with_help("Disallow the use of the `__proto__` property.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_prototype_builtins.rs b/crates/oxc_linter/src/rules/eslint/no_prototype_builtins.rs index 14ea5409466775..5d23038ab5f35a 100644 --- a/crates/oxc_linter/src/rules/eslint/no_prototype_builtins.rs +++ b/crates/oxc_linter/src/rules/eslint/no_prototype_builtins.rs @@ -6,8 +6,10 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_prototype_builtins_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-prototype-builtins): do not access Object.prototype method {x0:?} from target object")) - .with_help(format!("to avoid prototype pollution, use `Object.prototype.{x0}.call` instead")) + OxcDiagnostic::warn(format!("do not access Object.prototype method {x0:?} from target object")) + .with_help(format!( + "to avoid prototype pollution, use `Object.prototype.{x0}.call` instead" + )) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_redeclare.rs b/crates/oxc_linter/src/rules/eslint/no_redeclare.rs index c71798c26c9c18..3b2c426ba692a4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_redeclare.rs +++ b/crates/oxc_linter/src/rules/eslint/no_redeclare.rs @@ -9,17 +9,17 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_redeclare_diagnostic(x0: &str, span1: Span, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-redeclare): '{x0}' is already defined.")).with_labels([ + OxcDiagnostic::warn(format!("'{x0}' is already defined.")).with_labels([ span1.label(format!("'{x0}' is already defined.")), span2.label("It can not be redeclare here."), ]) } fn no_redeclare_as_builti_in_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-redeclare): '{x0}' is already defined as a built-in global variable." - )) - .with_label(span1.label(format!("'{x0}' is already defined as a built-in global variable."))) + OxcDiagnostic::warn(format!("'{x0}' is already defined as a built-in global variable.")) + .with_label( + span1.label(format!("'{x0}' is already defined as a built-in global variable.")), + ) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs b/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs index 3a40b30fae7411..5c9679ba27d867 100644 --- a/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs +++ b/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs @@ -10,7 +10,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_regex_spaces_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-regex-spaces): Spaces are hard to count.") + OxcDiagnostic::warn("Spaces are hard to count.") .with_help("Use a quantifier, e.g. {2}") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs b/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs index 2ef6d9265cd90d..f41ea3189c9909 100644 --- a/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs +++ b/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs @@ -9,9 +9,9 @@ use crate::{context::LintContext, rule::Rule, AstNode}; fn no_restricted_globals(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { let warn_text = if x1.is_empty() { - format!("eslint(no-restricted-globals): Unexpected use of '{x0}'.") + format!("Unexpected use of '{x0}'.") } else { - format!("eslint(no-restricted-globals): Unexpected use of '{x0}'. {x1}") + format!("Unexpected use of '{x0}'. {x1}") }; OxcDiagnostic::warn(warn_text).with_label(span2) diff --git a/crates/oxc_linter/src/rules/eslint/no_script_url.rs b/crates/oxc_linter/src/rules/eslint/no_script_url.rs index 980f4a20c36824..b1be0ff0108ef4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_script_url.rs +++ b/crates/oxc_linter/src/rules/eslint/no_script_url.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_script_url_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-script-url): Script URL is a form of eval") + OxcDiagnostic::warn("Script URL is a form of eval") .with_help("Disallow `javascript:` urls") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_self_assign.rs b/crates/oxc_linter/src/rules/eslint/no_self_assign.rs index c1865ff1fd7a06..1e8fb8f4d71a75 100644 --- a/crates/oxc_linter/src/rules/eslint/no_self_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_self_assign.rs @@ -14,8 +14,7 @@ use oxc_syntax::operator::AssignmentOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_self_assign_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-self-assign): this expression is assigned to itself") - .with_label(span0) + OxcDiagnostic::warn("this expression is assigned to itself").with_label(span0) } #[derive(Debug, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_self_compare.rs b/crates/oxc_linter/src/rules/eslint/no_self_compare.rs index b098cfe2d36607..8e7d6c403b4ca3 100644 --- a/crates/oxc_linter/src/rules/eslint/no_self_compare.rs +++ b/crates/oxc_linter/src/rules/eslint/no_self_compare.rs @@ -6,11 +6,9 @@ use oxc_span::{GetSpan, Span}; use crate::{ast_util::calculate_hash, context::LintContext, rule::Rule, AstNode}; fn no_self_compare_diagnostic(span0: Span, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-self-compare): Disallow comparisons where both sides are exactly the same", - ) - .with_help("If you are testing for NaN, you can use Number.isNaN function.") - .with_labels([span0, span1]) + OxcDiagnostic::warn("Disallow comparisons where both sides are exactly the same") + .with_help("If you are testing for NaN, you can use Number.isNaN function.") + .with_labels([span0, span1]) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_setter_return.rs b/crates/oxc_linter/src/rules/eslint/no_setter_return.rs index 2d05df3f375d43..f6c55176963d54 100644 --- a/crates/oxc_linter/src/rules/eslint/no_setter_return.rs +++ b/crates/oxc_linter/src/rules/eslint/no_setter_return.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_setter_return_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-setter-return): Setter cannot return a value").with_label(span0) + OxcDiagnostic::warn("Setter cannot return a value").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs b/crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs index a41c346319be45..33edced1781f8e 100644 --- a/crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs +++ b/crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, globals::PRE_DEFINE_VAR, rule::Rule}; fn no_shadow_restricted_names_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-shadow-restricted-names): Shadowing of global properties such as 'undefined' is not allowed.") + OxcDiagnostic::warn("Shadowing of global properties such as 'undefined' is not allowed.") .with_help(format!("Shadowing of global properties '{x0}'.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_sparse_arrays.rs b/crates/oxc_linter/src/rules/eslint/no_sparse_arrays.rs index b5116f3f27afa2..d13e546e1f7dbe 100644 --- a/crates/oxc_linter/src/rules/eslint/no_sparse_arrays.rs +++ b/crates/oxc_linter/src/rules/eslint/no_sparse_arrays.rs @@ -46,11 +46,9 @@ impl Rule for NoSparseArrays { if !violations.is_empty() { if violations.len() < 10 { ctx.diagnostic( - OxcDiagnostic::warn( - "eslint(no-sparse-arrays): Unexpected comma in middle of array", - ) - .with_help("remove the comma or insert `undefined`") - .with_labels(violations), + OxcDiagnostic::warn("Unexpected comma in middle of array") + .with_help("remove the comma or insert `undefined`") + .with_labels(violations), ); } else { let span = if (array_expr.span.end - array_expr.span.start) < 50 { @@ -64,7 +62,7 @@ impl Rule for NoSparseArrays { ctx.diagnostic( OxcDiagnostic::warn(format!( - "eslint(no-sparse-arrays): {} unexpected commas in middle of array", + "{} unexpected commas in middle of array", violations.len() )) .with_help("remove the comma or insert `undefined`") diff --git a/crates/oxc_linter/src/rules/eslint/no_template_curly_in_string.rs b/crates/oxc_linter/src/rules/eslint/no_template_curly_in_string.rs index 37b7eedf3799ef..90710fc4c2588f 100644 --- a/crates/oxc_linter/src/rules/eslint/no_template_curly_in_string.rs +++ b/crates/oxc_linter/src/rules/eslint/no_template_curly_in_string.rs @@ -6,11 +6,9 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_template_curly_in_string_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-template-curly-in-string): Unexpected template string expression", - ) - .with_help("Disallow template literal placeholder syntax in regular strings") - .with_label(span0) + OxcDiagnostic::warn("Unexpected template string expression") + .with_help("Disallow template literal placeholder syntax in regular strings") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_ternary.rs b/crates/oxc_linter/src/rules/eslint/no_ternary.rs index 8978a51b34a28b..12b72d8fd80339 100644 --- a/crates/oxc_linter/src/rules/eslint/no_ternary.rs +++ b/crates/oxc_linter/src/rules/eslint/no_ternary.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_ternary_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-ternary): Unexpected use of ternary expression") + OxcDiagnostic::warn("Unexpected use of ternary expression") .with_help("Do not use the ternary expression.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs b/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs index 59930e2615713a..9a406676d20ed4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs +++ b/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs @@ -16,7 +16,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_this_before_super_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-this-before-super): Expected to always call super() before this/super property access.") + OxcDiagnostic::warn("Expected to always call super() before this/super property access.") .with_help("Call super() before this/super property access.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_undef.rs b/crates/oxc_linter/src/rules/eslint/no_undef.rs index 75826fe9df3d6d..278ddf131c1764 100644 --- a/crates/oxc_linter/src/rules/eslint/no_undef.rs +++ b/crates/oxc_linter/src/rules/eslint/no_undef.rs @@ -7,7 +7,7 @@ use oxc_syntax::operator::UnaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_undef_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-undef): Disallow the use of undeclared variables.") + OxcDiagnostic::warn("Disallow the use of undeclared variables.") .with_help(format!("'{x0}' is not defined.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_undefined.rs b/crates/oxc_linter/src/rules/eslint/no_undefined.rs index 13c724dc6345ef..213fcd6021ddd6 100644 --- a/crates/oxc_linter/src/rules/eslint/no_undefined.rs +++ b/crates/oxc_linter/src/rules/eslint/no_undefined.rs @@ -9,7 +9,7 @@ use crate::{context::LintContext, rule::Rule, AstNode}; pub struct NoUndefined; fn no_undefined_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-undefined): Disallow the use of `undefined` as an identifier") + OxcDiagnostic::warn("Disallow the use of `undefined` as an identifier") .with_help("Unexpected use of undefined.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_unreachable.rs b/crates/oxc_linter/src/rules/eslint/no_unreachable.rs index c6cbcd462b507b..da6f5f2689c258 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unreachable.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unreachable.rs @@ -13,7 +13,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule}; fn no_unreachable_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::error("eslint(no-unreachable): Unreachable code.").with_label(span) + OxcDiagnostic::error("Unreachable code.").with_label(span) } /// diff --git a/crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs b/crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs index 74395342a3bd2d..5c9dbdea0f7cd5 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs @@ -9,7 +9,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_unsafe_finally_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-unsafe-finally): Unsafe finally block") + OxcDiagnostic::warn("Unsafe finally block") .with_help("Control flow inside try or catch blocks will be overwritten by this statement") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_unsafe_optional_chaining.rs b/crates/oxc_linter/src/rules/eslint/no_unsafe_optional_chaining.rs index 05d004430ce3e9..a393ed72262f56 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unsafe_optional_chaining.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unsafe_optional_chaining.rs @@ -10,17 +10,15 @@ use oxc_syntax::operator::LogicalOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_unsafe_optional_chaining_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-unsafe-optional-chaining): Unsafe usage of optional chaining") + OxcDiagnostic::warn("Unsafe usage of optional chaining") .with_help("If this short-circuits with 'undefined' the evaluation will throw TypeError") .with_label(span0) } fn no_unsafe_arithmetic_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(no-unsafe-optional-chaining): Unsafe arithmetic operation on optional chaining", - ) - .with_help("This can result in NaN.") - .with_label(span0) + OxcDiagnostic::warn("Unsafe arithmetic operation on optional chaining") + .with_help("This can result in NaN.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs b/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs index 9aa64b65e66c9e..b7d6a73d9e1c2f 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_unused_labels_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-unused-labels): Disallow unused labels") + OxcDiagnostic::warn("Disallow unused labels") .with_help(format!("'{x0}:' is defined but never used.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs b/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs index cadb43bef847a5..bd76f684a1cbc5 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs @@ -9,10 +9,7 @@ use oxc_syntax::class::ElementKind; use crate::{context::LintContext, rule::Rule}; fn no_unused_private_class_members_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(no-unused-private-class-members): '{x0}' is defined but never used." - )) - .with_label(span1) + OxcDiagnostic::warn(format!("'{x0}' is defined but never used.")).with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_catch.rs b/crates/oxc_linter/src/rules/eslint/no_useless_catch.rs index 9b301ce49e423b..26964c2ccfc3f6 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_catch.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_catch.rs @@ -9,12 +9,12 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_useless_catch_diagnostic(catch: Span, rethrow: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-catch): Unnecessary try/catch wrapper") + OxcDiagnostic::warn("Unnecessary try/catch wrapper") .with_labels([catch.label("is caught here"), rethrow.label("and re-thrown here")]) } fn no_useless_catch_finalizer_diagnostic(catch: Span, rethrow: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-catch): Unnecessary catch clause") + OxcDiagnostic::warn("Unnecessary catch clause") .with_labels([catch.label("is caught here"), rethrow.label("and re-thrown here")]) } diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_concat.rs b/crates/oxc_linter/src/rules/eslint/no_useless_concat.rs index 50b5122c0b6a31..35ea1f75acdaef 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_concat.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_concat.rs @@ -13,7 +13,7 @@ use crate::{context::LintContext, rule::Rule, AstNode}; pub struct NoUselessConcat; fn no_useless_concat_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-concat): Unexpected string concatenation of literals.") + OxcDiagnostic::warn("Unexpected string concatenation of literals.") .with_help("Rewrite into one string literal") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs index 59ee86e6ebef30..f5aee8b854f0a1 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs @@ -12,12 +12,12 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_empty_constructor(constructor_span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-constructor): Empty constructors are unnecessary") + OxcDiagnostic::warn("Empty constructors are unnecessary") .with_label(constructor_span) .with_help("Remove the constructor or add code to it.") } fn no_redundant_super_call(constructor_span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-constructor): Redundant super call in constructor") + OxcDiagnostic::warn("Redundant super call in constructor") .with_label(constructor_span).with_help("Constructors of subclasses invoke super() automatically if they are empty. Remove this constructor or add code to it.") } diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs b/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs index fbe7bb40fb0d63..a72931cbdd7574 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs @@ -8,8 +8,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_useless_escape_diagnostic(x0: char, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(no-useless-escape): Unnecessary escape character {x0:?}")) - .with_label(span1) + OxcDiagnostic::warn(format!("Unnecessary escape character {x0:?}")).with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_rename.rs b/crates/oxc_linter/src/rules/eslint/no_useless_rename.rs index 9169ab4dd49014..9cd391ce54c22c 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_rename.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_rename.rs @@ -9,9 +9,11 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_useless_rename_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-useless-rename): Disallow renaming import, export, and destructured assignments to the same name") - .with_help("Either remove the renaming or rename the variable.") - .with_label(span0) + OxcDiagnostic::warn( + "Disallow renaming import, export, and destructured assignments to the same name", + ) + .with_help("Either remove the renaming or rename the variable.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/no_var.rs b/crates/oxc_linter/src/rules/eslint/no_var.rs index 0630b2f7b57370..e650f3aec168a4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_var.rs +++ b/crates/oxc_linter/src/rules/eslint/no_var.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_var_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-var): Unexpected var, use let or const instead.") + OxcDiagnostic::warn("Unexpected var, use let or const instead.") .with_help("Replace var with let or const") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_void.rs b/crates/oxc_linter/src/rules/eslint/no_void.rs index 595b386874176c..0785114107417d 100644 --- a/crates/oxc_linter/src/rules/eslint/no_void.rs +++ b/crates/oxc_linter/src/rules/eslint/no_void.rs @@ -7,7 +7,7 @@ use oxc_syntax::operator::UnaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_void_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-void): Disallow `void` operators") + OxcDiagnostic::warn("Disallow `void` operators") .with_help("Expected 'undefined' and instead saw 'void'.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/no_with.rs b/crates/oxc_linter/src/rules/eslint/no_with.rs index e8e6c08db0e39b..bea0e17dabc5f0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_with.rs +++ b/crates/oxc_linter/src/rules/eslint/no_with.rs @@ -6,7 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_with_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(no-with): Unexpected use of `with` statement.") + OxcDiagnostic::warn("Unexpected use of `with` statement.") .with_help("Do not use the `with` statement.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/prefer_exponentiation_operator.rs b/crates/oxc_linter/src/rules/eslint/prefer_exponentiation_operator.rs index bc625652568473..bcc7310d9c2c32 100644 --- a/crates/oxc_linter/src/rules/eslint/prefer_exponentiation_operator.rs +++ b/crates/oxc_linter/src/rules/eslint/prefer_exponentiation_operator.rs @@ -12,10 +12,7 @@ use crate::{ pub struct PreferExponentiationOperator; fn prefer_exponentian_operator_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-unicorn(prefer-exponentian-operator): Prefer `**` over `Math.pow`.", - ) - .with_label(span0) + OxcDiagnostic::warn("Prefer `**` over `Math.pow`.").with_label(span0) } declare_oxc_lint!( diff --git a/crates/oxc_linter/src/rules/eslint/radix.rs b/crates/oxc_linter/src/rules/eslint/radix.rs index 3777b5c8e04080..da915d5ee4541e 100644 --- a/crates/oxc_linter/src/rules/eslint/radix.rs +++ b/crates/oxc_linter/src/rules/eslint/radix.rs @@ -9,22 +9,20 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; fn missing_parameters(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(radix): Missing parameters.").with_label(span0) + OxcDiagnostic::warn("Missing parameters.").with_label(span0) } fn missing_radix(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(radix): Missing radix parameter.").with_label(span0) + OxcDiagnostic::warn("Missing radix parameter.").with_label(span0) } fn redundant_radix(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(radix): Redundant radix parameter.").with_label(span0) + OxcDiagnostic::warn("Redundant radix parameter.").with_label(span0) } fn invalid_radix(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint(radix): Invalid radix parameter, must be an integer between 2 and 36.", - ) - .with_label(span0) + OxcDiagnostic::warn("Invalid radix parameter, must be an integer between 2 and 36.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/require_await.rs b/crates/oxc_linter/src/rules/eslint/require_await.rs index e8ac13daf5d870..9e5cd5d7014d89 100644 --- a/crates/oxc_linter/src/rules/eslint/require_await.rs +++ b/crates/oxc_linter/src/rules/eslint/require_await.rs @@ -14,8 +14,7 @@ use crate::{context::LintContext, rule::Rule, AstNode}; pub struct RequireAwait; fn require_await_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(require-await): Async function has no 'await' expression.") - .with_label(span0) + OxcDiagnostic::warn("Async function has no 'await' expression.").with_label(span0) } declare_oxc_lint!( diff --git a/crates/oxc_linter/src/rules/eslint/require_yield.rs b/crates/oxc_linter/src/rules/eslint/require_yield.rs index bd2fb58da88b3f..2ccfcf36d92bbf 100644 --- a/crates/oxc_linter/src/rules/eslint/require_yield.rs +++ b/crates/oxc_linter/src/rules/eslint/require_yield.rs @@ -6,8 +6,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn require_yield_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(require-yield): This generator function does not have 'yield'") - .with_label(span0) + OxcDiagnostic::warn("This generator function does not have 'yield'").with_label(span0) } #[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 69a651326d9f50..b78a4257b91a8b 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -19,20 +19,18 @@ fn unexpected_syntax_order_diagnostic( x1: &ImportKind, span2: Span, ) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint(sort-imports): Expected '{x0}' syntax before '{x1}' syntax." - )) - .with_label(span2) + OxcDiagnostic::warn(format!("Expected '{x0}' syntax before '{x1}' syntax.")).with_label(span2) } fn sort_imports_alphabetically_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(sort-imports): Imports should be sorted alphabetically.") - .with_label(span0) + OxcDiagnostic::warn("Imports should be sorted alphabetically.").with_label(span0) } fn sort_members_alphabetically_diagnostic(x0: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint(sort-imports): Member '{x0}' of the import declaration should be sorted alphabetically.")) - .with_label(span0) + OxcDiagnostic::warn(format!( + "Member '{x0}' of the import declaration should be sorted alphabetically." + )) + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/eslint/symbol_description.rs b/crates/oxc_linter/src/rules/eslint/symbol_description.rs index 101096dff1fa89..4b191b91fc52bd 100644 --- a/crates/oxc_linter/src/rules/eslint/symbol_description.rs +++ b/crates/oxc_linter/src/rules/eslint/symbol_description.rs @@ -9,8 +9,7 @@ use crate::{context::LintContext, rule::Rule, AstNode}; pub struct SymbolDescription; fn symbol_description_diagnostic(span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(symbol-description): Expected Symbol to have a description.") - .with_label(span1) + OxcDiagnostic::warn("Expected Symbol to have a description.").with_label(span1) } declare_oxc_lint!( diff --git a/crates/oxc_linter/src/rules/eslint/unicode_bom.rs b/crates/oxc_linter/src/rules/eslint/unicode_bom.rs index ee15443de98b26..2fa335d8906545 100644 --- a/crates/oxc_linter/src/rules/eslint/unicode_bom.rs +++ b/crates/oxc_linter/src/rules/eslint/unicode_bom.rs @@ -5,13 +5,13 @@ use oxc_span::{Span, SPAN}; use crate::{context::LintContext, rule::Rule}; fn unexpected_unicode_bom_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(unicode-bom): Unexpected Unicode BOM (Byte Order Mark)") + OxcDiagnostic::warn("Unexpected Unicode BOM (Byte Order Mark)") .with_help("File must not begin with the Unicode BOM") .with_label(span0) } fn expected_unicode_bom_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(unicode-bom): Expected Unicode BOM (Byte Order Mark)") + OxcDiagnostic::warn("Expected Unicode BOM (Byte Order Mark)") .with_help("File must begin with the Unicode BOM") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/eslint/use_isnan.rs b/crates/oxc_linter/src/rules/eslint/use_isnan.rs index 43e3de013435d4..7ea3c5d1d12c77 100644 --- a/crates/oxc_linter/src/rules/eslint/use_isnan.rs +++ b/crates/oxc_linter/src/rules/eslint/use_isnan.rs @@ -10,13 +10,13 @@ use oxc_syntax::operator::BinaryOperator; use crate::{context::LintContext, rule::Rule, AstNode}; fn comparison_with_na_n(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(use-isnan): Requires calls to isNaN() when checking for NaN") + OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN") .with_help("Use the isNaN function to compare with NaN.") .with_label(span0) } fn switch_na_n(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(use-isnan): Requires calls to isNaN() when checking for NaN") + OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN") .with_help( "'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.", ) @@ -24,13 +24,13 @@ fn switch_na_n(span0: Span) -> OxcDiagnostic { } fn case_na_n(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(use-isnan): Requires calls to isNaN() when checking for NaN") + OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN") .with_help("'case NaN' can never match. Use Number.isNaN before the switch.") .with_label(span0) } fn index_of_na_n(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(use-isnan): Requires calls to isNaN() when checking for NaN") + OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN") .with_help(format!("Array prototype method '{x0}' cannot find NaN.")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/eslint/valid_typeof.rs b/crates/oxc_linter/src/rules/eslint/valid_typeof.rs index c616d6926379ce..a323997380e660 100644 --- a/crates/oxc_linter/src/rules/eslint/valid_typeof.rs +++ b/crates/oxc_linter/src/rules/eslint/valid_typeof.rs @@ -8,10 +8,8 @@ use phf::{phf_set, Set}; use crate::{context::LintContext, rule::Rule, AstNode}; fn not_string(x0: Option<&'static str>, span1: Span) -> OxcDiagnostic { - let mut d = OxcDiagnostic::warn( - "eslint(valid-typeof): Typeof comparisons should be to string literals.", - ) - .with_label(span1); + let mut d = + OxcDiagnostic::warn("Typeof comparisons should be to string literals.").with_label(span1); if let Some(x) = x0 { d = d.with_help(x); } @@ -19,8 +17,7 @@ fn not_string(x0: Option<&'static str>, span1: Span) -> OxcDiagnostic { } fn invalid_value(x0: Option<&'static str>, span1: Span) -> OxcDiagnostic { - let mut d = OxcDiagnostic::warn("eslint(valid-typeof): Invalid typeof comparison value.") - .with_label(span1); + let mut d = OxcDiagnostic::warn("Invalid typeof comparison value.").with_label(span1); if let Some(x) = x0 { d = d.with_help(x); } diff --git a/crates/oxc_linter/src/rules/import/default.rs b/crates/oxc_linter/src/rules/import/default.rs index 8256b68f1c1433..241bfae0654114 100644 --- a/crates/oxc_linter/src/rules/import/default.rs +++ b/crates/oxc_linter/src/rules/import/default.rs @@ -6,11 +6,9 @@ use oxc_syntax::module_record::ImportImportName; use crate::{context::LintContext, rule::Rule}; fn default_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(default): No default export found in imported module {x0:?}" - )) - .with_help(format!("does {x0:?} have the default export?")) - .with_label(span1) + OxcDiagnostic::warn(format!("No default export found in imported module {x0:?}")) + .with_help(format!("does {x0:?} have the default export?")) + .with_label(span1) } /// diff --git a/crates/oxc_linter/src/rules/import/export.rs b/crates/oxc_linter/src/rules/import/export.rs index 08b5191fa82b17..74abbfcf7feb19 100644 --- a/crates/oxc_linter/src/rules/import/export.rs +++ b/crates/oxc_linter/src/rules/import/export.rs @@ -9,10 +9,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{context::LintContext, rule::Rule}; fn no_named_export(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(export): No named exports found in module '{x1}'" - )) - .with_label(span0) + OxcDiagnostic::warn(format!("No named exports found in module '{x1}'")).with_label(span0) } /// @@ -89,10 +86,8 @@ impl Rule for Export { let labels = spans.into_iter().map(LabeledSpan::underline).collect::>(); ctx.diagnostic( - OxcDiagnostic::warn(format!( - "eslint-plugin-import(export): Multiple exports of name '{name}'." - )) - .with_labels(labels), + OxcDiagnostic::warn(format!("Multiple exports of name '{name}'.")) + .with_labels(labels), ); } } @@ -103,8 +98,7 @@ impl Rule for Export { spans.push(span); let labels = spans.into_iter().map(LabeledSpan::underline).collect::>(); ctx.diagnostic( - OxcDiagnostic::warn("eslint-plugin-import(export): Multiple default exports.") - .with_labels(labels), + OxcDiagnostic::warn("Multiple default exports.").with_labels(labels), ); } } diff --git a/crates/oxc_linter/src/rules/import/max_dependencies.rs b/crates/oxc_linter/src/rules/import/max_dependencies.rs index 76b608cf9e06fe..80b4c7cc5fab50 100644 --- a/crates/oxc_linter/src/rules/import/max_dependencies.rs +++ b/crates/oxc_linter/src/rules/import/max_dependencies.rs @@ -6,7 +6,7 @@ use serde_json::Value; use crate::{context::LintContext, rule::Rule}; fn max_dependencies_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-import(max-dependencies): {x0:?}")) + OxcDiagnostic::warn(format!("{x0:?}")) .with_help("Reduce the number of dependencies in this file") .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/import/named.rs b/crates/oxc_linter/src/rules/import/named.rs index 927434ece85644..6142745b4497c7 100644 --- a/crates/oxc_linter/src/rules/import/named.rs +++ b/crates/oxc_linter/src/rules/import/named.rs @@ -6,7 +6,7 @@ use oxc_syntax::module_record::{ExportImportName, ImportImportName}; use crate::{context::LintContext, rule::Rule}; fn named_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-import(named): named import {x0:?} not found")) + OxcDiagnostic::warn(format!("named import {x0:?} not found")) .with_help(format!("does {x1:?} have the export {x0:?}?")) .with_label(span2) } diff --git a/crates/oxc_linter/src/rules/import/namespace.rs b/crates/oxc_linter/src/rules/import/namespace.rs index b416daa42009ed..2d049af078bbc0 100644 --- a/crates/oxc_linter/src/rules/import/namespace.rs +++ b/crates/oxc_linter/src/rules/import/namespace.rs @@ -13,30 +13,25 @@ use oxc_syntax::module_record::{ExportExportName, ExportImportName, ImportImport use crate::{context::LintContext, rule::Rule}; fn no_export(span0: Span, x1: &str, x2: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(namespace): {x1:?} not found in imported namespace {x2:?}." - )) - .with_label(span0) + OxcDiagnostic::warn(format!("{x1:?} not found in imported namespace {x2:?}.")).with_label(span0) } fn no_export_in_deeply_imported_namespace(span0: Span, x1: &str, x2: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(namespace): {x1:?} not found in deeply imported namespace {x2:?}." - )) - .with_label(span0) + OxcDiagnostic::warn(format!("{x1:?} not found in deeply imported namespace {x2:?}.")) + .with_label(span0) } fn computed_reference(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-import(namespace): Unable to validate computed reference to imported namespace {x1:?}.")).with_label(span0) -} - -fn assignment(span0: Span, x1: &str) -> OxcDiagnostic { OxcDiagnostic::warn(format!( - "eslint-plugin-import(namespace): Assignment to member of namespace {x1:?}.'" + "Unable to validate computed reference to imported namespace {x1:?}." )) .with_label(span0) } +fn assignment(span0: Span, x1: &str) -> OxcDiagnostic { + OxcDiagnostic::warn(format!("Assignment to member of namespace {x1:?}.'")).with_label(span0) +} + /// #[derive(Debug, Default, Clone)] pub struct Namespace { diff --git a/crates/oxc_linter/src/rules/import/no_amd.rs b/crates/oxc_linter/src/rules/import/no_amd.rs index c35c1751ebb946..5e48c32aca1c42 100644 --- a/crates/oxc_linter/src/rules/import/no_amd.rs +++ b/crates/oxc_linter/src/rules/import/no_amd.rs @@ -9,11 +9,9 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_amd_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-import(no-amd): Do not use AMD `require` and `define` calls.", - ) - .with_help(format!("Expected imports instead of AMD {x1}()")) - .with_label(span0) + OxcDiagnostic::warn("Do not use AMD `require` and `define` calls.") + .with_help(format!("Expected imports instead of AMD {x1}()")) + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/import/no_cycle.rs b/crates/oxc_linter/src/rules/import/no_cycle.rs index aa4e2797664834..e215da63103a47 100644 --- a/crates/oxc_linter/src/rules/import/no_cycle.rs +++ b/crates/oxc_linter/src/rules/import/no_cycle.rs @@ -12,7 +12,7 @@ use oxc_syntax::{ use crate::{context::LintContext, rule::Rule}; fn no_cycle_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-import(no-cycle): Dependency cycle detected") + OxcDiagnostic::warn("Dependency cycle detected") .with_help(format!("These paths form a cycle: \n{x1}")) .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/import/no_default_export.rs b/crates/oxc_linter/src/rules/import/no_default_export.rs index 1afa56e1f08f5f..55b2d2d0a281c4 100644 --- a/crates/oxc_linter/src/rules/import/no_default_export.rs +++ b/crates/oxc_linter/src/rules/import/no_default_export.rs @@ -5,8 +5,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_default_export_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-import(no-default-export): Prefer named exports") - .with_label(span0) + OxcDiagnostic::warn("Prefer named exports").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/import/no_deprecated.rs b/crates/oxc_linter/src/rules/import/no_deprecated.rs index 61c511eda01959..e8642a0bf771e8 100644 --- a/crates/oxc_linter/src/rules/import/no_deprecated.rs +++ b/crates/oxc_linter/src/rules/import/no_deprecated.rs @@ -5,7 +5,7 @@ use oxc_macros::declare_oxc_lint; use crate::{context::LintContext, rule::Rule}; // #[derive(Debug, Error, Diagnostic)] -// #[error("eslint-plugin-import(namespace): ")] +// #[error("")] // #[diagnostic(severity(warning), help(""))] // struct NoDeprecatedDiagnostic(CompactStr, #[label] pub Span); diff --git a/crates/oxc_linter/src/rules/import/no_duplicates.rs b/crates/oxc_linter/src/rules/import/no_duplicates.rs index 424d018e080844..0752279ee73363 100644 --- a/crates/oxc_linter/src/rules/import/no_duplicates.rs +++ b/crates/oxc_linter/src/rules/import/no_duplicates.rs @@ -51,7 +51,12 @@ impl Rule for NoDuplicates { .iter() .map(|requested_module| LabeledSpan::underline(requested_module.span())) .collect::>(); - ctx.diagnostic(OxcDiagnostic::warn("eslint-plugin-import(no-duplicates): Forbid repeated import of the same module in multiple places").with_labels(labels)); + ctx.diagnostic( + OxcDiagnostic::warn( + "Forbid repeated import of the same module in multiple places", + ) + .with_labels(labels), + ); } } }; diff --git a/crates/oxc_linter/src/rules/import/no_named_as_default.rs b/crates/oxc_linter/src/rules/import/no_named_as_default.rs index 9c538560bc87b1..0689dbb09bd6ed 100644 --- a/crates/oxc_linter/src/rules/import/no_named_as_default.rs +++ b/crates/oxc_linter/src/rules/import/no_named_as_default.rs @@ -6,7 +6,7 @@ use oxc_syntax::module_record::ImportImportName; use crate::{context::LintContext, rule::Rule}; fn no_named_as_default_diagnostic(span0: Span, x1: &str, x2: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-import(no-named-as-default): Module {x2:?} has named export {x1:?}")) + OxcDiagnostic::warn(format!("Module {x2:?} has named export {x1:?}")) .with_help(format!("Using default import as {x1:?} can be confusing. Use another name for default import to avoid confusion.")) .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/import/no_named_as_default_member.rs b/crates/oxc_linter/src/rules/import/no_named_as_default_member.rs index 5e1f86c000c80a..269844bd288c31 100644 --- a/crates/oxc_linter/src/rules/import/no_named_as_default_member.rs +++ b/crates/oxc_linter/src/rules/import/no_named_as_default_member.rs @@ -17,11 +17,9 @@ fn no_named_as_default_member_dignostic( x2: &str, x3: &str, ) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(no-named-as-default-member): {x1:?} also has a named export {x2:?}" - )) - .with_help(format!("Check if you meant to write `import {{{x2:}}} from {x3:?}`")) - .with_label(span0) + OxcDiagnostic::warn(format!("{x1:?} also has a named export {x2:?}")) + .with_help(format!("Check if you meant to write `import {{{x2:}}} from {x3:?}`")) + .with_label(span0) } /// diff --git a/crates/oxc_linter/src/rules/import/no_self_import.rs b/crates/oxc_linter/src/rules/import/no_self_import.rs index 2d038085466321..31b39c82e6a243 100644 --- a/crates/oxc_linter/src/rules/import/no_self_import.rs +++ b/crates/oxc_linter/src/rules/import/no_self_import.rs @@ -5,10 +5,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_self_import_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-import(no-self-import): module importing itself is not allowed", - ) - .with_label(span0) + OxcDiagnostic::warn("module importing itself is not allowed").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/import/no_unused_modules.rs b/crates/oxc_linter/src/rules/import/no_unused_modules.rs index ac820001759e14..0a61957f5105fa 100644 --- a/crates/oxc_linter/src/rules/import/no_unused_modules.rs +++ b/crates/oxc_linter/src/rules/import/no_unused_modules.rs @@ -4,7 +4,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_exports_found(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-import(no-unused-modules): No exports found") + OxcDiagnostic::warn("No exports found") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/import/no_webpack_loader_syntax.rs b/crates/oxc_linter/src/rules/import/no_webpack_loader_syntax.rs index 1100ae680791d7..ca5e60f73c8eb5 100644 --- a/crates/oxc_linter/src/rules/import/no_webpack_loader_syntax.rs +++ b/crates/oxc_linter/src/rules/import/no_webpack_loader_syntax.rs @@ -10,11 +10,9 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_named_as_default_diagnostic(x0: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-import(no-webpack-loader-syntax): Unexpected `!` in `{x0}`." - )) - .with_help("Do not use import syntax to configure webpack loaders") - .with_label(span0) + OxcDiagnostic::warn(format!("Unexpected `!` in `{x0}`.")) + .with_help("Do not use import syntax to configure webpack loaders") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/consistent_test_it.rs b/crates/oxc_linter/src/rules/jest/consistent_test_it.rs index 60c272676575c4..25a13ec8580b01 100644 --- a/crates/oxc_linter/src/rules/jest/consistent_test_it.rs +++ b/crates/oxc_linter/src/rules/jest/consistent_test_it.rs @@ -11,30 +11,21 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_jest_fn_call, JestFnKind, - JestGeneralFnKind, ParsedJestFnCallNew, PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_jest_fn_call, JestFnKind, JestGeneralFnKind, + ParsedJestFnCallNew, PossibleJestNode, }, }; -fn consistent_method(x0: TestPluginName, x1: &str, x2: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "{x0}(consistent-test-it): Enforce `test` and `it` usage conventions", - )) - .with_help(format!("Prefer using {x1:?} instead of {x2:?}")) - .with_label(span0) +fn consistent_method(x1: &str, x2: &str, span0: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Enforce `test` and `it` usage conventions".to_string()) + .with_help(format!("Prefer using {x1:?} instead of {x2:?}")) + .with_label(span0) } -fn consistent_method_within_describe( - x0: TestPluginName, - x1: &str, - x2: &str, - span0: Span, -) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "{x0}(consistent-test-it): Enforce `test` and `it` usage conventions", - )) - .with_help(format!("Prefer using {x1:?} instead of {x2:?} within describe")) - .with_label(span0) +fn consistent_method_within_describe(x1: &str, x2: &str, span0: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Enforce `test` and `it` usage conventions".to_string()) + .with_help(format!("Prefer using {x1:?} instead of {x2:?} within describe")) + .with_label(span0) } #[derive(Debug, Clone, Eq, PartialEq)] @@ -201,13 +192,12 @@ impl Rule for ConsistentTestIt { } fn run_once(&self, ctx: &LintContext) { - let plugin_name = get_test_plugin_name(ctx); let mut describe_nesting_hash: FxHashMap = FxHashMap::default(); let mut possible_jest_nodes = collect_possible_jest_call_node(ctx); possible_jest_nodes.sort_by_key(|n| n.node.id()); for possible_jest_node in &possible_jest_nodes { - self.run(&mut describe_nesting_hash, plugin_name, possible_jest_node, ctx); + self.run(&mut describe_nesting_hash, possible_jest_node, ctx); } } } @@ -216,7 +206,6 @@ impl ConsistentTestIt { fn run<'a>( &self, describe_nesting_hash: &mut FxHashMap, - plugin_name: TestPluginName, possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>, ) { @@ -248,7 +237,7 @@ impl ConsistentTestIt { &fn_to_str, ) { ctx.diagnostic_with_fix( - consistent_method(plugin_name, &fn_to_str, &opposite_test_keyword, span), + consistent_method(&fn_to_str, &opposite_test_keyword, span), |fixer| fixer.replace(span, prefer_test_name), ); } @@ -268,7 +257,6 @@ impl ConsistentTestIt { ) { ctx.diagnostic_with_fix( consistent_method_within_describe( - plugin_name, &describe_to_str, &opposite_test_keyword, span, diff --git a/crates/oxc_linter/src/rules/jest/expect_expect.rs b/crates/oxc_linter/src/rules/jest/expect_expect.rs index f791f7a6100395..949375a0002d6d 100644 --- a/crates/oxc_linter/src/rules/jest/expect_expect.rs +++ b/crates/oxc_linter/src/rules/jest/expect_expect.rs @@ -13,13 +13,13 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_node_name, get_test_plugin_name, - is_type_of_jest_fn_call, JestFnKind, JestGeneralFnKind, PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, get_node_name, is_type_of_jest_fn_call, JestFnKind, + JestGeneralFnKind, PossibleJestNode, }, }; -fn expect_expect_diagnostic(x0: TestPluginName, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(expect-expect): Test has no assertions")) +fn expect_expect_diagnostic(span0: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Test has no assertions".to_string()) .with_help("Add assertion(s) in this Test") .with_label(span0) } @@ -122,7 +122,6 @@ fn run<'a>( ) { let node = possible_jest_node.node; if let AstKind::CallExpression(call_expr) = node.kind() { - let plugin_name = get_test_plugin_name(ctx); let name = get_node_name(&call_expr.callee); if is_type_of_jest_fn_call( call_expr, @@ -138,7 +137,7 @@ fn run<'a>( if property_name == "todo" { return; } - if property_name == "skip" && plugin_name.eq(&TestPluginName::Vitest) { + if property_name == "skip" && ctx.frameworks().is_vitest() { return; } } @@ -150,7 +149,7 @@ fn run<'a>( check_arguments(call_expr, &rule.assert_function_names, &mut visited, ctx); if !has_assert_function { - ctx.diagnostic(expect_expect_diagnostic(plugin_name, call_expr.callee.span())); + ctx.diagnostic(expect_expect_diagnostic(call_expr.callee.span())); } } } diff --git a/crates/oxc_linter/src/rules/jest/max_expects.rs b/crates/oxc_linter/src/rules/jest/max_expects.rs index a25640df59ba70..cea8f7ecff0c40 100644 --- a/crates/oxc_linter/src/rules/jest/max_expects.rs +++ b/crates/oxc_linter/src/rules/jest/max_expects.rs @@ -11,7 +11,7 @@ use crate::{ }; fn exceeded_max_assertion(x0: usize, x1: usize, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(max-expects): Enforces a maximum number assertion calls in a test body.") + OxcDiagnostic::warn("Enforces a maximum number assertion calls in a test body.") .with_help(format!("Too many assertion calls ({x0:?}) - maximum allowed is {x1:?}")) .with_label(span2) } diff --git a/crates/oxc_linter/src/rules/jest/max_nested_describe.rs b/crates/oxc_linter/src/rules/jest/max_nested_describe.rs index 0682e8fdfc85eb..562a3d28f137d5 100644 --- a/crates/oxc_linter/src/rules/jest/max_nested_describe.rs +++ b/crates/oxc_linter/src/rules/jest/max_nested_describe.rs @@ -14,11 +14,9 @@ use crate::{ }; fn exceeded_max_depth(current: usize, max: usize, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(max-nested-describe): Enforces a maximum depth to nested describe calls.", - ) - .with_help(format!("Too many nested describe calls ({current}) - maximum allowed is {max}")) - .with_label(span0) + OxcDiagnostic::warn("Enforces a maximum depth to nested describe calls.") + .with_help(format!("Too many nested describe calls ({current}) - maximum allowed is {max}")) + .with_label(span0) } #[derive(Debug, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_alias_methods.rs b/crates/oxc_linter/src/rules/jest/no_alias_methods.rs index 1b59f07bfc1a7c..a50a3b5954b1b6 100644 --- a/crates/oxc_linter/src/rules/jest/no_alias_methods.rs +++ b/crates/oxc_linter/src/rules/jest/no_alias_methods.rs @@ -6,19 +6,11 @@ use oxc_span::Span; use crate::{ context::LintContext, rule::Rule, - utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_expect_jest_fn_call, - PossibleJestNode, TestPluginName, - }, + utils::{collect_possible_jest_call_node, parse_expect_jest_fn_call, PossibleJestNode}, }; -fn no_alias_methods_diagnostic( - x0: TestPluginName, - x1: &str, - x2: &str, - span3: Span, -) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(no-alias-methods): Unexpected alias {x1:?}")) +fn no_alias_methods_diagnostic(x1: &str, x2: &str, span3: Span) -> OxcDiagnostic { + OxcDiagnostic::warn(format!("Unexpected alias {x1:?}")) .with_help(format!("Replace {x1:?} with its canonical name of {x2:?}")) .with_label(span3) } @@ -96,10 +88,8 @@ fn run<'a>(possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) span.end -= 1; } - let plugin_name = get_test_plugin_name(ctx); - ctx.diagnostic_with_fix( - no_alias_methods_diagnostic(plugin_name, name, canonical_name, matcher.span), + no_alias_methods_diagnostic(name, canonical_name, matcher.span), // || Fix::new(canonical_name, Span::new(start, end)), |fixer| fixer.replace(span, canonical_name), ); diff --git a/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs b/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs index 6be16fafeff452..4df3cd5ee323b7 100644 --- a/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs @@ -7,11 +7,9 @@ use regex::Regex; use crate::{context::LintContext, rule::Rule}; fn no_commented_out_tests_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-commented-out-tests): Some tests seem to be commented", - ) - .with_help("Remove or uncomment this comment") - .with_label(span0) + OxcDiagnostic::warn("Some tests seem to be commented") + .with_help("Remove or uncomment this comment") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs index 2ea0db2b927379..e07902bf66b19f 100644 --- a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs @@ -15,7 +15,7 @@ use crate::{ }; fn no_conditional_expect_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-conditional-expect): Unexpected conditional expect") + OxcDiagnostic::warn("Unexpected conditional expect") .with_help("Avoid calling `expect` conditionally`") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs index dcb26371ec757f..05880374caa19e 100644 --- a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs +++ b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs @@ -13,20 +13,17 @@ use crate::{ }; fn no_global_set_timeout_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-confusing-set-timeout)") - .with_help("`jest.setTimeout` should be call in `global` scope") - .with_label(span0) + OxcDiagnostic::warn("`jest.setTimeout` should be call in `global` scope").with_label(span0) } fn no_multiple_set_timeouts_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-confusing-set-timeout)") - .with_help("Do not call `jest.setTimeout` multiple times, as only the last call will have an effect") + OxcDiagnostic::warn("Do not call `jest.setTimeout` multiple times") + .with_help("Only the last call to `jest.setTimeout` will have an effect.") .with_label(span0) } fn no_unorder_set_timeout_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-confusing-set-timeout)") - .with_help("`jest.setTimeout` should be placed before any other jest methods") + OxcDiagnostic::warn("`jest.setTimeout` should be placed before any other jest methods") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/no_deprecated_functions.rs b/crates/oxc_linter/src/rules/jest/no_deprecated_functions.rs index a93596fa4ea832..df238dd87bce7d 100644 --- a/crates/oxc_linter/src/rules/jest/no_deprecated_functions.rs +++ b/crates/oxc_linter/src/rules/jest/no_deprecated_functions.rs @@ -9,11 +9,9 @@ use phf::{phf_map, Map}; use crate::{context::LintContext, rule::Rule}; fn deprecated_function(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-deprecated-functions): Disallow use of deprecated functions", - ) - .with_help(format!("{x0:?} has been deprecated in favor of {x1:?}")) - .with_label(span2) + OxcDiagnostic::warn("Disallow use of deprecated functions") + .with_help(format!("{x0:?} has been deprecated in favor of {x1:?}")) + .with_label(span2) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs b/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs index 9aec9bb5e398e4..46612cd4163861 100644 --- a/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs @@ -7,8 +7,8 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_general_jest_fn_call, - JestFnKind, JestGeneralFnKind, ParsedGeneralJestFnCall, PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_general_jest_fn_call, JestFnKind, JestGeneralFnKind, + ParsedGeneralJestFnCall, PossibleJestNode, }, }; @@ -63,15 +63,8 @@ declare_oxc_lint!( correctness ); -fn no_disabled_tests_diagnostic( - x0: TestPluginName, - x1: &str, - x2: &str, - span3: Span, -) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(no-disabled-tests): {x1:?}")) - .with_help(format!("{x2:?}")) - .with_label(span3) +fn no_disabled_tests_diagnostic(x1: &'static str, x2: &'static str, span3: Span) -> OxcDiagnostic { + OxcDiagnostic::warn(x1).with_help(x2).with_label(span3) } enum Message { @@ -98,19 +91,13 @@ impl Message { impl Rule for NoDisabledTests { fn run_once(&self, ctx: &LintContext) { - let plugin_name = get_test_plugin_name(ctx); - for possible_jest_node in &collect_possible_jest_call_node(ctx) { - run(possible_jest_node, plugin_name, ctx); + run(possible_jest_node, ctx); } } } -fn run<'a>( - possible_jest_node: &PossibleJestNode<'a, '_>, - plugin_name: TestPluginName, - ctx: &LintContext<'a>, -) { +fn run<'a>(possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) { let node = possible_jest_node.node; if let AstKind::CallExpression(call_expr) = node.kind() { if let Some(jest_fn_call) = parse_general_jest_fn_call(call_expr, possible_jest_node, ctx) { @@ -125,12 +112,7 @@ fn run<'a>( && members.iter().all(|member| member.is_name_unequal("todo")) { let (error, help) = Message::MissingFunction.details(); - ctx.diagnostic(no_disabled_tests_diagnostic( - plugin_name, - error, - help, - call_expr.span, - )); + ctx.diagnostic(no_disabled_tests_diagnostic(error, help, call_expr.span)); return; } @@ -142,12 +124,7 @@ fn run<'a>( } else { Message::DisabledTestWithX.details() }; - ctx.diagnostic(no_disabled_tests_diagnostic( - plugin_name, - error, - help, - call_expr.callee.span(), - )); + ctx.diagnostic(no_disabled_tests_diagnostic(error, help, call_expr.callee.span())); return; } @@ -159,12 +136,7 @@ fn run<'a>( } else { Message::DisabledTestWithSkip.details() }; - ctx.diagnostic(no_disabled_tests_diagnostic( - plugin_name, - error, - help, - call_expr.callee.span(), - )); + ctx.diagnostic(no_disabled_tests_diagnostic(error, help, call_expr.callee.span())); } } else if let Expression::Identifier(ident) = &call_expr.callee { if ident.name.as_str() == "pending" @@ -172,12 +144,7 @@ fn run<'a>( { // `describe('foo', function () { pending() })` let (error, help) = Message::Pending.details(); - ctx.diagnostic(no_disabled_tests_diagnostic( - plugin_name, - error, - help, - call_expr.span, - )); + ctx.diagnostic(no_disabled_tests_diagnostic(error, help, call_expr.span)); } } } diff --git a/crates/oxc_linter/src/rules/jest/no_done_callback.rs b/crates/oxc_linter/src/rules/jest/no_done_callback.rs index b8ea6e1d40a65e..727ccac000aeb0 100644 --- a/crates/oxc_linter/src/rules/jest/no_done_callback.rs +++ b/crates/oxc_linter/src/rules/jest/no_done_callback.rs @@ -16,19 +16,15 @@ use crate::{ }; fn no_done_callback(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-done-callback): Function parameter(s) use the `done` argument", - ) - .with_help("Return a Promise instead of relying on callback parameter") - .with_label(span0) + OxcDiagnostic::warn("Function parameter(s) use the `done` argument") + .with_help("Return a Promise instead of relying on callback parameter") + .with_label(span0) } fn use_await_instead_of_callback(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-done-callback): Function parameter(s) use the `done` argument", - ) - .with_help("Use await instead of callback in async functions") - .with_label(span0) + OxcDiagnostic::warn("Function parameter(s) use the `done` argument") + .with_help("Use await instead of callback in async functions") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs b/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs index 73dd9de3d3290b..0e2ea3e57fa2f9 100644 --- a/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs +++ b/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs @@ -16,11 +16,9 @@ use crate::{ }; fn no_duplicate_hooks_diagnostic(x0: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-duplicate-hooks): Disallow duplicate setup and teardown hooks.", - ) - .with_help(format!("Duplicate {x0:?} in describe block.")) - .with_label(span0) + OxcDiagnostic::warn("Disallow duplicate setup and teardown hooks.") + .with_help(format!("Duplicate {x0:?} in describe block.")) + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_export.rs b/crates/oxc_linter/src/rules/jest/no_export.rs index 3a8f1738dfd36a..d65b306389c628 100644 --- a/crates/oxc_linter/src/rules/jest/no_export.rs +++ b/crates/oxc_linter/src/rules/jest/no_export.rs @@ -5,7 +5,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, utils::is_jest_file}; fn no_export_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-export): Do not export from a test file.") + OxcDiagnostic::warn("Do not export from a test file.") .with_help("If you want to share code between tests, move it into a separate file and import it from there.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/no_focused_tests.rs b/crates/oxc_linter/src/rules/jest/no_focused_tests.rs index 1acbc1ae7ff561..e7a1b852154d9b 100644 --- a/crates/oxc_linter/src/rules/jest/no_focused_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_focused_tests.rs @@ -7,24 +7,15 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_general_jest_fn_call, - JestFnKind, JestGeneralFnKind, MemberExpressionElement, ParsedGeneralJestFnCall, - PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_general_jest_fn_call, JestFnKind, JestGeneralFnKind, + MemberExpressionElement, ParsedGeneralJestFnCall, PossibleJestNode, }, }; -fn no_focused_tests_diagnostic(span0: Span, x1: TestPluginName) -> OxcDiagnostic { - match x1 { - TestPluginName::Jest => { - OxcDiagnostic::warn(format!("{x1}(no-focused-tests): Unexpected focused test.")) - .with_help("Remove focus from test.") - .with_label(span0) - } - TestPluginName::Vitest => { - OxcDiagnostic::warn(format!("{x1}(no-focused-tests): Focused tests are not allowed.")) - .with_label(span0) - } - } +fn no_focused_tests_diagnostic(span0: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Unexpected focused test.") + .with_help("Remove focus from test.") + .with_label(span0) } #[derive(Debug, Default, Clone)] @@ -75,18 +66,13 @@ declare_oxc_lint!( impl Rule for NoFocusedTests { fn run_once(&self, ctx: &LintContext) { - let plugin_name = get_test_plugin_name(ctx); for node in &collect_possible_jest_call_node(ctx) { - run(node, plugin_name, ctx); + run(node, ctx); } } } -fn run<'a>( - possible_jest_node: &PossibleJestNode<'a, '_>, - plugin_name: TestPluginName, - ctx: &LintContext<'a>, -) { +fn run<'a>(possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) { let node = possible_jest_node.node; let AstKind::CallExpression(call_expr) = node.kind() else { return; @@ -101,13 +87,10 @@ fn run<'a>( if name.starts_with('f') { ctx.diagnostic_with_fix( - no_focused_tests_diagnostic( - Span::new( - call_expr.span.start, - call_expr.span.start + u32::try_from(name.len()).unwrap_or(1), - ), - plugin_name, - ), + no_focused_tests_diagnostic(Span::new( + call_expr.span.start, + call_expr.span.start + u32::try_from(name.len()).unwrap_or(1), + )), |fixer| fixer.delete_range(Span::sized(call_expr.span.start, 1)), ); @@ -116,16 +99,13 @@ fn run<'a>( let only_node = members.iter().find(|member| member.is_name_equal("only")); if let Some(only_node) = only_node { - ctx.diagnostic_with_fix( - no_focused_tests_diagnostic(only_node.span, plugin_name), - |fixer| { - let mut span = only_node.span.expand_left(1); - if !matches!(only_node.element, MemberExpressionElement::IdentName(_)) { - span = span.expand_right(1); - } - fixer.delete_range(span) - }, - ); + ctx.diagnostic_with_fix(no_focused_tests_diagnostic(only_node.span), |fixer| { + let mut span = only_node.span.expand_left(1); + if !matches!(only_node.element, MemberExpressionElement::IdentName(_)) { + span = span.expand_right(1); + } + fixer.delete_range(span) + }); } } diff --git a/crates/oxc_linter/src/rules/jest/no_hooks.rs b/crates/oxc_linter/src/rules/jest/no_hooks.rs index ba0cb0f2188605..177494cc2dac8b 100644 --- a/crates/oxc_linter/src/rules/jest/no_hooks.rs +++ b/crates/oxc_linter/src/rules/jest/no_hooks.rs @@ -13,8 +13,7 @@ use crate::{ }; fn unexpected_hook_diagonsitc(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-hooks): Disallow setup and teardown hooks.") - .with_label(span0) + OxcDiagnostic::warn("Disallow setup and teardown hooks.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_identical_title.rs b/crates/oxc_linter/src/rules/jest/no_identical_title.rs index e6c29ff34d4d87..be024a22b4bad0 100644 --- a/crates/oxc_linter/src/rules/jest/no_identical_title.rs +++ b/crates/oxc_linter/src/rules/jest/no_identical_title.rs @@ -20,13 +20,15 @@ use crate::{ }; fn describe_repeat(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-identical-title): Describe block title is used multiple times in the same describe block.") + OxcDiagnostic::warn("Describe block title is used multiple times in the same describe block.") .with_help("Change the title of describe block.") .with_label(span0) } fn test_repeat(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-identical-title): Test title is used multiple times in the same describe block.").with_help("Change the title of test.").with_label(span0) + OxcDiagnostic::warn("Test title is used multiple times in the same describe block.") + .with_help("Change the title of test.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs b/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs index b435932a4dc1d7..8acf1d1d6d2585 100644 --- a/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs +++ b/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs @@ -10,7 +10,7 @@ use crate::{ }; fn no_interpolation_in_snapshots_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-interpolation-in-snapshots): Do not use string interpolation inside of snapshots") + OxcDiagnostic::warn("Do not use string interpolation inside of snapshots") .with_help("Remove string interpolation from snapshots") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs index e0f73bf31d0688..eb9361edaa61e8 100644 --- a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs +++ b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs @@ -11,9 +11,7 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule}; fn no_jasmine_globals_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-jest(no-jasmine-globals): {x0:?}")) - .with_help(format!("{x1:?}")) - .with_label(span2) + OxcDiagnostic::warn(format!("{x0:?}")).with_help(format!("{x1:?}")).with_label(span2) } /// diff --git a/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs b/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs index 1855bf5d330595..3d117e1863f3d0 100644 --- a/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs +++ b/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs @@ -17,13 +17,13 @@ use crate::{ }; fn no_snapshot(x0: usize, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-large-snapshots): Disallow large snapshots.") + OxcDiagnostic::warn("Disallow large snapshots.") .with_help(format!("`{x0:?}`s should begin with lowercase")) .with_label(span0) } fn too_long_snapshots(x0: usize, x1: usize, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-large-snapshots): Disallow large snapshots.") + OxcDiagnostic::warn("Disallow large snapshots.") .with_help(format!( "Expected Jest snapshot to be smaller than {x0:?} lines but was {x1:?} lines long" )) diff --git a/crates/oxc_linter/src/rules/jest/no_mocks_import.rs b/crates/oxc_linter/src/rules/jest/no_mocks_import.rs index a27e4fb7250207..1a971fea727023 100644 --- a/crates/oxc_linter/src/rules/jest/no_mocks_import.rs +++ b/crates/oxc_linter/src/rules/jest/no_mocks_import.rs @@ -8,7 +8,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule}; fn no_mocks_import_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-mocks-import): Mocks should not be manually imported from a `__mocks__` directory.") + OxcDiagnostic::warn("Mocks should not be manually imported from a `__mocks__` directory.") .with_help("Instead use `jest.mock` and import from the original module path.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs b/crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs index c61d22aa3530d5..82e32feac5dd91 100644 --- a/crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs +++ b/crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs @@ -14,19 +14,15 @@ use crate::{ }; fn restricted_jest_method(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-restricted-jest-methods): Disallow specific `jest.` methods", - ) - .with_help(format!("Use of `{x0:?}` is disallowed")) - .with_label(span1) + OxcDiagnostic::warn("Disallow specific `jest.` methods") + .with_help(format!("Use of `{x0:?}` is disallowed")) + .with_label(span1) } fn restricted_jest_method_with_message(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-restricted-jest-methods): Disallow specific `jest.` methods", - ) - .with_help(format!("{x0:?}")) - .with_label(span1) + OxcDiagnostic::warn("Disallow specific `jest.` methods") + .with_help(format!("{x0:?}")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs b/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs index 54bdd54a84d8fb..893478c7c40d73 100644 --- a/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs +++ b/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs @@ -17,19 +17,15 @@ use crate::{ }; fn restricted_chain(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-restricted-matchers): Disallow specific matchers & modifiers", - ) - .with_help(format!("Use of `{x0:?}` is disallowed`")) - .with_label(span1) + OxcDiagnostic::warn("Disallow specific matchers & modifiers") + .with_help(format!("Use of `{x0:?}` is disallowed`")) + .with_label(span1) } fn restricted_chain_with_message(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-restricted-matchers): Disallow specific matchers & modifiers", - ) - .with_help(format!("{x0:?}")) - .with_label(span1) + OxcDiagnostic::warn("Disallow specific matchers & modifiers") + .with_help(format!("{x0:?}")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs index 9496968e9a945d..800ca9c847e842 100644 --- a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs @@ -18,11 +18,9 @@ use crate::{ }; fn no_standalone_expect_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-standalone-expect): Expect must be inside of a test block.", - ) - .with_help("Did you forget to wrap `expect` in a `test` or `it` block?") - .with_label(span0) + OxcDiagnostic::warn("Expect must be inside of a test block.") + .with_help("Did you forget to wrap `expect` in a `test` or `it` block?") + .with_label(span0) } /// diff --git a/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs b/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs index cb9247131954a1..433b9e2a93891d 100644 --- a/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs +++ b/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs @@ -7,14 +7,13 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_general_jest_fn_call, - JestGeneralFnKind, KnownMemberExpressionProperty, ParsedGeneralJestFnCall, - PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_general_jest_fn_call, JestGeneralFnKind, + KnownMemberExpressionProperty, ParsedGeneralJestFnCall, PossibleJestNode, }, }; -fn no_test_prefixes_diagnostic(x0: TestPluginName, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(no-test-prefixes): Use {x1:?} instead.")).with_label(span2) +fn no_test_prefixes_diagnostic(x1: &str, span2: Span) -> OxcDiagnostic { + OxcDiagnostic::warn(format!("Use {x1:?} instead.")).with_label(span2) } #[derive(Debug, Default, Clone)] @@ -95,12 +94,10 @@ fn run<'a>(possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) }; let preferred_node_name = get_preferred_node_names(&jest_fn_call); - let plugin_name = get_test_plugin_name(ctx); - ctx.diagnostic_with_fix( - no_test_prefixes_diagnostic(plugin_name, &preferred_node_name, span), - |fixer| fixer.replace(span, preferred_node_name), - ); + ctx.diagnostic_with_fix(no_test_prefixes_diagnostic(&preferred_node_name, span), |fixer| { + fixer.replace(span, preferred_node_name) + }); } fn get_preferred_node_names(jest_fn_call: &ParsedGeneralJestFnCall) -> String { diff --git a/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs b/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs index faae4823a0f61b..e76130faf92356 100644 --- a/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs +++ b/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs @@ -15,10 +15,7 @@ use crate::{ }; fn no_test_return_statement_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value", - ) - .with_label(span0) + OxcDiagnostic::warn("Jest tests should not return a value").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_untyped_mock_factory.rs b/crates/oxc_linter/src/rules/jest/no_untyped_mock_factory.rs index c8ac2398e754c5..bf7e98a73ce1a7 100644 --- a/crates/oxc_linter/src/rules/jest/no_untyped_mock_factory.rs +++ b/crates/oxc_linter/src/rules/jest/no_untyped_mock_factory.rs @@ -13,9 +13,11 @@ use crate::{ }; fn add_type_parameter_to_module_mock_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(no-untyped-mock-factory): Disallow using `jest.mock()` factories without an explicit type parameter.") - .with_help(format!("Add a type parameter to the mock factory such as `typeof import({x0:?})`")) - .with_label(span1) + OxcDiagnostic::warn( + "Disallow using `jest.mock()` factories without an explicit type parameter.", + ) + .with_help(format!("Add a type parameter to the mock factory such as `typeof import({x0:?})`")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_called_with.rs b/crates/oxc_linter/src/rules/jest/prefer_called_with.rs index 33497460cb9caa..047c7f07ac7799 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_called_with.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_called_with.rs @@ -10,13 +10,13 @@ use crate::{ }; fn use_to_be_called_with(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-called-with): Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`.") + OxcDiagnostic::warn("Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`.") .with_help("Prefer toBeCalledWith(/* expected args */)") .with_label(span0) } fn use_have_been_called_with(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-called-with): Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`.") + OxcDiagnostic::warn("Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`.") .with_help("Prefer toHaveBeenCalledWith(/* expected args */)") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_comparison_matcher.rs b/crates/oxc_linter/src/rules/jest/prefer_comparison_matcher.rs index 78178f857ea82b..3d0a5b74b1c13e 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_comparison_matcher.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_comparison_matcher.rs @@ -18,7 +18,7 @@ use crate::{ }; fn use_to_be_comparison(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-comparison-matcher): Suggest using the built-in comparison matchers") + OxcDiagnostic::warn("Suggest using the built-in comparison matchers") .with_help(format!("Prefer using `{x0:?}` instead")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_equality_matcher.rs b/crates/oxc_linter/src/rules/jest/prefer_equality_matcher.rs index 8da97aceba2906..6f16fcb67c3df2 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_equality_matcher.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_equality_matcher.rs @@ -14,7 +14,7 @@ use crate::{ }; fn use_equality_matcher_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-equality-matcher): Suggest using the built-in equality matchers.") + OxcDiagnostic::warn("Suggest using the built-in equality matchers.") .with_help("Prefer using one of the equality matchers instead") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_expect_resolves.rs b/crates/oxc_linter/src/rules/jest/prefer_expect_resolves.rs index be9c781522907e..ac3582842dd834 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_expect_resolves.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_expect_resolves.rs @@ -17,7 +17,7 @@ use crate::{ }; fn expect_resolves(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-expect-resolves): Prefer `await expect(...).resolves` over `expect(await ...)` syntax.") + OxcDiagnostic::warn("Prefer `await expect(...).resolves` over `expect(await ...)` syntax.") .with_help("Use `await expect(...).resolves` instead") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_hooks_in_order.rs b/crates/oxc_linter/src/rules/jest/prefer_hooks_in_order.rs index a983a2f7955924..d91946f233b1d3 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_hooks_in_order.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_hooks_in_order.rs @@ -9,17 +9,14 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - get_test_plugin_name, parse_jest_fn_call, JestFnKind, JestGeneralFnKind, - ParsedJestFnCallNew, PossibleJestNode, TestPluginName, + parse_jest_fn_call, JestFnKind, JestGeneralFnKind, ParsedJestFnCallNew, PossibleJestNode, }, }; -fn reorder_hooks(x0: TestPluginName, x1: &str, x2: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "{x0}(prefer-hooks-in-order): Prefer having hooks in a consistent order.", - )) - .with_help(format!("{x1:?} hooks should be before any {x2:?} hooks")) - .with_label(span0) +fn reorder_hooks(x1: &str, x2: &str, span0: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Prefer having hooks in a consistent order.") + .with_help(format!("{x1:?} hooks should be before any {x2:?} hooks")) + .with_label(span0) } #[derive(Debug, Default, Clone)] @@ -191,14 +188,8 @@ impl PreferHooksInOrder { let Some(previous_hook_name) = hook_orders.get(previous_hook_pos) else { return; }; - let plugin_name = get_test_plugin_name(ctx); - - ctx.diagnostic(reorder_hooks( - plugin_name, - &hook_name, - previous_hook_name, - call_expr.span, - )); + + ctx.diagnostic(reorder_hooks(&hook_name, previous_hook_name, call_expr.span)); return; } diff --git a/crates/oxc_linter/src/rules/jest/prefer_hooks_on_top.rs b/crates/oxc_linter/src/rules/jest/prefer_hooks_on_top.rs index e395935d7bd460..c2bd385264ff76 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_hooks_on_top.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_hooks_on_top.rs @@ -16,11 +16,9 @@ use crate::{ }; fn no_hook_on_top(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(prefer-hooks-on-top): Suggest having hooks before any test cases.", - ) - .with_help("Hooks should come before test cases") - .with_label(span0) + OxcDiagnostic::warn("Suggest having hooks before any test cases.") + .with_help("Hooks should come before test cases") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs b/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs index e0e2fbc4cb25af..3822be1036ed21 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs @@ -10,11 +10,9 @@ use phf::{phf_set, Set}; use crate::{context::LintContext, rule::Rule, AstNode}; fn use_jest_mocked(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(prefer-jest-mocked): Prefer `jest.mocked()` over `fn as jest.Mock`.", - ) - .with_help("Prefer `jest.mocked()`") - .with_label(span0) + OxcDiagnostic::warn("Prefer `jest.mocked()` over `fn as jest.Mock`.") + .with_help("Prefer `jest.mocked()`") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_lowercase_title.rs b/crates/oxc_linter/src/rules/jest/prefer_lowercase_title.rs index 0eeb1f45c5c4be..756b722f394a49 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_lowercase_title.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_lowercase_title.rs @@ -13,7 +13,7 @@ use crate::{ }; fn unexpected_lowercase(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-lowercase-title): Enforce lowercase test names") + OxcDiagnostic::warn("Enforce lowercase test names") .with_help(format!("`{x0:?}`s should begin with lowercase")) .with_label(span1) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_mock_promise_shorthand.rs b/crates/oxc_linter/src/rules/jest/prefer_mock_promise_shorthand.rs index 296b040431035a..4f62a552e1dbaf 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_mock_promise_shorthand.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_mock_promise_shorthand.rs @@ -9,7 +9,9 @@ use oxc_span::{Atom, Span}; use crate::{context::LintContext, fixer::RuleFixer, rule::Rule, utils::get_node_name}; fn use_mock_shorthand(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-mock-promise-shorthand): Prefer mock resolved/rejected shorthands for promises").with_help(format!("Prefer {x0:?}")).with_label(span1) + OxcDiagnostic::warn("Prefer mock resolved/rejected shorthands for promises") + .with_help(format!("Prefer {x0:?}")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_spy_on.rs b/crates/oxc_linter/src/rules/jest/prefer_spy_on.rs index f0e126d38c6ad2..c1a81a759c3595 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_spy_on.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_spy_on.rs @@ -18,7 +18,7 @@ use crate::{ }; fn use_jest_spy_on(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-spy-on): Suggest using `jest.spyOn()`.") + OxcDiagnostic::warn("Suggest using `jest.spyOn()`.") .with_help("Use jest.spyOn() instead") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_strict_equal.rs b/crates/oxc_linter/src/rules/jest/prefer_strict_equal.rs index b7546f719ac98c..44e087c9444321 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_strict_equal.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_strict_equal.rs @@ -10,7 +10,7 @@ use crate::{ }; fn use_to_strict_equal(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-strict-equal): Suggest using `toStrictEqual()`.") + OxcDiagnostic::warn("Suggest using `toStrictEqual()`.") .with_help("Use `toStrictEqual()` instead") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jest/prefer_to_be.rs b/crates/oxc_linter/src/rules/jest/prefer_to_be.rs index 14d2e4c0bcf62f..c21c3b7438d607 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_to_be.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_to_be.rs @@ -16,30 +16,23 @@ use crate::{ }; fn use_to_be(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(prefer-to-be): Use `toBe` when expecting primitive literals.", - ) - .with_label(span0) + OxcDiagnostic::warn("Use `toBe` when expecting primitive literals.").with_label(span0) } fn use_to_be_undefined(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-to-be): Use `toBeUndefined` instead.") - .with_label(span0) + OxcDiagnostic::warn("Use `toBeUndefined` instead.").with_label(span0) } fn use_to_be_defined(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-to-be): Use `toBeDefined` instead.") - .with_label(span0) + OxcDiagnostic::warn("Use `toBeDefined` instead.").with_label(span0) } fn use_to_be_null(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-to-be): Use `toBeNull` instead.") - .with_label(span0) + OxcDiagnostic::warn("Use `toBeNull` instead.").with_label(span0) } fn use_to_be_na_n(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-to-be): Use `toBeNaN` instead.") - .with_label(span0) + OxcDiagnostic::warn("Use `toBeNaN` instead.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_to_contain.rs b/crates/oxc_linter/src/rules/jest/prefer_to_contain.rs index 3da01d40c1ac11..df42a037686925 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_to_contain.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_to_contain.rs @@ -16,8 +16,7 @@ use crate::{ }; fn use_to_contain(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-to-contain): Suggest using `toContain()`.") - .with_label(span0) + OxcDiagnostic::warn("Suggest using `toContain()`.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_to_have_length.rs b/crates/oxc_linter/src/rules/jest/prefer_to_have_length.rs index 91698f620eb7a7..62989af72c0813 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_to_have_length.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_to_have_length.rs @@ -17,10 +17,7 @@ use crate::{ }; fn use_to_have_length(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(prefer-to-have-length): Suggest using `toHaveLength()`.", - ) - .with_label(span0) + OxcDiagnostic::warn("Suggest using `toHaveLength()`.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/prefer_todo.rs b/crates/oxc_linter/src/rules/jest/prefer_todo.rs index 01c7824b72f6c1..7b8b18369e350d 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_todo.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_todo.rs @@ -17,13 +17,11 @@ use crate::{ }; fn empty_test(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-todo): Suggest using `test.todo`.") - .with_label(span0) + OxcDiagnostic::warn("Suggest using `test.todo`.").with_label(span0) } fn un_implemented_test_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jest(prefer-todo): Suggest using `test.todo`.") - .with_label(span0) + OxcDiagnostic::warn("Suggest using `test.todo`.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/require_hook.rs b/crates/oxc_linter/src/rules/jest/require_hook.rs index cd63e678c4ea29..ed60cdc09f7609 100644 --- a/crates/oxc_linter/src/rules/jest/require_hook.rs +++ b/crates/oxc_linter/src/rules/jest/require_hook.rs @@ -18,11 +18,9 @@ use crate::{ }; fn use_hook(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(require-hook): Require setup and teardown code to be within a hook.", - ) - .with_help("This should be done within a hook") - .with_label(span0) + OxcDiagnostic::warn("Require setup and teardown code to be within a hook.") + .with_help("This should be done within a hook") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/require_to_throw_message.rs b/crates/oxc_linter/src/rules/jest/require_to_throw_message.rs index 6085b204ca8e3f..9499d819531dec 100644 --- a/crates/oxc_linter/src/rules/jest/require_to_throw_message.rs +++ b/crates/oxc_linter/src/rules/jest/require_to_throw_message.rs @@ -10,11 +10,9 @@ use crate::{ }; fn require_to_throw_message_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!( - "eslint-plugin-jest(require-to-throw-message): Require a message for {x0:?}." - )) - .with_help(format!("Add an error message to {x0:?}")) - .with_label(span1) + OxcDiagnostic::warn(format!("Require a message for {x0:?}.")) + .with_help(format!("Add an error message to {x0:?}")) + .with_label(span1) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/require_top_level_describe.rs b/crates/oxc_linter/src/rules/jest/require_top_level_describe.rs index d4d20f830ec257..612aaacd9bb6e0 100644 --- a/crates/oxc_linter/src/rules/jest/require_top_level_describe.rs +++ b/crates/oxc_linter/src/rules/jest/require_top_level_describe.rs @@ -16,27 +16,23 @@ use crate::{ }; fn too_many_describes(max: usize, repeat: &str, span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(require-top-level-describe): Require test cases and hooks to be inside a `describe` block", - ) - .with_help(format!("There should not be more than {max:?} describe{repeat} at the top level.")) - .with_label(span0) + OxcDiagnostic::warn("Require test cases and hooks to be inside a `describe` block") + .with_help(format!( + "There should not be more than {max:?} describe{repeat} at the top level." + )) + .with_label(span0) } fn unexpected_test_case(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(require-top-level-describe): Require test cases and hooks to be inside a `describe` block", - ) - .with_help("All test cases must be wrapped in a describe block.") - .with_label(span0) + OxcDiagnostic::warn("Require test cases and hooks to be inside a `describe` block") + .with_help("All test cases must be wrapped in a describe block.") + .with_label(span0) } fn unexpected_hook(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jest(require-top-level-describe): Require test cases and hooks to be inside a `describe` block", - ) - .with_help("All hooks must be wrapped in a describe block.") - .with_label(span0) + OxcDiagnostic::warn("Require test cases and hooks to be inside a `describe` block") + .with_help("All hooks must be wrapped in a describe block.") + .with_label(span0) } #[derive(Debug, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs b/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs index 80abd7c39ce84a..d8a91f22f47d07 100644 --- a/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs +++ b/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs @@ -10,20 +10,17 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_general_jest_fn_call, - JestFnKind, JestGeneralFnKind, PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_general_jest_fn_call, JestFnKind, JestGeneralFnKind, + PossibleJestNode, }, }; fn valid_describe_callback_diagnostic( - x0: TestPluginName, - x1: &str, - x2: &str, + x1: &'static str, + x2: &'static str, span3: Span, ) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(valid-describe-callback): {x1:?}")) - .with_help(format!("{x2:?}")) - .with_label(span3) + OxcDiagnostic::warn(x1).with_help(x2).with_label(span3) } #[derive(Debug, Default, Clone)] @@ -167,8 +164,7 @@ fn find_first_return_stmt_span(function_body: &FunctionBody) -> Option { fn diagnostic(ctx: &LintContext, span: Span, message: Message) { let (error, help) = message.details(); - let plugin_name = get_test_plugin_name(ctx); - ctx.diagnostic(valid_describe_callback_diagnostic(plugin_name, error, help, span)); + ctx.diagnostic(valid_describe_callback_diagnostic(error, help, span)); } #[derive(Clone, Copy)] diff --git a/crates/oxc_linter/src/rules/jest/valid_expect.rs b/crates/oxc_linter/src/rules/jest/valid_expect.rs index a4ba8be46ada09..711a6e7cab513a 100644 --- a/crates/oxc_linter/src/rules/jest/valid_expect.rs +++ b/crates/oxc_linter/src/rules/jest/valid_expect.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use oxc_ast::{ ast::{Expression, MemberExpression}, AstKind, @@ -10,16 +12,17 @@ use crate::{ context::LintContext, rule::Rule, utils::{ - collect_possible_jest_call_node, get_test_plugin_name, parse_expect_jest_fn_call, - ExpectError, PossibleJestNode, TestPluginName, + collect_possible_jest_call_node, parse_expect_jest_fn_call, ExpectError, PossibleJestNode, }, AstNode, }; -fn valid_expect_diagnostic(x0: TestPluginName, x1: &str, x2: &str, span3: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("{x0}(valid-expect): {x1:?}")) - .with_help(format!("{x2:?}")) - .with_label(span3) +fn valid_expect_diagnostic>>( + x1: S, + x2: &'static str, + span3: Span, +) -> OxcDiagnostic { + OxcDiagnostic::warn(x1).with_help(x2).with_label(span3) } #[derive(Debug, Default, Clone)] @@ -121,7 +124,6 @@ impl Rule for ValidExpect { impl ValidExpect { fn run<'a>(&self, possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) { - let plugin_name = get_test_plugin_name(ctx); let node = possible_jest_node.node; let AstKind::CallExpression(call_expr) = node.kind() else { return; @@ -137,17 +139,17 @@ impl ValidExpect { match jest_fn_call.expect_error { Some(ExpectError::MatcherNotFound) => { let (error, help) = Message::MatcherNotFound.details(); - ctx.diagnostic(valid_expect_diagnostic(plugin_name, error, help, reporting_span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, reporting_span)); return; } Some(ExpectError::MatcherNotCalled) => { let (error, help) = Message::MatcherNotCalled.details(); - ctx.diagnostic(valid_expect_diagnostic(plugin_name, error, help, reporting_span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, reporting_span)); return; } Some(ExpectError::ModifierUnknown) => { let (error, help) = Message::ModifierUnknown.details(); - ctx.diagnostic(valid_expect_diagnostic(plugin_name, error, help, reporting_span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, reporting_span)); return; } None => {} @@ -164,7 +166,7 @@ impl ValidExpect { if self.min_args > 1 { "s" } else { "" } ); let help = "Remove the extra arguments."; - ctx.diagnostic(valid_expect_diagnostic(plugin_name, &error, help, call_expr.span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, call_expr.span)); return; } if call_expr.arguments.len() > self.max_args { @@ -174,7 +176,7 @@ impl ValidExpect { if self.max_args > 1 { "s" } else { "" } ); let help = "Add the missing arguments."; - ctx.diagnostic(valid_expect_diagnostic(plugin_name, &error, help, call_expr.span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, call_expr.span)); return; } @@ -222,7 +224,7 @@ impl ValidExpect { span = call_expr.span; Message::PromisesWithAsyncAssertionsMustBeAwaited.details() }; - ctx.diagnostic(valid_expect_diagnostic(plugin_name, error, help, span)); + ctx.diagnostic(valid_expect_diagnostic(error, help, span)); } } } diff --git a/crates/oxc_linter/src/rules/jest/valid_title.rs b/crates/oxc_linter/src/rules/jest/valid_title.rs index 8e8e8f48f22af9..6e812f4a50a145 100644 --- a/crates/oxc_linter/src/rules/jest/valid_title.rs +++ b/crates/oxc_linter/src/rules/jest/valid_title.rs @@ -19,9 +19,7 @@ use crate::{ }; fn valid_title_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-jest(valid-title): {x0:?}")) - .with_help(format!("{x1:?}")) - .with_label(span2) + OxcDiagnostic::warn(format!("{x0:?}")).with_help(format!("{x1:?}")).with_label(span2) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/check_access.rs b/crates/oxc_linter/src/rules/jsdoc/check_access.rs index 562ff00447c8d4..1287b1582b540e 100644 --- a/crates/oxc_linter/src/rules/jsdoc/check_access.rs +++ b/crates/oxc_linter/src/rules/jsdoc/check_access.rs @@ -7,17 +7,17 @@ use rustc_hash::FxHashSet; use crate::{context::LintContext, rule::Rule, utils::should_ignore_as_internal}; fn invalid_access_level(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(check-access): Invalid access level is specified or missing.", - ) - .with_help("Valid access levels are `package`, `private`, `protected`, and `public`.") - .with_label(span0) + OxcDiagnostic::warn("Invalid access level is specified or missing.") + .with_help("Valid access levels are `package`, `private`, `protected`, and `public`.") + .with_label(span0) } fn redundant_access_tags(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(check-access): Mixing of @access with @public, @private, @protected, or @package on the same doc block.") - .with_help("There should be only one instance of access tag in a JSDoc comment.") - .with_label(span0) + OxcDiagnostic::warn( + "Mixing of @access with @public, @private, @protected, or @package on the same doc block.", + ) + .with_help("There should be only one instance of access tag in a JSDoc comment.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/check_property_names.rs b/crates/oxc_linter/src/rules/jsdoc/check_property_names.rs index eebd8427903212..98cc62beff657b 100644 --- a/crates/oxc_linter/src/rules/jsdoc/check_property_names.rs +++ b/crates/oxc_linter/src/rules/jsdoc/check_property_names.rs @@ -10,11 +10,9 @@ use crate::{ }; fn no_root(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(check-property-names): No root defined for @property path.", - ) - .with_help(format!("@property path declaration `{x1}` appears before any real property.")) - .with_label(span0) + OxcDiagnostic::warn("No root defined for @property path.") + .with_help(format!("@property path declaration `{x1}` appears before any real property.")) + .with_label(span0) } #[derive(Debug, Default, Clone)] @@ -108,11 +106,11 @@ impl Rule for CheckPropertyNames { }) .collect::>(); ctx.diagnostic( - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(check-property-names): Duplicate @property found.", - ) - .with_help(format!("@property `{type_name}` is duplicated on the same block.")) - .with_labels(labels), + OxcDiagnostic::warn("Duplicate @property found.") + .with_help(format!( + "@property `{type_name}` is duplicated on the same block." + )) + .with_labels(labels), ); } } diff --git a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs index 3f5fe3f97d5af3..1ed81c578a2208 100644 --- a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs +++ b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs @@ -11,9 +11,7 @@ use crate::{ }; fn check_tag_names_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(check-tag-names): Invalid tag name found.") - .with_help(x1.to_string()) - .with_label(span0) + OxcDiagnostic::warn("Invalid tag name found.").with_help(x1.to_string()).with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs b/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs index 6f9ac1b0f8291e..c1143fd7459478 100644 --- a/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs +++ b/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs @@ -7,11 +7,9 @@ use serde::Deserialize; use crate::{context::LintContext, rule::Rule, utils::should_ignore_as_private}; fn empty_tags_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(empty-tags): Expects the void tags to be empty of any content.", - ) - .with_help(format!("`@{x1}` tag should not have body.")) - .with_label(span0) + OxcDiagnostic::warn("Expects the void tags to be empty of any content.") + .with_help(format!("`@{x1}` tag should not have body.")) + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs b/crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs index 0d9d3043e47c09..5e63e8df51bc4b 100644 --- a/crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs +++ b/crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs @@ -12,7 +12,7 @@ use crate::{ }; fn implements_on_classes_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(implements-on-classes): `@implements` used on a non-constructor function") + OxcDiagnostic::warn("`@implements` used on a non-constructor function") .with_help("Add `@class` tag or use ES6 class syntax.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsdoc/no_defaults.rs b/crates/oxc_linter/src/rules/jsdoc/no_defaults.rs index 6c47426904e081..9293b148b482c3 100644 --- a/crates/oxc_linter/src/rules/jsdoc/no_defaults.rs +++ b/crates/oxc_linter/src/rules/jsdoc/no_defaults.rs @@ -12,9 +12,7 @@ use crate::{ }; fn no_defaults_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(no-defaults): Defaults are not permitted.") - .with_help(x1.to_string()) - .with_label(span0) + OxcDiagnostic::warn("Defaults are not permitted.").with_help(x1.to_string()).with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_param.rs b/crates/oxc_linter/src/rules/jsdoc/require_param.rs index 27683c5c81d0f4..33ca41095f1120 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_param.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_param.rs @@ -246,7 +246,7 @@ impl Rule for RequireParam { .map(|span| LabeledSpan::new_with_span(None, *span)) .collect::>(); ctx.diagnostic( - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-param): Missing JSDoc `@param` declaration for function parameters.") + OxcDiagnostic::warn("Missing JSDoc `@param` declaration for function parameters.") .with_help("Add `@param` tag with name.") .with_labels(labels), ); diff --git a/crates/oxc_linter/src/rules/jsdoc/require_param_description.rs b/crates/oxc_linter/src/rules/jsdoc/require_param_description.rs index 6251b631f06621..bea361d4103ea9 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_param_description.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_param_description.rs @@ -14,11 +14,9 @@ use crate::{ }; fn missing_type_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-param-description): Missing JSDoc `@param` description.", - ) - .with_help("Add description to `@param` tag.") - .with_label(span0) + OxcDiagnostic::warn("Missing JSDoc `@param` description.") + .with_help("Add description to `@param` tag.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_param_name.rs b/crates/oxc_linter/src/rules/jsdoc/require_param_name.rs index 63ab1548014be6..08715ec4cc7b6c 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_param_name.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_param_name.rs @@ -11,7 +11,7 @@ use crate::{ }; fn missing_name_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-param-name): Missing JSDoc `@param` name.") + OxcDiagnostic::warn("Missing JSDoc `@param` name.") .with_help("Add name to `@param` tag.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsdoc/require_param_type.rs b/crates/oxc_linter/src/rules/jsdoc/require_param_type.rs index e09f41148defc5..8a2760095a2901 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_param_type.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_param_type.rs @@ -14,7 +14,7 @@ use crate::{ }; fn missing_type_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-param-type): Missing JSDoc `@param` type.") + OxcDiagnostic::warn("Missing JSDoc `@param` type.") .with_help("Add {type} to `@param` tag.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsdoc/require_property.rs b/crates/oxc_linter/src/rules/jsdoc/require_property.rs index 8388665cff0dbf..58b5cf588d204e 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_property.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_property.rs @@ -9,9 +9,11 @@ use crate::{ }; fn require_property_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-property): The `@typedef` and `@namespace` tags must include a `@property` tag with the type Object.") - .with_help("Consider adding a `@property` tag or replacing it with a more specific type.") - .and_label(span) + OxcDiagnostic::warn( + "The `@typedef` and `@namespace` tags must include a `@property` tag with the type Object.", + ) + .with_help("Consider adding a `@property` tag or replacing it with a more specific type.") + .and_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_property_description.rs b/crates/oxc_linter/src/rules/jsdoc/require_property_description.rs index 45357ab6fb4fcc..ca5e8174c346b8 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_property_description.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_property_description.rs @@ -9,11 +9,9 @@ use crate::{ }; fn require_property_description_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-property-description): Missing description in @property tag.", - ) - .with_help("Add a description to this @property tag.") - .with_label(span0) + OxcDiagnostic::warn("Missing description in @property tag.") + .with_help("Add a description to this @property tag.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_property_name.rs b/crates/oxc_linter/src/rules/jsdoc/require_property_name.rs index 5b4e5528bf46e2..d538f3df71f5b8 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_property_name.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_property_name.rs @@ -9,11 +9,9 @@ use crate::{ }; fn require_property_name_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-property-name): Missing name in @property tag.", - ) - .with_help("Add a type name to this @property tag.") - .with_label(span0) + OxcDiagnostic::warn("Missing name in @property tag.") + .with_help("Add a type name to this @property tag.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_property_type.rs b/crates/oxc_linter/src/rules/jsdoc/require_property_type.rs index f83afb2f5f5c87..29d2846378ee86 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_property_type.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_property_type.rs @@ -9,11 +9,9 @@ use crate::{ }; fn require_property_type_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-property-type): Missing type in @property tag.", - ) - .with_help("Add a {type} to this @property tag.") - .with_label(span0) + OxcDiagnostic::warn("Missing type in @property tag.") + .with_help("Add a {type} to this @property tag.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_returns.rs b/crates/oxc_linter/src/rules/jsdoc/require_returns.rs index 4ed710c127614c..7a714d9f05cc7d 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_returns.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_returns.rs @@ -20,14 +20,12 @@ use crate::{ }; fn missing_returns_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-returns): Missing JSDoc `@returns` declaration for function.", - ) - .with_help("Add `@returns` tag to the JSDoc comment.") - .with_label(span0) + OxcDiagnostic::warn("Missing JSDoc `@returns` declaration for function.") + .with_help("Add `@returns` tag to the JSDoc comment.") + .with_label(span0) } fn duplicate_returns_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-returns): Duplicate `@returns` tags.") + OxcDiagnostic::warn("Duplicate `@returns` tags.") .with_help("Remove redundunt `@returns` tag.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsdoc/require_returns_description.rs b/crates/oxc_linter/src/rules/jsdoc/require_returns_description.rs index 1a81c97ac9d1d3..99f892611b3978 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_returns_description.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_returns_description.rs @@ -11,11 +11,9 @@ use crate::{ }; fn missing_description_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsdoc(require-returns-description): Missing JSDoc `@returns` description.", - ) - .with_help("Add description comment to `@returns` tag.") - .with_label(span0) + OxcDiagnostic::warn("Missing JSDoc `@returns` description.") + .with_help("Add description comment to `@returns` tag.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsdoc/require_returns_type.rs b/crates/oxc_linter/src/rules/jsdoc/require_returns_type.rs index 55793f442cbfd4..1db7885357a716 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_returns_type.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_returns_type.rs @@ -11,7 +11,7 @@ use crate::{ }; fn missing_type_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-returns-type): Missing JSDoc `@returns` type.") + OxcDiagnostic::warn("Missing JSDoc `@returns` type.") .with_help("Add {type} to `@returns` tag.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsdoc/require_yields.rs b/crates/oxc_linter/src/rules/jsdoc/require_yields.rs index ec3ddab811c66a..6f32c246e5d9af 100644 --- a/crates/oxc_linter/src/rules/jsdoc/require_yields.rs +++ b/crates/oxc_linter/src/rules/jsdoc/require_yields.rs @@ -17,19 +17,19 @@ use crate::{ }; fn missing_yields(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-yields): Missing JSDoc `@yields` declaration for generator function.") + OxcDiagnostic::warn("Missing JSDoc `@yields` declaration for generator function.") .with_help("Add `@yields` tag to the JSDoc comment.") .with_label(span0) } fn duplicate_yields(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-yields): Duplicate `@yields` tags.") + OxcDiagnostic::warn("Duplicate `@yields` tags.") .with_help("Remove redundunt `@yields` tag.") .with_label(span0) } fn missing_yields_with_generator(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsdoc(require-yields): `@yields` tag is required when using `@generator` tag.") + OxcDiagnostic::warn("`@yields` tag is required when using `@generator` tag.") .with_help("Add `@yields` tag to the JSDoc comment.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs index 273248ff0e58a6..cb6ac06b4e7483 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs @@ -17,13 +17,13 @@ use crate::{ }; fn missing_alt_prop(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Missing `alt` attribute.") + OxcDiagnostic::warn("Missing `alt` attribute.") .with_help("Must have `alt` prop, either with meaningful text, or an empty string for decorative images.") .with_label(span0) } fn missing_alt_value(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Invalid `alt` value.") + OxcDiagnostic::warn("Invalid `alt` value.") .with_help( "Must have meaningful value for `alt` prop. Use alt=\"\" for presentational images.", ) @@ -31,39 +31,37 @@ fn missing_alt_value(span0: Span) -> OxcDiagnostic { } fn aria_label_value(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Missing value for aria-label attribute.") + OxcDiagnostic::warn("Missing value for aria-label attribute.") .with_help("The aria-label attribute must have a value. The alt attribute is preferred over aria-label for images.") .with_label(span0) } fn aria_labelled_by_value(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsx-a11y(alt-text): Missing value for aria-labelledby attribute.", - ) - .with_help("The alt attribute is preferred over aria-labelledby for images.") - .with_label(span0) + OxcDiagnostic::warn("Missing value for aria-labelledby attribute.") + .with_help("The alt attribute is preferred over aria-labelledby for images.") + .with_label(span0) } fn prefer_alt(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): ARIA used where native HTML could suffice.") + OxcDiagnostic::warn("ARIA used where native HTML could suffice.") .with_help("Prefer alt=\"\" over presentational role. Native HTML attributes should be preferred for accessibility before resorting to ARIA attributes.") .with_label(span0) } fn object(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Missing alternative text.") + OxcDiagnostic::warn("Missing alternative text.") .with_help("Embedded elements must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.") .with_label(span0) } fn area(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Missing alternative text.") + OxcDiagnostic::warn("Missing alternative text.") .with_help("Each area of an image map must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.") .with_label(span0) } fn input_type_image(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(alt-text): Missing alternative text.") + OxcDiagnostic::warn("Missing alternative text.") .with_help(" elements with type=\"image\" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/anchor_has_content.rs b/crates/oxc_linter/src/rules/jsx_a11y/anchor_has_content.rs index 464d1b970c2d1f..3c093f1478f86e 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/anchor_has_content.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/anchor_has_content.rs @@ -14,13 +14,13 @@ use crate::{ }; fn missing_content(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(anchor-has-content): Missing accessible content when using `a` elements.") + OxcDiagnostic::warn("Missing accessible content when using `a` elements.") .with_help("Provide screen reader accessible content when using `a` elements.") .with_label(span0) } fn remove_aria_hidden(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(anchor-has-content): Missing accessible content when using `a` elements.") + OxcDiagnostic::warn("Missing accessible content when using `a` elements.") .with_help("Remove the `aria-hidden` attribute to allow the anchor element and its content visible to assistive technologies.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/anchor_is_valid.rs b/crates/oxc_linter/src/rules/jsx_a11y/anchor_is_valid.rs index 1ea1b096c8fb09..a4f69db2d2fa26 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/anchor_is_valid.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/anchor_is_valid.rs @@ -14,27 +14,21 @@ use crate::{ }; fn missing_href_attribute(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsx-a11y(anchor-is-valid): Missing `href` attribute for the `a` element.", - ) - .with_help("Provide an href for the `a` element.") - .with_label(span0) + OxcDiagnostic::warn("Missing `href` attribute for the `a` element.") + .with_help("Provide an href for the `a` element.") + .with_label(span0) } fn incorrect_href(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element.", - ) - .with_help("Provide a correct href for the `a` element.") - .with_label(span0) + OxcDiagnostic::warn("Use an incorrect href for the 'a' element.") + .with_help("Provide a correct href for the `a` element.") + .with_label(span0) } fn cant_be_anchor(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn( - "eslint-plugin-jsx-a11y(anchor-is-valid): The a element has `href` and `onClick`.", - ) - .with_help("Use a `button` element instead of an `a` element.") - .with_label(span0) + OxcDiagnostic::warn(" The a element has `href` and `onClick`.") + .with_help("Use a `button` element instead of an `a` element.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs index 4e21a515815aaa..50f4603a32d908 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs @@ -15,8 +15,10 @@ use crate::{ }; fn aria_activedescendant_has_tabindex_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(aria-activedescendant-has-tabindex): Enforce elements with aria-activedescendant are tabbable.") - .with_help("An element that manages focus with `aria-activedescendant` must have a tabindex.") + OxcDiagnostic::warn("Enforce elements with aria-activedescendant are tabbable.") + .with_help( + "An element that manages focus with `aria-activedescendant` must have a tabindex.", + ) .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_props.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_props.rs index 0c310df47c3311..17da41c4ddd68c 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_props.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_props.rs @@ -9,9 +9,7 @@ use crate::{ }; fn aria_props_diagnostic(span: Span, prop_name: &str, suggestion: Option<&str>) -> OxcDiagnostic { - let mut err = OxcDiagnostic::warn(format!( - "eslint-plugin-jsx-a11y(aria-props): '{prop_name}' is not a valid ARIA attribute." - )); + let mut err = OxcDiagnostic::warn(format!("'{prop_name}' is not a valid ARIA attribute.")); if let Some(suggestion) = suggestion { err = err.with_help(format!("Did you mean '{suggestion}'?")); diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_role.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_role.rs index 6e80f1131df70c..2efa65b987a7d7 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_role.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_role.rs @@ -15,7 +15,7 @@ use crate::{ }; fn aria_role_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(aria-role): Elements with ARIA roles must use a valid, non-abstract ARIA role.") + OxcDiagnostic::warn("Elements with ARIA roles must use a valid, non-abstract ARIA role.") .with_help(format!("Set a valid, non-abstract ARIA role for element with ARIA{x1}")) .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs index 851cd9c0faef98..82eb06fac7e5e2 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs @@ -34,7 +34,7 @@ declare_oxc_lint! { pub struct AriaUnsupportedElements; fn aria_unsupported_elements_diagnostic(span0: Span, x1: &str) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(aria-unsupported-elements): This element does not support ARIA roles, states and properties.") + OxcDiagnostic::warn("This element does not support ARIA roles, states and properties.") .with_help(format!("Try removing the prop `{x1}`.")) .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs b/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs index cb229143e4afeb..780d90b5feb88a 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs @@ -15,7 +15,7 @@ use crate::{ }; fn autocomplete_valid_diagnostic(span: Span, autocomplete: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("eslint-plugin-jsx-a11y(autocomplete-valid): `{autocomplete}` is not a valid value for autocomplete.")) + OxcDiagnostic::warn(format!("`{autocomplete}` is not a valid value for autocomplete.")) .with_help(format!("Change `{autocomplete}` to a valid value for autocomplete.")) .with_label(span) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs b/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs index 1ecd9427460c0b..e7b605bdc87726 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs @@ -15,7 +15,7 @@ use crate::{ }; fn click_events_have_key_events_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(click-events-have-key-events): Enforce a clickable non-interactive element has at least one keyboard event listener.") + OxcDiagnostic::warn("Enforce a clickable non-interactive element has at least one keyboard event listener.") .with_help("Visible, non-interactive elements with click handlers must have one of keyup, keydown, or keypress listener.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs b/crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs index a14f31021bfb26..6d07561ecca2c4 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs @@ -11,9 +11,11 @@ use crate::{ }; fn heading_has_content_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint(heading-has-content): Headings must have content and the content must be accessible by a screen reader.") - .with_help("Provide screen reader accessible content when using heading elements.") - .with_label(span0) + OxcDiagnostic::warn( + "Headings must have content and the content must be accessible by a screen reader.", + ) + .with_help("Provide screen reader accessible content when using heading elements.") + .with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs b/crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs index 619a371a345de9..6cc62083aaae29 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs @@ -14,13 +14,13 @@ use crate::{ }; fn missing_lang_prop(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(html-has-lang): Missing lang attribute.") + OxcDiagnostic::warn("Missing lang attribute.") .with_help("Add a lang attribute to the html element whose value represents the primary language of document.") .with_label(span0) } fn missing_lang_value(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(html-has-lang): Missing value for lang attribute") + OxcDiagnostic::warn("Missing value for lang attribute") .with_help("Must have meaningful value for `lang` prop.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs b/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs index 948961d12f7829..6b9e973100e1dc 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs @@ -14,7 +14,7 @@ use crate::{ }; fn iframe_has_title_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(iframe-has-title): Missing `title` attribute for the `iframe` element.") + OxcDiagnostic::warn("Missing `title` attribute for the `iframe` element.") .with_help("Provide title property for iframe element.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs index 8d9f7f7a129ec9..38f29cdd523ae1 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs @@ -17,7 +17,7 @@ use crate::{ }; fn img_redundant_alt_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute.").with_help("Provide no redundant alt text for image. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop.").with_label(span0) + OxcDiagnostic::warn("Redundant alt attribute.").with_help("Provide no redundant alt text for image. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop.").with_label(span0) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jsx_a11y/lang.rs b/crates/oxc_linter/src/rules/jsx_a11y/lang.rs index 46c1d7da295eaa..92b90016d8cbf0 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/lang.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/lang.rs @@ -15,7 +15,7 @@ use crate::{ }; fn lang_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(lang): Lang attribute must have a valid value.") + OxcDiagnostic::warn("Lang attribute must have a valid value.") .with_help("Set a valid value for lang attribute.") .with_label(span0) } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs b/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs index 8b224cbfbe4b98..5ca598a7fe8bc9 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs @@ -9,7 +9,7 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, utils::get_element_type, AstNode}; fn media_has_caption_diagnostic(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("eslint-plugin-jsx-a11y(media-has-caption): Missing element with captions inside