From 0062d74091e394e2b9c8a99f44198b72edbbca33 Mon Sep 17 00:00:00 2001 From: ematipico Date: Fri, 28 Oct 2022 11:16:55 +0100 Subject: [PATCH] chore: merge --- crates/rome_cli/tests/commands/check.rs | 2 +- crates/rome_cli/tests/configs.rs | 5 +- .../downgrade_severity.snap | 5 +- .../should_disable_a_rule.snap | 2 +- .../main_commands_check/upgrade_severity.snap | 48 ++++--------------- .../rome_js_analyze/src/analyzers/nursery.rs | 12 +---- .../src/semantic_analyzers/nursery.rs | 15 +----- 7 files changed, 16 insertions(+), 73 deletions(-) diff --git a/crates/rome_cli/tests/commands/check.rs b/crates/rome_cli/tests/commands/check.rs index 53eb48952d70..f27baa740063 100644 --- a/crates/rome_cli/tests/commands/check.rs +++ b/crates/rome_cli/tests/commands/check.rs @@ -512,7 +512,7 @@ fn downgrade_severity() { .filter(|m| m.level == LogLevel::Error) .filter(|m| { let content = format!("{:#?}", m.content); - content.contains("security/noDebugger") + content.contains("correctness/noDebugger") }) .count(), 1 diff --git a/crates/rome_cli/tests/configs.rs b/crates/rome_cli/tests/configs.rs index b8d179fb12c8..3d34249a54ab 100644 --- a/crates/rome_cli/tests/configs.rs +++ b/crates/rome_cli/tests/configs.rs @@ -100,7 +100,7 @@ pub const CONFIG_LINTER_SUPPRESSED_RULE: &str = r#"{ "linter": { "rules": { "recommended": true, - "security": { + "correctness": { "noDebugger": "off" } } @@ -122,8 +122,7 @@ pub const CONFIG_LINTER_DOWNGRADE_DIAGNOSTIC: &str = r#"{ "linter": { "rules": { "recommended": true, - "security": { - "recommended": true, + "correctness": { "noDebugger": "warn" } } diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/downgrade_severity.snap b/crates/rome_cli/tests/snapshots/main_commands_check/downgrade_severity.snap index 4c756afbef93..f79bd68acc38 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/downgrade_severity.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/downgrade_severity.snap @@ -9,8 +9,7 @@ expression: content "linter": { "rules": { "recommended": true, - "security": { - "recommended": true, + "correctness": { "noDebugger": "warn" } } @@ -27,7 +26,7 @@ debugger; # Emitted Messages ```block -file.js:1:1 lint/security/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +file.js:1:1 lint/correctness/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This is an unexpected use of the debugger statement. diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/should_disable_a_rule.snap b/crates/rome_cli/tests/snapshots/main_commands_check/should_disable_a_rule.snap index 79df1afbb0ce..56d689b042a9 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/should_disable_a_rule.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/should_disable_a_rule.snap @@ -9,7 +9,7 @@ expression: content "linter": { "rules": { "recommended": true, - "security": { + "correctness": { "noDebugger": "off" } } diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/upgrade_severity.snap b/crates/rome_cli/tests/snapshots/main_commands_check/upgrade_severity.snap index 21dc214e5074..70be1645f9e6 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/upgrade_severity.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/upgrade_severity.snap @@ -1,6 +1,5 @@ --- source: crates/rome_cli/tests/snap_test.rs -assertion_line: 223 expression: content --- ## `rome.json` @@ -11,8 +10,7 @@ expression: content "rules": { "recommended": true, "nursery": { - "noUnreachable": "error", - "noUnusedVariables": "error" + "noInvalidConstructorSuper": "error" } } } @@ -22,13 +20,9 @@ expression: content ## `file.js` ```js -function f() { - for (;;) { - continue; - break; - } +class A extends B { + constructor() {} } - ``` # Termination Message @@ -40,40 +34,14 @@ errors where emitted while running checks # Emitted Messages ```block -file.js:4:9 lint/nursery/noUnreachable ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +file.js:1:9 lint/nursery/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × This code will never be reached ... - - 2 │ for (;;) { - 3 │ continue; - > 4 │ break; - │ ^^^^^^ - 5 │ } - 6 │ } + × This class extends another class and a super() call is expected. - i ... because this statement will continue the loop beforehand - - 1 │ function f() { - 2 │ for (;;) { - > 3 │ continue; + > 1 │ class A extends B { │ ^^^^^^^^^ - 4 │ break; - 5 │ } - - -``` - -```block -file.js:1:10 lint/nursery/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × This function is unused. - - > 1 │ function f() { - │ ^ - 2 │ for (;;) { - 3 │ continue; - - i Unused variables usually are result of incomplete refactoring, typos and other source of bugs. + 2 │ constructor() {} + 3 │ } ``` diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index 857c2338c38f..f74417a3e03e 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -1,19 +1,9 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use rome_analyze::declare_group; -mod no_auto_focus; mod no_banned_types; mod no_explicit_any; mod no_invalid_constructor_super; -mod no_new_symbol; -mod no_unreachable; -mod use_alt_text; -mod use_anchor_content; -mod use_blank_target; mod use_flat_map; -mod use_key_with_click_events; -mod use_key_with_mouse_events; -mod use_optional_chain; -mod use_valid_anchor; mod use_valid_for_direction; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_auto_focus :: NoAutoFocus , self :: no_banned_types :: NoBannedTypes , self :: no_explicit_any :: NoExplicitAny , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_new_symbol :: NoNewSymbol , self :: no_unreachable :: NoUnreachable , self :: use_alt_text :: UseAltText , self :: use_anchor_content :: UseAnchorContent , self :: use_blank_target :: UseBlankTarget , self :: use_flat_map :: UseFlatMap , self :: use_key_with_click_events :: UseKeyWithClickEvents , self :: use_key_with_mouse_events :: UseKeyWithMouseEvents , self :: use_optional_chain :: UseOptionalChain , self :: use_valid_anchor :: UseValidAnchor , self :: use_valid_for_direction :: UseValidForDirection ,] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_banned_types :: NoBannedTypes , self :: no_explicit_any :: NoExplicitAny , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: use_flat_map :: UseFlatMap , self :: use_valid_for_direction :: UseValidForDirection ,] } } diff --git a/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs b/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs index 71eb311f8659..5f3340f7de8a 100644 --- a/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs @@ -1,20 +1,7 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use rome_analyze::declare_group; -mod no_array_index_key; -mod no_children_prop; mod no_const_assign; -mod no_dangerously_set_inner_html; -mod no_dangerously_set_inner_html_with_children; -mod no_positive_tabindex; -mod no_render_return_value; -mod no_restricted_globals; -mod no_undeclared_variables; -mod no_unused_variables; -mod no_useless_fragments; -mod no_void_elements_with_children; -mod use_button_type; mod use_camel_case; mod use_exhaustive_dependencies; -mod use_fragment_syntax; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_array_index_key :: NoArrayIndexKey , self :: no_children_prop :: NoChildrenProp , self :: no_const_assign :: NoConstAssign , self :: no_dangerously_set_inner_html :: NoDangerouslySetInnerHtml , self :: no_dangerously_set_inner_html_with_children :: NoDangerouslySetInnerHtmlWithChildren , self :: no_positive_tabindex :: NoPositiveTabindex , self :: no_render_return_value :: NoRenderReturnValue , self :: no_restricted_globals :: NoRestrictedGlobals , self :: no_undeclared_variables :: NoUndeclaredVariables , self :: no_unused_variables :: NoUnusedVariables , self :: no_useless_fragments :: NoUselessFragments , self :: no_void_elements_with_children :: NoVoidElementsWithChildren , self :: use_button_type :: UseButtonType , self :: use_camel_case :: UseCamelCase , self :: use_exhaustive_dependencies :: UseExhaustiveDependencies , self :: use_fragment_syntax :: UseFragmentSyntax ,] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_const_assign :: NoConstAssign , self :: use_camel_case :: UseCamelCase , self :: use_exhaustive_dependencies :: UseExhaustiveDependencies ,] } }