diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index a4c1a54ac2e..857c2338c38 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -1,8 +1,19 @@ //! 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_banned_types :: NoBannedTypes , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: use_flat_map :: UseFlatMap , self :: use_valid_for_direction :: UseValidForDirection ,] } } +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 ,] } } diff --git a/crates/rome_js_analyze/src/semantic_analyzers/nursery/no_explicit_any.rs b/crates/rome_js_analyze/src/analyzers/nursery/no_explicit_any.rs similarity index 100% rename from crates/rome_js_analyze/src/semantic_analyzers/nursery/no_explicit_any.rs rename to crates/rome_js_analyze/src/analyzers/nursery/no_explicit_any.rs diff --git a/crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs b/crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs index 955ada70f57..69f8c541fb6 100644 --- a/crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs +++ b/crates/rome_js_analyze/src/analyzers/style/no_negation_else.rs @@ -139,8 +139,8 @@ fn is_negation(node: &JsAnyExpression) -> Option { match (expr.operator().ok(), expr.argument().ok()) { ( Some(JsUnaryOperator::LogicalNot), - Some(JsAnyExpression::JsUnaryExpression(_)), - ) => Some(false), + Some(JsAnyExpression::JsUnaryExpression(inner_unary)), + ) => Some(inner_unary.operator().ok()? != JsUnaryOperator::LogicalNot), _ => Some(true), } } diff --git a/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs b/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs index bbcf7c832f6..71eb311f865 100644 --- a/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/semantic_analyzers/nursery.rs @@ -1,8 +1,20 @@ //! 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_explicit_any; +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; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_const_assign :: NoConstAssign , self :: no_explicit_any :: NoExplicitAny , self :: use_camel_case :: UseCamelCase , self :: use_exhaustive_dependencies :: UseExhaustiveDependencies ,] } } +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 ,] } } diff --git a/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js b/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js index 958380ad5a3..decca486351 100644 --- a/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js +++ b/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js @@ -1,4 +1,6 @@ -// valid +// invalid function f() { return !!specs.variables ? specs.variables(props) : {}; -} \ No newline at end of file +} +// valid +!-a ? b : c \ No newline at end of file diff --git a/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js.snap b/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js.snap index deda78fc7d5..2cd8ef0d62a 100644 --- a/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js.snap +++ b/crates/rome_js_analyze/tests/specs/style/noNegationElse/issue_3141.js.snap @@ -4,10 +4,33 @@ expression: issue_3141.js --- # Input ```js -// valid +// invalid function f() { return !!specs.variables ? specs.variables(props) : {}; } +// valid +!-a ? b : c +``` + +# Diagnostics +``` +issue_3141.js:6:1 lint/style/noNegationElse FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Invert blocks when performing a negation test. + + 4 │ } + 5 │ // valid + > 6 │ !-a ? b : c + │ ^^^^^^^^^^^ + + i Suggested fix: Exchange alternate and consequent of the node + + 4 4 │ } + 5 5 │ // valid + 6 │ - !-a·?·b·:·c + 6 │ + -a·?·c·:·b + + ```