From f64c7e04a37195ca35f89b0e4e113fdd42924272 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 24 Feb 2024 23:54:43 +0800 Subject: [PATCH] feat(linter): handle cjs `module.exports.foo = bar` and `exports.foo = bar` (#2492) --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/oxc_ast/src/ast/js.rs | 2 +- .../oxc_linter/fixtures/import/oxc_named.js | 2 + crates/oxc_linter/src/rules/import/default.rs | 6 +- crates/oxc_linter/src/rules/import/named.rs | 16 +++-- crates/oxc_linter/src/service.rs | 2 +- .../adjacent_overload_signatures.snap | 2 - crates/oxc_linter/src/snapshots/alt_text.snap | 2 - .../src/snapshots/anchor_has_content.snap | 2 - .../src/snapshots/anchor_is_valid.snap | 2 - .../src/snapshots/approx_constant.snap | 2 - .../aria_activedescendant_has_tabindex.snap | 2 - .../oxc_linter/src/snapshots/aria_props.snap | 2 - .../oxc_linter/src/snapshots/aria_role.snap | 2 - .../snapshots/aria_unsupported_elements.snap | 2 - .../src/snapshots/array_callback_return.snap | 2 - .../oxc_linter/src/snapshots/array_type.snap | 2 - .../src/snapshots/autocomplete_valid.snap | 2 - .../bad_array_method_on_arguments.snap | 2 - .../src/snapshots/bad_bitwise_operator.snap | 2 - .../src/snapshots/bad_char_at_comparison.snap | 2 - .../snapshots/bad_comparison_sequence.snap | 2 - .../src/snapshots/bad_min_max_func.snap | 2 - .../bad_object_literal_comparison.snap | 2 - .../src/snapshots/bad_replace_all_arg.snap | 2 - .../src/snapshots/ban_ts_comment.snap | 2 - .../src/snapshots/ban_tslint_comment.snap | 2 - .../oxc_linter/src/snapshots/ban_types.snap | 2 - .../src/snapshots/button_has_type.snap | 2 - .../src/snapshots/catch_error_name.snap | 2 - .../click_events_have_key_events.snap | 2 - .../src/snapshots/const_comparisons.snap | 2 - crates/oxc_linter/src/snapshots/default.snap | 2 - .../src/snapshots/default_case_last.snap | 2 - .../src/snapshots/double_comparisons.snap | 2 - .../src/snapshots/empty_brace_spaces.snap | 2 - crates/oxc_linter/src/snapshots/eqeqeq.snap | 2 - .../oxc_linter/src/snapshots/erasing_op.snap | 2 - .../src/snapshots/error_message.snap | 2 - .../oxc_linter/src/snapshots/escape_case.snap | 2 - .../src/snapshots/expect_expect.snap | 2 - .../src/snapshots/explicit_length_check.snap | 2 - .../src/snapshots/filename_case.snap | 2 - .../src/snapshots/for_direction.snap | 2 - .../src/snapshots/getter_return.snap | 2 - .../src/snapshots/google_font_display.snap | 2 - .../src/snapshots/google_font_preconnect.snap | 2 - .../src/snapshots/heading_has_content.snap | 2 - .../src/snapshots/html_has_lang.snap | 2 - .../src/snapshots/iframe_has_title.snap | 2 - .../src/snapshots/img_redundant_alt.snap | 2 - .../src/snapshots/inline_script_id.snap | 2 - crates/oxc_linter/src/snapshots/jsx_key.snap | 2 - .../snapshots/jsx_no_comment_textnodes.snap | 2 - .../src/snapshots/jsx_no_duplicate_props.snap | 2 - .../src/snapshots/jsx_no_jsx_as_prop.snap | 2 - .../snapshots/jsx_no_new_array_as_prop.snap | 2 - .../jsx_no_new_function_as_prop.snap | 2 - .../jsx_no_new_function_as_props.snap | 68 ------------------ .../snapshots/jsx_no_new_object_as_prop.snap | 2 - .../src/snapshots/jsx_no_target_blank.snap | 2 - .../src/snapshots/jsx_no_undef.snap | 2 - .../snapshots/jsx_no_useless_fragment.snap | 2 - crates/oxc_linter/src/snapshots/lang.snap | 2 - .../oxc_linter/src/snapshots/max_expects.snap | 2 - .../src/snapshots/media_has_caption.snap | 2 - .../snapshots/misrefactored_assign_op.snap | 2 - .../src/snapshots/missing_throw.snap | 2 - .../mouse_events_have_key_events.snap | 2 - crates/oxc_linter/src/snapshots/named.snap | 15 +++- .../src/snapshots/new_for_builtins.snap | 2 - .../src/snapshots/next_script_for_ga.snap | 2 - .../snapshots/no_abusive_eslint_disable.snap | 2 - .../src/snapshots/no_access_key.snap | 2 - .../src/snapshots/no_accumulating_spread.snap | 2 - .../src/snapshots/no_alias_methods.snap | 2 - crates/oxc_linter/src/snapshots/no_amd.snap | 2 - .../no_aria_hidden_on_focusable.snap | 2 - .../src/snapshots/no_array_constructor.snap | 2 - .../src/snapshots/no_array_for_each.snap | 2 - .../src/snapshots/no_array_reduce.snap | 2 - .../snapshots/no_assign_module_variable.snap | 2 - .../snapshots/no_async_client_component.snap | 2 - .../snapshots/no_async_promise_executor.snap | 2 - .../src/snapshots/no_autofocus.snap | 2 - .../snapshots/no_await_expression_member.snap | 2 - ...e_interactive_script_outside_document.snap | 2 - .../oxc_linter/src/snapshots/no_bitwise.snap | 2 - .../oxc_linter/src/snapshots/no_caller.snap | 2 - .../src/snapshots/no_case_declarations.snap | 2 - .../src/snapshots/no_children_prop.snap | 2 - .../src/snapshots/no_class_assign.snap | 2 - .../src/snapshots/no_commented_out_tests.snap | 2 - .../src/snapshots/no_compare_neg_zero.snap | 2 - .../src/snapshots/no_cond_assign.snap | 2 - .../src/snapshots/no_conditional_expect.snap | 2 - .../snapshots/no_confusing_set_timeout.snap | 2 - .../oxc_linter/src/snapshots/no_console.snap | 2 - .../src/snapshots/no_console_spaces.snap | 2 - .../src/snapshots/no_const_assign.snap | 2 - .../no_constant_binary_expression.snap | 2 - .../src/snapshots/no_constant_condition.snap | 2 - .../src/snapshots/no_control_regex.snap | Bin 4544 -> 4542 bytes .../oxc_linter/src/snapshots/no_css_tags.snap | 2 - crates/oxc_linter/src/snapshots/no_cycle.snap | 2 - .../oxc_linter/src/snapshots/no_danger.snap | 2 - .../oxc_linter/src/snapshots/no_debugger.snap | 2 - .../src/snapshots/no_delete_var.snap | 2 - .../snapshots/no_deprecated_functions.snap | 2 - .../snapshots/no_direct_mutation_state.snap | 2 - .../src/snapshots/no_disabled_tests.snap | 2 - .../snapshots/no_distracting_elements.snap | 2 - .../src/snapshots/no_document_cookie.snap | 2 - .../snapshots/no_document_import_in_page.snap | 2 - .../src/snapshots/no_done_callback.snap | 2 - .../src/snapshots/no_dupe_class_members.snap | 2 - .../src/snapshots/no_dupe_else_if.snap | 2 - .../src/snapshots/no_dupe_keys.snap | 2 - .../src/snapshots/no_duplicate_case.snap | 2 - .../snapshots/no_duplicate_enum_values.snap | 2 - .../src/snapshots/no_duplicates.snap | 2 - crates/oxc_linter/src/snapshots/no_empty.snap | 2 - .../snapshots/no_empty_character_class.snap | 2 - .../src/snapshots/no_empty_file.snap | 2 - .../src/snapshots/no_empty_interface.snap | 2 - .../src/snapshots/no_empty_pattern.snap | 2 - .../src/snapshots/no_empty_static_block.snap | 2 - crates/oxc_linter/src/snapshots/no_eval.snap | 2 - .../src/snapshots/no_ex_assign.snap | 2 - .../src/snapshots/no_explicit_any.snap | 2 - .../oxc_linter/src/snapshots/no_export.snap | 2 - .../src/snapshots/no_extra_boolean_cast.snap | 2 - .../no_extra_non_null_assertion.snap | 2 - .../src/snapshots/no_find_dom_node.snap | 2 - .../src/snapshots/no_focused_tests.snap | 2 - .../src/snapshots/no_func_assign.snap | 2 - .../src/snapshots/no_global_assign.snap | 2 - .../src/snapshots/no_head_element.snap | 2 - .../snapshots/no_head_import_in_document.snap | 2 - .../src/snapshots/no_hex_escape.snap | 2 - crates/oxc_linter/src/snapshots/no_hooks.snap | 2 - .../src/snapshots/no_identical_title.snap | 2 - .../src/snapshots/no_img_element.snap | 2 - .../src/snapshots/no_import_assign.snap | 2 - .../src/snapshots/no_inner_declarations.snap | 2 - .../src/snapshots/no_instanceof_array.snap | 2 - .../no_interpolation_in_snapshots.snap | 2 - .../no_invalid_remove_event_listener.snap | 2 - .../snapshots/no_irregular_whitespace.snap | 2 - .../src/snapshots/no_is_mounted.snap | 2 - .../src/snapshots/no_jasmine_globals.snap | 2 - .../src/snapshots/no_lonely_if.snap | 2 - .../src/snapshots/no_loss_of_precision.snap | 2 - .../src/snapshots/no_misused_new.snap | 2 - .../src/snapshots/no_mixed_operators.snap | 2 - .../src/snapshots/no_mocks_import.snap | 2 - .../src/snapshots/no_named_as_default.snap | 2 - .../snapshots/no_named_as_default_member.snap | 2 - .../src/snapshots/no_namespace.snap | 2 - .../src/snapshots/no_negated_condition.snap | 2 - .../src/snapshots/no_nested_ternary.snap | 2 - .../src/snapshots/no_new_array.snap | 2 - .../src/snapshots/no_new_buffer.snap | 2 - .../src/snapshots/no_new_symbol.snap | 2 - .../src/snapshots/no_new_wrappers.snap | 2 - .../no_non_null_asserted_optional_chain.snap | 2 - .../snapshots/no_nonoctal_decimal_escape.snap | 2 - crates/oxc_linter/src/snapshots/no_null.snap | 2 - .../src/snapshots/no_obj_calls.snap | 2 - .../no_object_as_default_parameter.snap | 2 - .../src/snapshots/no_process_exit.snap | 2 - .../src/snapshots/no_prototype_builtins.snap | 2 - .../src/snapshots/no_redeclare.snap | 2 - .../src/snapshots/no_redundant_roles.snap | 2 - .../src/snapshots/no_regex_spaces.snap | 2 - .../src/snapshots/no_render_return_value.snap | 2 - .../snapshots/no_restricted_jest_methods.snap | 2 - .../src/snapshots/no_restricted_matchers.snap | 2 - .../src/snapshots/no_return_await.snap | 2 - .../no_script_component_in_head.snap | 2 - .../src/snapshots/no_self_assign.snap | 2 - .../src/snapshots/no_self_compare.snap | 2 - .../src/snapshots/no_setter_return.snap | 2 - .../snapshots/no_shadow_restricted_names.snap | 2 - .../src/snapshots/no_sparse_arrays.snap | 2 - .../src/snapshots/no_standalone_expect.snap | 2 - .../src/snapshots/no_static_only_class.snap | 2 - .../src/snapshots/no_string_refs.snap | 2 - .../src/snapshots/no_sync_scripts.snap | 2 - .../src/snapshots/no_test_prefixes.snap | 2 - .../snapshots/no_test_return_statement.snap | 2 - .../oxc_linter/src/snapshots/no_thenable.snap | 2 - .../src/snapshots/no_this_alias.snap | 2 - .../src/snapshots/no_this_assignment.snap | 2 - .../src/snapshots/no_this_before_super.snap | 2 - .../snapshots/no_title_in_document_head.snap | 2 - .../src/snapshots/no_typeof_undefined.snap | 2 - crates/oxc_linter/src/snapshots/no_typos.snap | 2 - crates/oxc_linter/src/snapshots/no_undef.snap | 2 - .../src/snapshots/no_unescaped_entities.snap | 2 - .../src/snapshots/no_unknown_property.snap | 2 - .../src/snapshots/no_unnecessary_await.snap | 2 - .../no_unnecessary_type_constraint.snap | 2 - .../no_unreadable_array_destructuring.snap | 2 - .../src/snapshots/no_unreadable_iife.snap | 2 - .../src/snapshots/no_unresolved.snap | 2 - .../no_unsafe_declaration_merging.snap | 2 - .../src/snapshots/no_unsafe_finally.snap | 2 - .../src/snapshots/no_unsafe_negation.snap | 2 - .../no_unsafe_optional_chaining.snap | 2 - .../src/snapshots/no_unused_labels.snap | 2 - .../no_unused_private_class_members.snap | 2 - .../src/snapshots/no_unwanted_polyfillio.snap | 2 - .../src/snapshots/no_useless_catch.snap | 2 - .../src/snapshots/no_useless_escape.snap | 2 - .../no_useless_fallback_in_spread.snap | 2 - .../snapshots/no_useless_length_check.snap | 2 - .../no_useless_promise_resolve_reject.snap | 2 - .../src/snapshots/no_useless_spread.snap | 2 - .../src/snapshots/no_useless_switch_case.snap | 2 - crates/oxc_linter/src/snapshots/no_var.snap | 2 - .../src/snapshots/no_var_requires.snap | 2 - crates/oxc_linter/src/snapshots/no_void.snap | 2 - .../src/snapshots/no_zero_fractions.snap | 2 - .../snapshots/number_arg_out_of_range.snap | 2 - .../src/snapshots/number_literal_case.snap | 2 - .../snapshots/numeric_separators_style.snap | 2 - .../src/snapshots/only_used_in_recursion.snap | 2 - .../snapshots/prefer_add_event_listener.snap | 2 - .../src/snapshots/prefer_array_flat.snap | 2 - .../src/snapshots/prefer_array_flat_map.snap | 2 - .../src/snapshots/prefer_array_some.snap | 2 - .../src/snapshots/prefer_as_const.snap | 2 - .../prefer_blob_reading_methods.snap | 2 - .../src/snapshots/prefer_called_with.snap | 2 - .../src/snapshots/prefer_code_point.snap | 2 - .../src/snapshots/prefer_date_now.snap | 2 - .../src/snapshots/prefer_dom_node_append.snap | 2 - .../snapshots/prefer_dom_node_dataset.snap | 2 - .../src/snapshots/prefer_dom_node_remove.snap | 2 - .../prefer_dom_node_text_content.snap | 2 - .../snapshots/prefer_equality_matcher.snap | 3 - .../src/snapshots/prefer_event_target.snap | 2 - .../src/snapshots/prefer_function_type.snap | 3 - .../src/snapshots/prefer_includes.snap | 2 - .../prefer_logical_operator_over_ternary.snap | 2 - .../src/snapshots/prefer_math_trunc.snap | 2 - .../src/snapshots/prefer_modern_dom_apis.snap | 2 - .../snapshots/prefer_modern_math_apis.snap | 2 - .../prefer_native_coercion_functions.snap | 2 - .../src/snapshots/prefer_node_protocol.snap | 2 - .../snapshots/prefer_number_properties.snap | 2 - .../prefer_optional_catch_binding.snap | 2 - .../snapshots/prefer_prototype_methods.snap | 2 - .../src/snapshots/prefer_query_selector.snap | 2 - .../src/snapshots/prefer_reflect_apply.snap | 2 - .../src/snapshots/prefer_regexp_test.snap | 2 - .../src/snapshots/prefer_set_size.snap | 2 - .../src/snapshots/prefer_spread.snap | 2 - .../snapshots/prefer_string_replace_all.snap | 2 - .../src/snapshots/prefer_string_slice.snap | 2 - .../prefer_string_starts_ends_with.snap | 2 - .../prefer_string_trim_start_end.snap | 2 - .../src/snapshots/prefer_tag_over_role.snap | 2 - .../oxc_linter/src/snapshots/prefer_todo.snap | 2 - .../src/snapshots/prefer_ts_expect_error.snap | 2 - .../src/snapshots/prefer_type_error.snap | 2 - .../src/snapshots/react_in_jsx_scope.snap | 2 - .../require_array_join_separator.snap | 2 - ...quire_number_to_fixed_digits_argument.snap | 2 - .../src/snapshots/require_render_return.snap | 2 - .../snapshots/require_to_throw_message.snap | 2 - .../src/snapshots/require_yield.snap | 2 - .../role_has_required_aria_props.snap | 2 - .../snapshots/role_supports_aria_props.snap | 2 - crates/oxc_linter/src/snapshots/scope.snap | 2 - .../src/snapshots/switch_case_braces.snap | 2 - .../src/snapshots/tabindex_no_positive.snap | 2 - .../text_encoding_identifier_case.snap | 2 - .../src/snapshots/throw_new_error.snap | 2 - .../src/snapshots/triple_slash_reference.snap | 2 - .../snapshots/uninvoked_array_callback.snap | 2 - .../oxc_linter/src/snapshots/use_isnan.snap | 2 - .../snapshots/valid_describe_callback.snap | 2 - .../src/snapshots/valid_expect.snap | 2 - .../oxc_linter/src/snapshots/valid_title.snap | 2 - .../src/snapshots/valid_typeof.snap | 2 - .../void_dom_elements_no_children.snap | 2 - .../oxc_semantic/src/module_record/builder.rs | 31 +++++++- crates/oxc_syntax/src/module_record.rs | 4 ++ 291 files changed, 65 insertions(+), 647 deletions(-) create mode 100644 crates/oxc_linter/fixtures/import/oxc_named.js delete mode 100644 crates/oxc_linter/src/snapshots/jsx_no_new_function_as_props.snap diff --git a/Cargo.lock b/Cargo.lock index f09a2720ed9ad..ef7ec51b53078 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.34.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" +checksum = "7c985c1bef99cf13c58fade470483d81a2bfe846ebde60ed28cc2dddec2df9e2" dependencies = [ "console", "globset", diff --git a/Cargo.toml b/Cargo.toml index 033e0b95be203..5883f9e0ad185 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,7 +128,7 @@ static_assertions = { version = "1.1.0" } stacker = { version = "0.1.15" } tracing = { version = "0.1" } tracing-subscriber = { version = "0.3" } -insta = { version = "1.34.0", features = ["glob"] } +insta = { version = "1.35.1", features = ["glob"] } codspeed-criterion-compat = { version = "2.3.3", default-features = false } glob = { version = "0.3.1" } mime_guess = { version = "2.0.4" } diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 5f5618b131cc8..7fed471d27f92 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -645,7 +645,7 @@ impl<'a> MemberExpression<'a> { } } - pub fn static_property_info(&'a self) -> Option<(Span, &'a str)> { + pub fn static_property_info(&self) -> Option<(Span, &str)> { match self { MemberExpression::ComputedMemberExpression(expr) => match &expr.expression { Expression::StringLiteral(lit) => Some((lit.span, &lit.value)), diff --git a/crates/oxc_linter/fixtures/import/oxc_named.js b/crates/oxc_linter/fixtures/import/oxc_named.js new file mode 100644 index 0000000000000..f800f7d334581 --- /dev/null +++ b/crates/oxc_linter/fixtures/import/oxc_named.js @@ -0,0 +1,2 @@ +module.exports.foo = 1; +exports.bar = 1; diff --git a/crates/oxc_linter/src/rules/import/default.rs b/crates/oxc_linter/src/rules/import/default.rs index 97b341169c35f..b7bbe0463cc14 100644 --- a/crates/oxc_linter/src/rules/import/default.rs +++ b/crates/oxc_linter/src/rules/import/default.rs @@ -3,7 +3,7 @@ use oxc_diagnostics::{ thiserror::Error, }; use oxc_macros::declare_oxc_lint; -use oxc_span::{Atom, Span}; +use oxc_span::Span; use oxc_syntax::module_record::ImportImportName; use crate::{context::LintContext, rule::Rule}; @@ -11,7 +11,7 @@ use crate::{context::LintContext, rule::Rule}; #[derive(Debug, Error, Diagnostic)] #[error("eslint-plugin-import(default): No default export found in imported module {0:?}")] #[diagnostic(severity(warning), help("does {0:?} have the default export?"))] -struct DefaultDiagnostic(Atom, #[label] pub Span); +struct DefaultDiagnostic(String, #[label] pub Span); /// #[derive(Debug, Default, Clone)] @@ -50,7 +50,7 @@ impl Rule for Default { && !remote_module_record_ref.exported_bindings.contains_key("default") { ctx.diagnostic(DefaultDiagnostic( - specifier.clone(), + specifier.to_string(), import_entry.module_request.span(), )); } diff --git a/crates/oxc_linter/src/rules/import/named.rs b/crates/oxc_linter/src/rules/import/named.rs index 2258e759fb507..db4c7f89880a6 100644 --- a/crates/oxc_linter/src/rules/import/named.rs +++ b/crates/oxc_linter/src/rules/import/named.rs @@ -3,7 +3,7 @@ use oxc_diagnostics::{ thiserror::Error, }; use oxc_macros::declare_oxc_lint; -use oxc_span::{Atom, Span}; +use oxc_span::Span; use oxc_syntax::module_record::{ExportImportName, ImportImportName}; use crate::{context::LintContext, rule::Rule}; @@ -11,7 +11,7 @@ use crate::{context::LintContext, rule::Rule}; #[derive(Debug, Error, Diagnostic)] #[error("eslint-plugin-import(named): named import {0:?} not found")] #[diagnostic(severity(warning), help("does {1:?} have the export {0:?}?"))] -struct NamedDiagnostic(Atom, Atom, #[label] pub Span); +struct NamedDiagnostic(String, String, #[label] pub Span); /// #[derive(Debug, Default, Clone)] @@ -56,8 +56,8 @@ impl Rule for Named { continue; } ctx.diagnostic(NamedDiagnostic( - import_name.name().clone(), - specifier.clone(), + import_name.name().to_string(), + specifier.to_string(), import_name.span(), )); } @@ -80,8 +80,8 @@ impl Rule for Named { continue; } ctx.diagnostic(NamedDiagnostic( - import_name.name().clone(), - specifier.clone(), + import_name.name().to_string(), + specifier.to_string(), import_name.span(), )); } @@ -164,6 +164,8 @@ fn test() { // "import { foo } from './export-all'", // TypeScript export assignment "import x from './typescript-export-assign-object'", + // oxc + "import { foo, bar } from './oxc_named'", ]; let fail = vec![ @@ -198,6 +200,8 @@ fn test() { // Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. "import { NotExported } from './typescript-export-assign-object'", "import { FooBar } from './typescript-export-assign-object'", + // oxc + "import { baz, quaz } from './oxc_named'", ]; Tester::new(Named::NAME, pass, fail) diff --git a/crates/oxc_linter/src/service.rs b/crates/oxc_linter/src/service.rs index f305bebf2230f..420654ce5f2ab 100644 --- a/crates/oxc_linter/src/service.rs +++ b/crates/oxc_linter/src/service.rs @@ -143,7 +143,7 @@ impl Runtime { .map(|p| TsconfigOptions { config_file: p, references: TsconfigReferences::Auto }); Resolver::new(ResolveOptions { extensions: VALID_EXTENSIONS.iter().map(|ext| format!(".{ext}")).collect(), - condition_names: vec!["require".into(), "module".into()], + condition_names: vec!["module".into(), "require".into()], tsconfig, ..ResolveOptions::default() }) diff --git a/crates/oxc_linter/src/snapshots/adjacent_overload_signatures.snap b/crates/oxc_linter/src/snapshots/adjacent_overload_signatures.snap index 1b2a3bfcf1a4e..146b16174da62 100644 --- a/crates/oxc_linter/src/snapshots/adjacent_overload_signatures.snap +++ b/crates/oxc_linter/src/snapshots/adjacent_overload_signatures.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: adjacent_overload_signatures --- - ⚠ typescript-eslint(adjacent-overload-signatures): All "foo" signatures should be adjacent. ╭─[adjacent_overload_signatures.tsx:3:18] 2 │ function foo(s: string); @@ -369,4 +368,3 @@ expression: adjacent_overload_signatures · ────────── 6 │ } ╰──── - diff --git a/crates/oxc_linter/src/snapshots/alt_text.snap b/crates/oxc_linter/src/snapshots/alt_text.snap index a59087f56d941..50489d0f5f715 100644 --- a/crates/oxc_linter/src/snapshots/alt_text.snap +++ b/crates/oxc_linter/src/snapshots/alt_text.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: alt_text --- - ⚠ eslint-plugin-jsx-a11y(alt-text): Missing `alt` attribute. ╭─[alt_text.tsx:1:1] 1 │ ; @@ -450,4 +449,3 @@ expression: alt_text · ────────────────────── ╰──── help: elements with type="image" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop. - diff --git a/crates/oxc_linter/src/snapshots/anchor_has_content.snap b/crates/oxc_linter/src/snapshots/anchor_has_content.snap index ce7d6b4692462..274dc96e3eb77 100644 --- a/crates/oxc_linter/src/snapshots/anchor_has_content.snap +++ b/crates/oxc_linter/src/snapshots/anchor_has_content.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: anchor_has_content --- - ⚠ eslint-plugin-jsx-a11y(anchor-has-content): Missing accessible content when using `a` elements. ╭─[anchor_has_content.tsx:1:1] 1 │ @@ -30,4 +29,3 @@ expression: anchor_has_content · ──────── ╰──── help: Provide screen reader accessible content when using `a` elements. - diff --git a/crates/oxc_linter/src/snapshots/anchor_is_valid.snap b/crates/oxc_linter/src/snapshots/anchor_is_valid.snap index be6d050e8a07b..24c952ee65428 100644 --- a/crates/oxc_linter/src/snapshots/anchor_is_valid.snap +++ b/crates/oxc_linter/src/snapshots/anchor_is_valid.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: anchor_is_valid --- - ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Missing `href` attribute for the `a` element. ╭─[anchor_is_valid.tsx:1:2] 1 │ @@ -92,4 +91,3 @@ expression: anchor_is_valid · ──── ╰──── help: Use a `button` element instead of an `a` element. - diff --git a/crates/oxc_linter/src/snapshots/approx_constant.snap b/crates/oxc_linter/src/snapshots/approx_constant.snap index badccdb692fa8..0f0b154156299 100644 --- a/crates/oxc_linter/src/snapshots/approx_constant.snap +++ b/crates/oxc_linter/src/snapshots/approx_constant.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: approx_constant --- - ⚠ oxc(approx-constant): Approximate value of `PI` found. ╭─[approx_constant.tsx:1:29] 1 │ const getArea = (radius) => 3.141 * radius * radius; @@ -65,4 +64,3 @@ expression: approx_constant · ──────── ╰──── help: Use `Math.SQRT2` instead - diff --git a/crates/oxc_linter/src/snapshots/aria_activedescendant_has_tabindex.snap b/crates/oxc_linter/src/snapshots/aria_activedescendant_has_tabindex.snap index 3c354764ae4c1..af53106af8191 100644 --- a/crates/oxc_linter/src/snapshots/aria_activedescendant_has_tabindex.snap +++ b/crates/oxc_linter/src/snapshots/aria_activedescendant_has_tabindex.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: aria_activedescendant_has_tabindex --- - ⚠ eslint-plugin-jsx-a11y(aria-activedescendant-has-tabindex): Enforce elements with aria-activedescendant are tabbable. ╭─[aria_activedescendant_has_tabindex.tsx:1:2] 1 │
; @@ -16,4 +15,3 @@ expression: aria_activedescendant_has_tabindex · ─────────────── ╰──── help: An element that manages focus with `aria-activedescendant` must have a tabindex. - diff --git a/crates/oxc_linter/src/snapshots/aria_props.snap b/crates/oxc_linter/src/snapshots/aria_props.snap index 5b3d8fbd263ae..323a7a794e35b 100644 --- a/crates/oxc_linter/src/snapshots/aria_props.snap +++ b/crates/oxc_linter/src/snapshots/aria_props.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: aria_props --- - ⚠ eslint-plugin-jsx-a11y(aria-props): Invalid ARIA prop. ╭─[aria_props.tsx:1:6] 1 │
@@ -23,4 +22,3 @@ expression: aria_props · ─────────────────────────────── ╰──── help: `aria-skldjfaria-klajsd` is an invalid ARIA attribute. - diff --git a/crates/oxc_linter/src/snapshots/aria_role.snap b/crates/oxc_linter/src/snapshots/aria_role.snap index d7e80941b69b6..da18ab107f458 100644 --- a/crates/oxc_linter/src/snapshots/aria_role.snap +++ b/crates/oxc_linter/src/snapshots/aria_role.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: aria_role --- - ⚠ eslint-plugin-jsx-a11y(aria-role): Elements with ARIA roles must use a valid, non-abstract ARIA role. ╭─[aria_role.tsx:1:11] 1 │
@@ -113,4 +112,3 @@ expression: aria_role · ──────── ╰──── help: Set a valid, non-abstract ARIA role for element with ARIA, `Button` is an invalid aria role - diff --git a/crates/oxc_linter/src/snapshots/aria_unsupported_elements.snap b/crates/oxc_linter/src/snapshots/aria_unsupported_elements.snap index fdc19ff2096e8..4c41332c27fd7 100644 --- a/crates/oxc_linter/src/snapshots/aria_unsupported_elements.snap +++ b/crates/oxc_linter/src/snapshots/aria_unsupported_elements.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: aria_unsupported_elements --- - ⚠ eslint-plugin-jsx-a11y(aria-unsupported-elements): This element does not support ARIA roles, states and properties. ╭─[aria_unsupported_elements.tsx:1:7] 1 │ @@ -226,4 +225,3 @@ expression: aria_unsupported_elements · ─────────── ╰──── help: Try removing the prop `aria-hidden`. - diff --git a/crates/oxc_linter/src/snapshots/array_callback_return.snap b/crates/oxc_linter/src/snapshots/array_callback_return.snap index 0c302b2583f59..aa51e8c589347 100644 --- a/crates/oxc_linter/src/snapshots/array_callback_return.snap +++ b/crates/oxc_linter/src/snapshots/array_callback_return.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: array_callback_return --- - ⚠ eslint(array-callback-return): Missing return on some path for array method "Array.from" ╭─[array_callback_return.tsx:1:26] 1 │ Array.from(x, function() {}) @@ -792,4 +791,3 @@ expression: array_callback_return · ──────────────────────── ╰──── help: Array method "Array.prototype.filter" needs to have valid return on all code paths - diff --git a/crates/oxc_linter/src/snapshots/array_type.snap b/crates/oxc_linter/src/snapshots/array_type.snap index 62e694ba4aa43..c9b041a0437ad 100644 --- a/crates/oxc_linter/src/snapshots/array_type.snap +++ b/crates/oxc_linter/src/snapshots/array_type.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: array_type --- - ⚠ typescript-eslint(array-type): Array type using 'Array' is forbidden. Use 'number[]' instead. ╭─[array_type.tsx:1:8] 1 │ let a: Array = []; @@ -565,4 +564,3 @@ expression: array_type 1 │ const foo: ReadonlyArray void> = []; · ─────────────────────────────────────────── ╰──── - diff --git a/crates/oxc_linter/src/snapshots/autocomplete_valid.snap b/crates/oxc_linter/src/snapshots/autocomplete_valid.snap index 5b05e862d9b25..4a11d3f97c272 100644 --- a/crates/oxc_linter/src/snapshots/autocomplete_valid.snap +++ b/crates/oxc_linter/src/snapshots/autocomplete_valid.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: autocomplete_valid --- - ⚠ eslint-plugin-jsx-a11y(autocomplete-valid): `foo` is not a valid value for autocomplete. ╭─[autocomplete_valid.tsx:1:20] 1 │ ; @@ -44,4 +43,3 @@ expression: autocomplete_valid · ────────────────── ╰──── help: Change `baz` to a valid value for autocomplete. - diff --git a/crates/oxc_linter/src/snapshots/bad_array_method_on_arguments.snap b/crates/oxc_linter/src/snapshots/bad_array_method_on_arguments.snap index 2a26fa4919d44..c77e510aa2db3 100644 --- a/crates/oxc_linter/src/snapshots/bad_array_method_on_arguments.snap +++ b/crates/oxc_linter/src/snapshots/bad_array_method_on_arguments.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_array_method_on_arguments --- - ⚠ deepscan(bad-array-method-on-arguments): Bad array method on arguments ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments['map'](() => {})} @@ -233,4 +232,3 @@ expression: bad_array_method_on_arguments · ─────────────────────── ╰──── help: The 'arguments' object does not have '@@iterator()' method. If an array method was intended, consider converting the 'arguments' object to an array or using ES6 rest parameter instead. - diff --git a/crates/oxc_linter/src/snapshots/bad_bitwise_operator.snap b/crates/oxc_linter/src/snapshots/bad_bitwise_operator.snap index ddf4b97a8c196..69bd2c04e1333 100644 --- a/crates/oxc_linter/src/snapshots/bad_bitwise_operator.snap +++ b/crates/oxc_linter/src/snapshots/bad_bitwise_operator.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_bitwise_operator --- - ⚠ deepscan(bad-bitwise-operator): Bad bitwise operator ╭─[bad_bitwise_operator.tsx:1:9] 1 │ var a = obj & obj.a @@ -107,4 +106,3 @@ expression: bad_bitwise_operator · ────────────────── ╰──── help: Bitwise operator '|=' seems unintended. Consider using non-compound assignment and logical operator '||' instead. - diff --git a/crates/oxc_linter/src/snapshots/bad_char_at_comparison.snap b/crates/oxc_linter/src/snapshots/bad_char_at_comparison.snap index 85d50ff0a44a9..50b40034fb06f 100644 --- a/crates/oxc_linter/src/snapshots/bad_char_at_comparison.snap +++ b/crates/oxc_linter/src/snapshots/bad_char_at_comparison.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_char_at_comparison --- - ⚠ deepscan(bad-char-at-comparison): Invalid comparison with `charAt` method ╭─[bad_char_at_comparison.tsx:1:1] 1 │ a.charAt(4) === 'aa' @@ -56,4 +55,3 @@ expression: bad_char_at_comparison · ╰── `charAt` called here ╰──── help: `String.prototype.charAt` returns a string of length 1. If the return value is compared with a string of length greater than 1, the comparison will always be false. - diff --git a/crates/oxc_linter/src/snapshots/bad_comparison_sequence.snap b/crates/oxc_linter/src/snapshots/bad_comparison_sequence.snap index b51b482bcb024..cfc39f1e181c4 100644 --- a/crates/oxc_linter/src/snapshots/bad_comparison_sequence.snap +++ b/crates/oxc_linter/src/snapshots/bad_comparison_sequence.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_comparison_sequence --- - ⚠ deepscan(bad-comparison-sequence): Bad comparison sequence ╭─[bad_comparison_sequence.tsx:1:5] 1 │ if (a == b == c) { console.log('foo') } @@ -254,4 +253,3 @@ expression: bad_comparison_sequence · ─────────── ╰──── help: Comparison result should not be used directly as an operand of another comparison. If you need to compare three or more operands, you should connect each comparison operation with logical AND operator (`&&`) - diff --git a/crates/oxc_linter/src/snapshots/bad_min_max_func.snap b/crates/oxc_linter/src/snapshots/bad_min_max_func.snap index 1d3188e189ce7..1b25c5c5324d5 100644 --- a/crates/oxc_linter/src/snapshots/bad_min_max_func.snap +++ b/crates/oxc_linter/src/snapshots/bad_min_max_func.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_min_max_func --- - ⚠ deepscan(bad-min-max-func): Math.min and Math.max combination leads to constant result ╭─[bad_min_max_func.tsx:1:1] 1 │ Math.min(Math.max(100, x), 0) @@ -58,4 +57,3 @@ expression: bad_min_max_func · ────────────────────────────────── ╰──── help: This evaluates to 155.0 because of the incorrect `Math.min`/`Math.max` combination - diff --git a/crates/oxc_linter/src/snapshots/bad_object_literal_comparison.snap b/crates/oxc_linter/src/snapshots/bad_object_literal_comparison.snap index 09dcd6942fff4..37af7d96695b0 100644 --- a/crates/oxc_linter/src/snapshots/bad_object_literal_comparison.snap +++ b/crates/oxc_linter/src/snapshots/bad_object_literal_comparison.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_object_literal_comparison --- - ⚠ deepscan(bad-object-literal-comparison): Unexpected object literal comparison. ╭─[bad_object_literal_comparison.tsx:1:5] 1 │ if (y === {}) { } @@ -72,4 +71,3 @@ expression: bad_object_literal_comparison · ──────────── ╰──── help: This comparison will always return true as array literals are never equal to each other. Consider using `Array.length` if empty checking was intended. - diff --git a/crates/oxc_linter/src/snapshots/bad_replace_all_arg.snap b/crates/oxc_linter/src/snapshots/bad_replace_all_arg.snap index 362dd3a13f161..3a7e856c5e12a 100644 --- a/crates/oxc_linter/src/snapshots/bad_replace_all_arg.snap +++ b/crates/oxc_linter/src/snapshots/bad_replace_all_arg.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: bad_replace_all_arg --- - ⚠ deepscan(bad-replace-all-arg): Global flag (g) is missing in the regular expression supplied to the `replaceAll` method. ╭─[bad_replace_all_arg.tsx:1:12] 1 │ withSpaces.replaceAll(/\s+/, ','); @@ -80,4 +79,3 @@ expression: bad_replace_all_arg 5 │ ╰──── help: To replace all occurrences of a string, use the `replaceAll` method with the global flag (g) in the regular expression. - diff --git a/crates/oxc_linter/src/snapshots/ban_ts_comment.snap b/crates/oxc_linter/src/snapshots/ban_ts_comment.snap index e6263912a271c..54ab968c9a461 100644 --- a/crates/oxc_linter/src/snapshots/ban_ts_comment.snap +++ b/crates/oxc_linter/src/snapshots/ban_ts_comment.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: ban_ts_comment --- - ⚠ typescript-eslint(ban-ts-comment): Do not use @ts-expect-error because it alters compilation errors. ╭─[ban_ts_comment.tsx:1:3] 1 │ // @ts-expect-error @@ -286,4 +285,3 @@ expression: ban_ts_comment 1 │ // @ts-check: TS1234 · ────────────────── ╰──── - diff --git a/crates/oxc_linter/src/snapshots/ban_tslint_comment.snap b/crates/oxc_linter/src/snapshots/ban_tslint_comment.snap index 23aefcf1ea5b7..c77339d912295 100644 --- a/crates/oxc_linter/src/snapshots/ban_tslint_comment.snap +++ b/crates/oxc_linter/src/snapshots/ban_tslint_comment.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: ban_tslint_comment --- - ⚠ typescript-eslint(ban-tslint-comment): tslint comment detected: "tslint:disable" ╭─[ban_tslint_comment.tsx:1:1] 1 │ /* tslint:disable */ @@ -53,4 +52,3 @@ expression: ban_tslint_comment 3 │ console.log(woah); 4 │ ╰──── - diff --git a/crates/oxc_linter/src/snapshots/ban_types.snap b/crates/oxc_linter/src/snapshots/ban_types.snap index 1a6b8c1401998..ec95e35f08dbc 100644 --- a/crates/oxc_linter/src/snapshots/ban_types.snap +++ b/crates/oxc_linter/src/snapshots/ban_types.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: ban_types --- - ⚠ typescript-eslint(ban-types): Do not use "String" as a type. Use "string" instead ╭─[ban_types.tsx:1:8] 1 │ let a: String; @@ -234,4 +233,3 @@ expression: ban_types 4 │ } ╰──── help: The `Function` type accepts any function-like value - diff --git a/crates/oxc_linter/src/snapshots/button_has_type.snap b/crates/oxc_linter/src/snapshots/button_has_type.snap index 01b884d39c490..f875614d3b687 100644 --- a/crates/oxc_linter/src/snapshots/button_has_type.snap +++ b/crates/oxc_linter/src/snapshots/button_has_type.snap @@ -2,7 +2,6 @@ source: crates/oxc_linter/src/tester.rs expression: button_has_type --- - ⚠ eslint-plugin-react(button-has-type): `button` elements must have an explicit `type` attribute. ╭─[button_has_type.tsx:1:2] 1 │