From afedf3b21c29686ae6794745c23ea1b27e7b8b2e Mon Sep 17 00:00:00 2001 From: kaioduarte Date: Thu, 24 Nov 2022 16:47:44 +0000 Subject: [PATCH 01/11] feat(rome_js_analyze): `useExponentiation` rule --- .../src/categories.rs | 1 + .../rome_js_analyze/src/analyzers/nursery.rs | 3 +- .../analyzers/nursery/use_exponentiation.rs | 303 +++++++++ .../nursery/useExponentiation/invalid.js | 36 ++ .../nursery/useExponentiation/invalid.js.snap | 610 ++++++++++++++++++ .../invalidAdjacentTokens.js | 15 + .../invalidAdjacentTokens.js.snap | 260 ++++++++ .../invalidBaseExpoentHigherPrecedence.js | 10 + ...invalidBaseExpoentHigherPrecedence.js.snap | 234 +++++++ .../invalidBaseExpoentLowerPrecedence.js | 12 + .../invalidBaseExpoentLowerPrecedence.js.snap | 284 ++++++++ .../invalidParentsWithHigherPrecedence.js | 20 + ...invalidParentsWithHigherPrecedence.js.snap | 455 +++++++++++++ .../invalidParentsWithLowerPrecedence.js | 24 + .../invalidParentsWithLowerPrecedence.js.snap | 320 +++++++++ .../invalidUnaryExpression.js | 9 + .../invalidUnaryExpression.js.snap | 209 ++++++ .../invalidWithoutAutofix.js | 19 + .../invalidWithoutAutofix.js.snap | 246 +++++++ .../specs/nursery/useExponentiation/valid.js | 28 + .../nursery/useExponentiation/valid.js.snap | 39 ++ .../src/configuration/linter/rules.rs | 5 +- editors/vscode/configuration_schema.json | 11 + npm/backend-jsonrpc/src/workspace.ts | 5 + npm/rome/configuration_schema.json | 11 + website/src/pages/lint/rules/index.mdx | 6 + .../src/pages/lint/rules/useExponentiation.md | 111 ++++ 27 files changed, 3284 insertions(+), 2 deletions(-) create mode 100644 crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap create mode 100644 website/src/pages/lint/rules/useExponentiation.md diff --git a/crates/rome_diagnostics_categories/src/categories.rs b/crates/rome_diagnostics_categories/src/categories.rs index 95ffe2e41d6..65f2043bd32 100644 --- a/crates/rome_diagnostics_categories/src/categories.rs +++ b/crates/rome_diagnostics_categories/src/categories.rs @@ -99,6 +99,7 @@ define_dategories! { "lint/nursery/useConst":"https://docs.rome.tools/lint/rules/useConst", "lint/nursery/useDefaultSwitchClauseLast":"https://docs.rome.tools/lint/rules/useDefaultSwitchClauseLast", "lint/nursery/useExhaustiveDependencies": "https://docs.rome.tools/lint/rules/useExhaustiveDependencies", + "lint/nursery/useExponentiation": "https://docs.rome.tools/lint/rules/useExponentiation", "lint/nursery/useFlatMap": "https://docs.rome.tools/lint/rules/useFlatMap", "lint/nursery/useNumericLiterals": "https://docs.rome.tools/lint/rules/useNumericLiterals", "lint/nursery/useValidForDirection": "https://docs.rome.tools/lint/rules/useValidForDirection", diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index 0be2c019938..ed918c78a9b 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -21,7 +21,8 @@ mod no_string_case_mismatch; mod no_unsafe_finally; mod no_void_type_return; mod use_default_switch_clause_last; +mod use_exponentiation; mod use_flat_map; mod use_numeric_literals; mod use_valid_for_direction; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_exponentiation :: UseExponentiation , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs new file mode 100644 index 00000000000..db236cb92c6 --- /dev/null +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs @@ -0,0 +1,303 @@ +use crate::JsRuleAction; +use rome_analyze::context::RuleContext; +use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic}; +use rome_console::markup; +use rome_diagnostics::Applicability; +use rome_js_factory::{make, syntax::T}; +use rome_js_syntax::{AnyJsExpression, JsBinaryOperator, JsCallExpression, OperatorPrecedence}; +use rome_rowan::{AstNode, AstNodeList, AstSeparatedList, BatchMutationExt}; +use std::iter; + +declare_rule! { + /// Disallow the use of `Math.pow` in favor of the `**` operator. + /// + /// > Introduced in ES2016, the infix exponentiation operator ** is an alternative for the standard Math.pow function. + /// > Infix notation is considered to be more readable and thus more preferable than the function notation. + /// + /// Source: https://eslint.org/docs/latest/rules/prefer-exponentiation-operator + /// + /// ## Examples + /// + /// ### Invalid + /// + /// ```js,expect_diagnostic + /// const foo = Math.pow(2, 8); + /// ``` + /// + /// ```js,expect_diagnostic + /// const bar = Math.pow(a, b); + /// ``` + /// + /// ```js,expect_diagnostic + /// let baz = Math.pow(a + b, c + d); + /// ``` + /// + /// ```js,expect_diagnostic + /// let quux = Math.pow(-1, n); + /// ``` + /// + /// ### Valid + /// + /// ```js + /// const foo = 2 ** 8; + /// + /// const bar = a ** b; + /// + /// let baz = (a + b) ** (c + d); + /// + /// let quux = (-1) ** n; + /// ``` + /// + pub(crate) UseExponentiation { + version: "11.0.0", + name: "useExponentiation", + recommended: false, + } +} + +impl Rule for UseExponentiation { + type Query = Ast; + type State = (); + type Signals = Option; + type Options = (); + + fn run(ctx: &RuleContext) -> Self::Signals { + let node = ctx.query(); + + match node.callee().ok()?.omit_parentheses() { + AnyJsExpression::JsStaticMemberExpression(static_member_expr) => { + let has_math = static_member_expr + .object() + .ok()? + .omit_parentheses() + .as_reference_identifier()? + .has_name("Math"); + let has_pow = static_member_expr + .member() + .ok()? + .as_js_name()? + .value_token() + .ok()? + .token_text_trimmed() + == "pow"; + + if has_math && has_pow { + return Some(()); + } + } + AnyJsExpression::JsComputedMemberExpression(computed_member_expr) => { + let has_math = computed_member_expr + .object() + .ok()? + .omit_parentheses() + .as_reference_identifier()? + .has_name("Math"); + let member_expr = computed_member_expr.member().ok()?; + + let has_pow = match member_expr { + AnyJsExpression::AnyJsLiteralExpression(literal_expr) => { + literal_expr + .as_js_string_literal_expression()? + .inner_string_text() + .ok()? + .text() + == "pow" + } + AnyJsExpression::JsTemplateExpression(template) => { + template.elements().len() == 1 + && template + .elements() + .into_iter() + .next()? + .as_js_template_chunk_element()? + .syntax() + .text_trimmed() + == "pow" + } + _ => false, + }; + + if has_math && has_pow { + return Some(()); + } + } + _ => {} + } + + None + } + + fn diagnostic(ctx: &RuleContext, _: &Self::State) -> Option { + let diagnostic = RuleDiagnostic::new( + rule_category!(), + ctx.query().range(), + "Use the '**' operator instead of 'Math.pow'.", + ); + + Some(diagnostic) + } + + fn action(ctx: &RuleContext, _: &Self::State) -> Option { + let mut mutation = ctx.root().begin(); + let node = ctx.query(); + + if !should_suggest_fix(node)? { + return None; + } + + let [base, exponent] = node.get_arguments_by_index([0, 1]); + let mut base_expr = base?.as_any_js_expression()?.clone().omit_parentheses(); + let mut exponent_expr = exponent?.as_any_js_expression()?.clone().omit_parentheses(); + + if does_base_need_parens(&base_expr)? { + base_expr = parenthesize_js_any_expression(&base_expr); + } + + if does_exponent_need_parens(&exponent_expr)? { + exponent_expr = parenthesize_js_any_expression(&exponent_expr); + } + + let new_node = make::js_binary_expression(base_expr, make::token(T![**]), exponent_expr); + + if let Some(parent) = does_parent_expression_need_parens(node) { + mutation.replace_node( + AnyJsExpression::from(node.clone()), + parenthesize_js_any_expression(&AnyJsExpression::from(new_node)), + ); + mutation.replace_node(parent.clone(), parenthesize_js_any_expression(&parent)); + } else { + mutation.replace_node( + AnyJsExpression::from(node.clone()), + AnyJsExpression::from(new_node), + ); + } + + Some(JsRuleAction { + category: ActionCategory::QuickFix, + applicability: Applicability::MaybeIncorrect, + message: markup! { "Use the '**' operator instead of 'Math.pow'." }.to_owned(), + mutation, + }) + } +} + +/// Verify if the autofix is safe to be applied and won't remove comments. +/// Argument list is considered valid if its length is 2 and there's no spread arg. +fn should_suggest_fix(node: &JsCallExpression) -> Option { + let arguments = node.arguments().ok()?; + let args_count = arguments.args().len(); + + Some( + args_count == 2 + && !arguments.l_paren_token().ok()?.has_leading_comments() + && !arguments.l_paren_token().ok()?.has_trailing_comments() + && !arguments.r_paren_token().ok()?.has_leading_comments() + && !arguments.r_paren_token().ok()?.has_trailing_comments() + && arguments + .args() + .into_iter() + .filter_map(|arg| arg.ok()) + .all(|arg| { + !arg.syntax().has_leading_comments() + && !arg.syntax().has_trailing_comments() + && arg.as_js_spread().is_none() + }), + ) +} + +/// Wraps a [AnyJsExpression] in paretheses +fn parenthesize_js_any_expression(expr: &AnyJsExpression) -> AnyJsExpression { + AnyJsExpression::from(make::js_parenthesized_expression( + make::token(T!['(']), + expr.clone(), + make::token(T![')']), + )) +} + +/// Determines whether the given node needs parens if used as the base in an exponentiation binary expression. +fn does_base_need_parens(expr: &AnyJsExpression) -> Option { + Some( + // '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c + expr.precedence().ok()? <= OperatorPrecedence::Exponential + // An unary operator cannot be used immediately before an exponentiation expression + || expr.as_js_unary_expression().is_some() + || expr.as_js_await_expression().is_some(), + ) +} + +/// Determines whether the given node needs parens if used as the exponent in an exponentiation binary expression. +fn does_exponent_need_parens(expr: &AnyJsExpression) -> Option { + Some(expr.precedence().ok()? < OperatorPrecedence::Exponential) +} + +/// Determines whether the given parent node needs parens if used as the exponent in an exponentiation binary expression. +fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option { + // Skips already parenthesized expressions + if has_parenthesized_parent_expression(AnyJsExpression::from(node.clone()))? { + return None; + } + + let parent = node.parent::()?; + + let needs_parentheses = match parent.clone() { + AnyJsExpression::JsBinaryExpression(bin_expr) => { + bin_expr.operator().ok()? != JsBinaryOperator::Exponent + && bin_expr.right().ok()?.as_js_call_expression()? != node + } + AnyJsExpression::JsCallExpression(call_expr) => !call_expr + .arguments() + .ok()? + .args() + .iter() + .filter_map(|arg| { + let binding = arg.ok()?; + return binding + .as_any_js_expression()? + .as_js_call_expression() + .cloned(); + }) + .any(|arg| &arg == node), + AnyJsExpression::JsNewExpression(new_expr) => !new_expr + .arguments()? + .args() + .iter() + .filter_map(|arg| { + let binding = arg.ok()?; + return binding + .as_any_js_expression()? + .as_js_call_expression() + .cloned(); + }) + .any(|arg| &arg == node), + AnyJsExpression::JsComputedMemberExpression(member_expr) => { + member_expr.member().ok()?.as_js_call_expression()? != node + } + AnyJsExpression::JsStaticMemberExpression(_) + | AnyJsExpression::JsUnaryExpression(_) + | AnyJsExpression::JsTemplateExpression(_) => true, + _ => false, + }; + + if needs_parentheses && parent.precedence().ok()? >= OperatorPrecedence::Exponential { + return Some(parent); + } + + None +} + +/// Traversal by parent to check if expression has a parenthesized parent. +fn has_parenthesized_parent_expression(expression: AnyJsExpression) -> Option { + let mut has_parenthesized_parent = false; + + iter::successors(expression.parent::(), |parent| { + if matches!(parent, AnyJsExpression::JsParenthesizedExpression(_)) { + has_parenthesized_parent = true; + parent.parent::() + } else { + None + } + }) + .last(); + + Some(has_parenthesized_parent) +} diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js new file mode 100644 index 00000000000..8b3819cc2cf --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js @@ -0,0 +1,36 @@ +Math.pow(a, b); +(Math).pow(a, b); + +// able to catch some workarounds +Math['pow'](a, b); +Math["pow"](a, b); +Math[`pow`](a, b); +(Math)['pow'](a, b); +(Math)["pow"](a, b); +(Math)[`pow`](a, b); + +// non-expression parents that don't require parens +var x = Math.pow(a, b); +if(Math.pow(a, b)){} +for(;Math.pow(a, b);){} +switch(foo){ case Math.pow(a, b): break; } +{ foo: Math.pow(a, b) } +function foo(bar, baz = Math.pow(a, b), quux){} +`${Math.pow(a, b)}` + +// already parenthesised, shouldn't insert extra parens ++(Math.pow(a, b)) +(Math.pow(a, b)).toString() + +// Optional chaining +Math.pow?.(a, b) +Math?.pow(a, b) +Math?.pow?.(a, b) +;(Math?.pow)(a, b) +;(Math?.pow)?.(a, b) + +// doesn't put extra parens +Math.pow((a + b), (c + d)) + +// tokens that can be adjacent +a+Math.pow(b, c)+d diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap new file mode 100644 index 00000000000..05e6553a2f0 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap @@ -0,0 +1,610 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalid.js +--- +# Input +```js +Math.pow(a, b); +(Math).pow(a, b); + +// able to catch some workarounds +Math['pow'](a, b); +Math["pow"](a, b); +Math[`pow`](a, b); +(Math)['pow'](a, b); +(Math)["pow"](a, b); +(Math)[`pow`](a, b); + +// non-expression parents that don't require parens +var x = Math.pow(a, b); +if(Math.pow(a, b)){} +for(;Math.pow(a, b);){} +switch(foo){ case Math.pow(a, b): break; } +{ foo: Math.pow(a, b) } +function foo(bar, baz = Math.pow(a, b), quux){} +`${Math.pow(a, b)}` + +// already parenthesised, shouldn't insert extra parens ++(Math.pow(a, b)) +(Math.pow(a, b)).toString() + +// Optional chaining +Math.pow?.(a, b) +Math?.pow(a, b) +Math?.pow?.(a, b) +;(Math?.pow)(a, b) +;(Math?.pow)?.(a, b) + +// doesn't put extra parens +Math.pow((a + b), (c + d)) + +// tokens that can be adjacent +a+Math.pow(b, c)+d + +``` + +# Diagnostics +``` +invalid.js:1:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + > 1 │ Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 2 │ (Math).pow(a, b); + 3 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 │ - Math.pow(a,·b); + 1 │ + a**b; + 2 2 │ (Math).pow(a, b); + 3 3 │ + + +``` + +``` +invalid.js:2:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ Math.pow(a, b); + > 2 │ (Math).pow(a, b); + │ ^^^^^^^^^^^^^^^^ + 3 │ + 4 │ // able to catch some workarounds + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ Math.pow(a, b); + 2 │ - (Math).pow(a,·b); + 2 │ + a**b; + 3 3 │ + 4 4 │ // able to catch some workarounds + + +``` + +``` +invalid.js:5:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ // able to catch some workarounds + > 5 │ Math['pow'](a, b); + │ ^^^^^^^^^^^^^^^^^ + 6 │ Math["pow"](a, b); + 7 │ Math[`pow`](a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 3 3 │ + 4 4 │ // able to catch some workarounds + 5 │ - Math['pow'](a,·b); + 5 │ + a**b; + 6 6 │ Math["pow"](a, b); + 7 7 │ Math[`pow`](a, b); + + +``` + +``` +invalid.js:6:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ // able to catch some workarounds + 5 │ Math['pow'](a, b); + > 6 │ Math["pow"](a, b); + │ ^^^^^^^^^^^^^^^^^ + 7 │ Math[`pow`](a, b); + 8 │ (Math)['pow'](a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ // able to catch some workarounds + 5 5 │ Math['pow'](a, b); + 6 │ - Math["pow"](a,·b); + 6 │ + a**b; + 7 7 │ Math[`pow`](a, b); + 8 8 │ (Math)['pow'](a, b); + + +``` + +``` +invalid.js:7:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 5 │ Math['pow'](a, b); + 6 │ Math["pow"](a, b); + > 7 │ Math[`pow`](a, b); + │ ^^^^^^^^^^^^^^^^^ + 8 │ (Math)['pow'](a, b); + 9 │ (Math)["pow"](a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 5 5 │ Math['pow'](a, b); + 6 6 │ Math["pow"](a, b); + 7 │ - Math[`pow`](a,·b); + 7 │ + a**b; + 8 8 │ (Math)['pow'](a, b); + 9 9 │ (Math)["pow"](a, b); + + +``` + +``` +invalid.js:8:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ Math["pow"](a, b); + 7 │ Math[`pow`](a, b); + > 8 │ (Math)['pow'](a, b); + │ ^^^^^^^^^^^^^^^^^^^ + 9 │ (Math)["pow"](a, b); + 10 │ (Math)[`pow`](a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ Math["pow"](a, b); + 7 7 │ Math[`pow`](a, b); + 8 │ - (Math)['pow'](a,·b); + 8 │ + a**b; + 9 9 │ (Math)["pow"](a, b); + 10 10 │ (Math)[`pow`](a, b); + + +``` + +``` +invalid.js:9:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ Math[`pow`](a, b); + 8 │ (Math)['pow'](a, b); + > 9 │ (Math)["pow"](a, b); + │ ^^^^^^^^^^^^^^^^^^^ + 10 │ (Math)[`pow`](a, b); + 11 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 7 7 │ Math[`pow`](a, b); + 8 8 │ (Math)['pow'](a, b); + 9 │ - (Math)["pow"](a,·b); + 9 │ + a**b; + 10 10 │ (Math)[`pow`](a, b); + 11 11 │ + + +``` + +``` +invalid.js:10:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 8 │ (Math)['pow'](a, b); + 9 │ (Math)["pow"](a, b); + > 10 │ (Math)[`pow`](a, b); + │ ^^^^^^^^^^^^^^^^^^^ + 11 │ + 12 │ // non-expression parents that don't require parens + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 8 8 │ (Math)['pow'](a, b); + 9 9 │ (Math)["pow"](a, b); + 10 │ - (Math)[`pow`](a,·b); + 10 │ + a**b; + 11 11 │ + 12 12 │ // non-expression parents that don't require parens + + +``` + +``` +invalid.js:13:9 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ // non-expression parents that don't require parens + > 13 │ var x = Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 14 │ if(Math.pow(a, b)){} + 15 │ for(;Math.pow(a, b);){} + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 11 11 │ + 12 12 │ // non-expression parents that don't require parens + 13 │ - var·x·=·Math.pow(a,·b); + 13 │ + var·x·=·a**b; + 14 14 │ if(Math.pow(a, b)){} + 15 15 │ for(;Math.pow(a, b);){} + + +``` + +``` +invalid.js:14:4 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ // non-expression parents that don't require parens + 13 │ var x = Math.pow(a, b); + > 14 │ if(Math.pow(a, b)){} + │ ^^^^^^^^^^^^^^ + 15 │ for(;Math.pow(a, b);){} + 16 │ switch(foo){ case Math.pow(a, b): break; } + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ // non-expression parents that don't require parens + 13 13 │ var x = Math.pow(a, b); + 14 │ - if(Math.pow(a,·b)){} + 14 │ + if(a**b){} + 15 15 │ for(;Math.pow(a, b);){} + 16 16 │ switch(foo){ case Math.pow(a, b): break; } + + +``` + +``` +invalid.js:15:6 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ var x = Math.pow(a, b); + 14 │ if(Math.pow(a, b)){} + > 15 │ for(;Math.pow(a, b);){} + │ ^^^^^^^^^^^^^^ + 16 │ switch(foo){ case Math.pow(a, b): break; } + 17 │ { foo: Math.pow(a, b) } + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 13 13 │ var x = Math.pow(a, b); + 14 14 │ if(Math.pow(a, b)){} + 15 │ - for(;Math.pow(a,·b);){} + 15 │ + for(;a**b;){} + 16 16 │ switch(foo){ case Math.pow(a, b): break; } + 17 17 │ { foo: Math.pow(a, b) } + + +``` + +``` +invalid.js:16:19 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 14 │ if(Math.pow(a, b)){} + 15 │ for(;Math.pow(a, b);){} + > 16 │ switch(foo){ case Math.pow(a, b): break; } + │ ^^^^^^^^^^^^^^ + 17 │ { foo: Math.pow(a, b) } + 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 14 14 │ if(Math.pow(a, b)){} + 15 15 │ for(;Math.pow(a, b);){} + 16 │ - switch(foo){·case·Math.pow(a,·b):·break;·} + 16 │ + switch(foo){·case·a**b:·break;·} + 17 17 │ { foo: Math.pow(a, b) } + 18 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + + +``` + +``` +invalid.js:17:8 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 15 │ for(;Math.pow(a, b);){} + 16 │ switch(foo){ case Math.pow(a, b): break; } + > 17 │ { foo: Math.pow(a, b) } + │ ^^^^^^^^^^^^^^ + 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + 19 │ `${Math.pow(a, b)}` + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 15 15 │ for(;Math.pow(a, b);){} + 16 16 │ switch(foo){ case Math.pow(a, b): break; } + 17 │ - {·foo:·Math.pow(a,·b)·} + 17 │ + {·foo:·a**b·} + 18 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + 19 19 │ `${Math.pow(a, b)}` + + +``` + +``` +invalid.js:18:25 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 16 │ switch(foo){ case Math.pow(a, b): break; } + 17 │ { foo: Math.pow(a, b) } + > 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + │ ^^^^^^^^^^^^^^ + 19 │ `${Math.pow(a, b)}` + 20 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 16 16 │ switch(foo){ case Math.pow(a, b): break; } + 17 17 │ { foo: Math.pow(a, b) } + 18 │ - function·foo(bar,·baz·=·Math.pow(a,·b),·quux){} + 18 │ + function·foo(bar,·baz·=·a**b,·quux){} + 19 19 │ `${Math.pow(a, b)}` + 20 20 │ + + +``` + +``` +invalid.js:19:4 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 17 │ { foo: Math.pow(a, b) } + 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + > 19 │ `${Math.pow(a, b)}` + │ ^^^^^^^^^^^^^^ + 20 │ + 21 │ // already parenthesised, shouldn't insert extra parens + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 17 17 │ { foo: Math.pow(a, b) } + 18 18 │ function foo(bar, baz = Math.pow(a, b), quux){} + 19 │ - `${Math.pow(a,·b)}` + 19 │ + `${a**b}` + 20 20 │ + 21 21 │ // already parenthesised, shouldn't insert extra parens + + +``` + +``` +invalid.js:22:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 21 │ // already parenthesised, shouldn't insert extra parens + > 22 │ +(Math.pow(a, b)) + │ ^^^^^^^^^^^^^^ + 23 │ (Math.pow(a, b)).toString() + 24 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 20 20 │ + 21 21 │ // already parenthesised, shouldn't insert extra parens + 22 │ - +(Math.pow(a,·b)) + 22 │ + +(a**b) + 23 23 │ (Math.pow(a, b)).toString() + 24 24 │ + + +``` + +``` +invalid.js:23:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 21 │ // already parenthesised, shouldn't insert extra parens + 22 │ +(Math.pow(a, b)) + > 23 │ (Math.pow(a, b)).toString() + │ ^^^^^^^^^^^^^^ + 24 │ + 25 │ // Optional chaining + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 21 21 │ // already parenthesised, shouldn't insert extra parens + 22 22 │ +(Math.pow(a, b)) + 23 │ - (Math.pow(a,·b)).toString() + 23 │ + (a**b).toString() + 24 24 │ + 25 25 │ // Optional chaining + + +``` + +``` +invalid.js:26:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 25 │ // Optional chaining + > 26 │ Math.pow?.(a, b) + │ ^^^^^^^^^^^^^^^^ + 27 │ Math?.pow(a, b) + 28 │ Math?.pow?.(a, b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 24 24 │ + 25 25 │ // Optional chaining + 26 │ - Math.pow?.(a,·b) + 26 │ + a**b + 27 27 │ Math?.pow(a, b) + 28 28 │ Math?.pow?.(a, b) + + +``` + +``` +invalid.js:27:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 25 │ // Optional chaining + 26 │ Math.pow?.(a, b) + > 27 │ Math?.pow(a, b) + │ ^^^^^^^^^^^^^^^ + 28 │ Math?.pow?.(a, b) + 29 │ ;(Math?.pow)(a, b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 25 25 │ // Optional chaining + 26 26 │ Math.pow?.(a, b) + 27 │ - Math?.pow(a,·b) + 27 │ + a**b + 28 28 │ Math?.pow?.(a, b) + 29 29 │ ;(Math?.pow)(a, b) + + +``` + +``` +invalid.js:28:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 26 │ Math.pow?.(a, b) + 27 │ Math?.pow(a, b) + > 28 │ Math?.pow?.(a, b) + │ ^^^^^^^^^^^^^^^^^ + 29 │ ;(Math?.pow)(a, b) + 30 │ ;(Math?.pow)?.(a, b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 26 26 │ Math.pow?.(a, b) + 27 27 │ Math?.pow(a, b) + 28 │ - Math?.pow?.(a,·b) + 28 │ + a**b + 29 29 │ ;(Math?.pow)(a, b) + 30 30 │ ;(Math?.pow)?.(a, b) + + +``` + +``` +invalid.js:29:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 27 │ Math?.pow(a, b) + 28 │ Math?.pow?.(a, b) + > 29 │ ;(Math?.pow)(a, b) + │ ^^^^^^^^^^^^^^^^^ + 30 │ ;(Math?.pow)?.(a, b) + 31 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 27 27 │ Math?.pow(a, b) + 28 28 │ Math?.pow?.(a, b) + 29 │ - ;(Math?.pow)(a,·b) + 29 │ + ;a**b + 30 30 │ ;(Math?.pow)?.(a, b) + 31 31 │ + + +``` + +``` +invalid.js:30:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 28 │ Math?.pow?.(a, b) + 29 │ ;(Math?.pow)(a, b) + > 30 │ ;(Math?.pow)?.(a, b) + │ ^^^^^^^^^^^^^^^^^^^ + 31 │ + 32 │ // doesn't put extra parens + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 28 28 │ Math?.pow?.(a, b) + 29 29 │ ;(Math?.pow)(a, b) + 30 │ - ;(Math?.pow)?.(a,·b) + 30 │ + ;a**b + 31 31 │ + 32 32 │ // doesn't put extra parens + + +``` + +``` +invalid.js:33:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 32 │ // doesn't put extra parens + > 33 │ Math.pow((a + b), (c + d)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 34 │ + 35 │ // tokens that can be adjacent + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 31 31 │ + 32 32 │ // doesn't put extra parens + 33 │ - Math.pow((a·+·b),·(c·+·d)) + 33 │ + (a·+·b)**(c·+·d) + 34 34 │ + 35 35 │ // tokens that can be adjacent + + +``` + +``` +invalid.js:36:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 35 │ // tokens that can be adjacent + > 36 │ a+Math.pow(b, c)+d + │ ^^^^^^^^^^^^^^ + 37 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 34 34 │ + 35 35 │ // tokens that can be adjacent + 36 │ - a+Math.pow(b,·c)+d + 36 │ + a+b**c+d + 37 37 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js new file mode 100644 index 00000000000..06f52066619 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js @@ -0,0 +1,15 @@ +// tokens that cannot be adjacent +a+Math.pow(++b, c); +(a)+(Math).pow((++b), c); + +// not supported yet +//Math.pow(a, b)in c +//Math.pow(a, (b))in (c) +//a+Math.pow(++b, c)in d +//a+Math.pow( ++b, c )in d + +// tokens that cannot be adjacent, but the autofix inserts parens required for precedence ++Math.pow(++a, b) +Math.pow(a, b) + Math.pow(c, d) +Math.pow(Math.pow(a, b), Math.pow(c, d)) +Math.pow(a, b)**Math.pow(c, d) diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap new file mode 100644 index 00000000000..72a433a0e52 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap @@ -0,0 +1,260 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidAdjacentTokens.js +--- +# Input +```js +// tokens that cannot be adjacent +a+Math.pow(++b, c); +(a)+(Math).pow((++b), c); + +// not supported yet +//Math.pow(a, b)in c +//Math.pow(a, (b))in (c) +//a+Math.pow(++b, c)in d +//a+Math.pow( ++b, c )in d + +// tokens that cannot be adjacent, but the autofix inserts parens required for precedence ++Math.pow(++a, b) +Math.pow(a, b) + Math.pow(c, d) +Math.pow(Math.pow(a, b), Math.pow(c, d)) +Math.pow(a, b)**Math.pow(c, d) + +``` + +# Diagnostics +``` +invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // tokens that cannot be adjacent + > 2 │ a+Math.pow(++b, c); + │ ^^^^^^^^^^^^^^^^ + 3 │ (a)+(Math).pow((++b), c); + 4 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // tokens that cannot be adjacent + 2 │ - a+Math.pow(++b,·c); + 2 │ + a+++b**c; + 3 3 │ (a)+(Math).pow((++b), c); + 4 4 │ + + +``` + +``` +invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // tokens that cannot be adjacent + 2 │ a+Math.pow(++b, c); + > 3 │ (a)+(Math).pow((++b), c); + │ ^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ // not supported yet + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // tokens that cannot be adjacent + 2 2 │ a+Math.pow(++b, c); + 3 │ - (a)+(Math).pow((++b),·c); + 3 │ + (a)+++b**c; + 4 4 │ + 5 5 │ // not supported yet + + +``` + +``` +invalidAdjacentTokens.js:12:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + > 12 │ +Math.pow(++a, b) + │ ^^^^^^^^^^^^^^^^ + 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 10 10 │ + 11 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + 12 │ - +Math.pow(++a,·b) + 12 │ + +(++a**b) + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + + +``` + +``` +invalidAdjacentTokens.js:13:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + 12 │ +Math.pow(++a, b) + > 13 │ Math.pow(a, b) + Math.pow(c, d) + │ ^^^^^^^^^^^^^^ + 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 │ Math.pow(a, b)**Math.pow(c, d) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 11 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + 12 12 │ +Math.pow(++a, b) + 13 │ - Math.pow(a,·b)·+·Math.pow(c,·d) + 13 │ + a**b·+·Math.pow(c,·d) + 14 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 15 │ Math.pow(a, b)**Math.pow(c, d) + + +``` + +``` +invalidAdjacentTokens.js:13:18 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + 12 │ +Math.pow(++a, b) + > 13 │ Math.pow(a, b) + Math.pow(c, d) + │ ^^^^^^^^^^^^^^ + 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 │ Math.pow(a, b)**Math.pow(c, d) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 11 11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence + 12 12 │ +Math.pow(++a, b) + 13 │ - Math.pow(a,·b)·+·Math.pow(c,·d) + 13 │ + Math.pow(a,·b)·+·c**d + 14 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 15 │ Math.pow(a, b)**Math.pow(c, d) + + +``` + +``` +invalidAdjacentTokens.js:14:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ +Math.pow(++a, b) + 13 │ Math.pow(a, b) + Math.pow(c, d) + > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ +Math.pow(++a, b) + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d)) + 14 │ + Math.pow(a,·b)**Math.pow(c,·d) + 15 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 16 │ + + +``` + +``` +invalidAdjacentTokens.js:14:10 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ +Math.pow(++a, b) + 13 │ Math.pow(a, b) + Math.pow(c, d) + > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + │ ^^^^^^^^^^^^^^ + 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ +Math.pow(++a, b) + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d)) + 14 │ + Math.pow(a**b,·Math.pow(c,·d)) + 15 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 16 │ + + +``` + +``` +invalidAdjacentTokens.js:14:26 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ +Math.pow(++a, b) + 13 │ Math.pow(a, b) + Math.pow(c, d) + > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + │ ^^^^^^^^^^^^^^ + 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ +Math.pow(++a, b) + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d)) + 14 │ + Math.pow(Math.pow(a,·b),·c**d) + 15 15 │ Math.pow(a, b)**Math.pow(c, d) + 16 16 │ + + +``` + +``` +invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + > 15 │ Math.pow(a, b)**Math.pow(c, d) + │ ^^^^^^^^^^^^^^ + 16 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 │ - Math.pow(a,·b)**Math.pow(c,·d) + 15 │ + a**b**Math.pow(c,·d) + 16 16 │ + + +``` + +``` +invalidAdjacentTokens.js:15:17 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + > 15 │ Math.pow(a, b)**Math.pow(c, d) + │ ^^^^^^^^^^^^^^ + 16 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 13 13 │ Math.pow(a, b) + Math.pow(c, d) + 14 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d)) + 15 │ - Math.pow(a,·b)**Math.pow(c,·d) + 15 │ + Math.pow(a,·b)**c**d + 16 16 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js new file mode 100644 index 00000000000..91ddb73c1c1 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js @@ -0,0 +1,10 @@ + // base and exponent with a higher precedence + Math.pow(2, 3) + Math.pow(a.foo, b) + Math.pow(a, b.foo) + Math.pow(a(), b) + Math.pow(a, b()) + Math.pow(++a, ++b) + Math.pow(a++, ++b) + Math.pow(a--, b--) + Math.pow(--a, b--) diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap new file mode 100644 index 00000000000..7ecff81c383 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap @@ -0,0 +1,234 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidBaseExpoentHigherPrecedence.js +--- +# Input +```js + // base and exponent with a higher precedence + Math.pow(2, 3) + Math.pow(a.foo, b) + Math.pow(a, b.foo) + Math.pow(a(), b) + Math.pow(a, b()) + Math.pow(++a, ++b) + Math.pow(a++, ++b) + Math.pow(a--, b--) + Math.pow(--a, b--) + +``` + +# Diagnostics +``` +invalidBaseExpoentHigherPrecedence.js:2:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // base and exponent with a higher precedence + > 2 │ Math.pow(2, 3) + │ ^^^^^^^^^^^^^^ + 3 │ Math.pow(a.foo, b) + 4 │ Math.pow(a, b.foo) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // base and exponent with a higher precedence + 2 │ - ·Math.pow(2,·3) + 2 │ + ·2**3 + 3 3 │ Math.pow(a.foo, b) + 4 4 │ Math.pow(a, b.foo) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:3:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // base and exponent with a higher precedence + 2 │ Math.pow(2, 3) + > 3 │ Math.pow(a.foo, b) + │ ^^^^^^^^^^^^^^^^^^ + 4 │ Math.pow(a, b.foo) + 5 │ Math.pow(a(), b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // base and exponent with a higher precedence + 2 2 │ Math.pow(2, 3) + 3 │ - ·Math.pow(a.foo,·b) + 3 │ + ·a.foo**b + 4 4 │ Math.pow(a, b.foo) + 5 5 │ Math.pow(a(), b) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:4:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ Math.pow(2, 3) + 3 │ Math.pow(a.foo, b) + > 4 │ Math.pow(a, b.foo) + │ ^^^^^^^^^^^^^^^^^^ + 5 │ Math.pow(a(), b) + 6 │ Math.pow(a, b()) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 2 2 │ Math.pow(2, 3) + 3 3 │ Math.pow(a.foo, b) + 4 │ - ·Math.pow(a,·b.foo) + 4 │ + ·a**b.foo + 5 5 │ Math.pow(a(), b) + 6 6 │ Math.pow(a, b()) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:5:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 3 │ Math.pow(a.foo, b) + 4 │ Math.pow(a, b.foo) + > 5 │ Math.pow(a(), b) + │ ^^^^^^^^^^^^^^^^ + 6 │ Math.pow(a, b()) + 7 │ Math.pow(++a, ++b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 3 3 │ Math.pow(a.foo, b) + 4 4 │ Math.pow(a, b.foo) + 5 │ - ·Math.pow(a(),·b) + 5 │ + ·a()**b + 6 6 │ Math.pow(a, b()) + 7 7 │ Math.pow(++a, ++b) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:6:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ Math.pow(a, b.foo) + 5 │ Math.pow(a(), b) + > 6 │ Math.pow(a, b()) + │ ^^^^^^^^^^^^^^^^ + 7 │ Math.pow(++a, ++b) + 8 │ Math.pow(a++, ++b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ Math.pow(a, b.foo) + 5 5 │ Math.pow(a(), b) + 6 │ - ·Math.pow(a,·b()) + 6 │ + ·a**b() + 7 7 │ Math.pow(++a, ++b) + 8 8 │ Math.pow(a++, ++b) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:7:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 5 │ Math.pow(a(), b) + 6 │ Math.pow(a, b()) + > 7 │ Math.pow(++a, ++b) + │ ^^^^^^^^^^^^^^^^^^ + 8 │ Math.pow(a++, ++b) + 9 │ Math.pow(a--, b--) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 5 5 │ Math.pow(a(), b) + 6 6 │ Math.pow(a, b()) + 7 │ - ·Math.pow(++a,·++b) + 7 │ + ·++a**++b + 8 8 │ Math.pow(a++, ++b) + 9 9 │ Math.pow(a--, b--) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:8:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ Math.pow(a, b()) + 7 │ Math.pow(++a, ++b) + > 8 │ Math.pow(a++, ++b) + │ ^^^^^^^^^^^^^^^^^^ + 9 │ Math.pow(a--, b--) + 10 │ Math.pow(--a, b--) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ Math.pow(a, b()) + 7 7 │ Math.pow(++a, ++b) + 8 │ - ·Math.pow(a++,·++b) + 8 │ + ·a++**++b + 9 9 │ Math.pow(a--, b--) + 10 10 │ Math.pow(--a, b--) + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:9:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ Math.pow(++a, ++b) + 8 │ Math.pow(a++, ++b) + > 9 │ Math.pow(a--, b--) + │ ^^^^^^^^^^^^^^^^^^ + 10 │ Math.pow(--a, b--) + 11 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 7 7 │ Math.pow(++a, ++b) + 8 8 │ Math.pow(a++, ++b) + 9 │ - ·Math.pow(a--,·b--) + 9 │ + ·a--**b-- + 10 10 │ Math.pow(--a, b--) + 11 11 │ + + +``` + +``` +invalidBaseExpoentHigherPrecedence.js:10:2 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 8 │ Math.pow(a++, ++b) + 9 │ Math.pow(a--, b--) + > 10 │ Math.pow(--a, b--) + │ ^^^^^^^^^^^^^^^^^^ + 11 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 8 8 │ Math.pow(a++, ++b) + 9 9 │ Math.pow(a--, b--) + 10 │ - ·Math.pow(--a,·b--) + 10 │ + ·--a**b-- + 11 11 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js new file mode 100644 index 00000000000..266d02490b4 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js @@ -0,0 +1,12 @@ +// base and exponent with a lower precedence +Math.pow(a * b, c) +Math.pow(a, b * c) +Math.pow(a / b, c) +Math.pow(a, b / c) +Math.pow(a + b, 3) +Math.pow(2, a - b) +Math.pow(a + b, c + d) +Math.pow(a = b, c = d) +Math.pow(a += b, c -= d) +Math.pow((a, b), (c, d)) +function *f() { Math.pow(yield, yield) } diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap new file mode 100644 index 00000000000..d77df6b1d04 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap @@ -0,0 +1,284 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidBaseExpoentLowerPrecedence.js +--- +# Input +```js +// base and exponent with a lower precedence +Math.pow(a * b, c) +Math.pow(a, b * c) +Math.pow(a / b, c) +Math.pow(a, b / c) +Math.pow(a + b, 3) +Math.pow(2, a - b) +Math.pow(a + b, c + d) +Math.pow(a = b, c = d) +Math.pow(a += b, c -= d) +Math.pow((a, b), (c, d)) +function *f() { Math.pow(yield, yield) } + +``` + +# Diagnostics +``` +invalidBaseExpoentLowerPrecedence.js:2:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // base and exponent with a lower precedence + > 2 │ Math.pow(a * b, c) + │ ^^^^^^^^^^^^^^^^^^ + 3 │ Math.pow(a, b * c) + 4 │ Math.pow(a / b, c) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // base and exponent with a lower precedence + 2 │ - Math.pow(a·*·b,·c) + 2 │ + (a·*·b)**c + 3 3 │ Math.pow(a, b * c) + 4 4 │ Math.pow(a / b, c) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:3:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // base and exponent with a lower precedence + 2 │ Math.pow(a * b, c) + > 3 │ Math.pow(a, b * c) + │ ^^^^^^^^^^^^^^^^^^ + 4 │ Math.pow(a / b, c) + 5 │ Math.pow(a, b / c) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // base and exponent with a lower precedence + 2 2 │ Math.pow(a * b, c) + 3 │ - Math.pow(a,·b·*·c) + 3 │ + a**(b·*·c) + 4 4 │ Math.pow(a / b, c) + 5 5 │ Math.pow(a, b / c) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:4:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ Math.pow(a * b, c) + 3 │ Math.pow(a, b * c) + > 4 │ Math.pow(a / b, c) + │ ^^^^^^^^^^^^^^^^^^ + 5 │ Math.pow(a, b / c) + 6 │ Math.pow(a + b, 3) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 2 2 │ Math.pow(a * b, c) + 3 3 │ Math.pow(a, b * c) + 4 │ - Math.pow(a·/·b,·c) + 4 │ + (a·/·b)**c + 5 5 │ Math.pow(a, b / c) + 6 6 │ Math.pow(a + b, 3) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:5:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 3 │ Math.pow(a, b * c) + 4 │ Math.pow(a / b, c) + > 5 │ Math.pow(a, b / c) + │ ^^^^^^^^^^^^^^^^^^ + 6 │ Math.pow(a + b, 3) + 7 │ Math.pow(2, a - b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 3 3 │ Math.pow(a, b * c) + 4 4 │ Math.pow(a / b, c) + 5 │ - Math.pow(a,·b·/·c) + 5 │ + a**(b·/·c) + 6 6 │ Math.pow(a + b, 3) + 7 7 │ Math.pow(2, a - b) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:6:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ Math.pow(a / b, c) + 5 │ Math.pow(a, b / c) + > 6 │ Math.pow(a + b, 3) + │ ^^^^^^^^^^^^^^^^^^ + 7 │ Math.pow(2, a - b) + 8 │ Math.pow(a + b, c + d) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ Math.pow(a / b, c) + 5 5 │ Math.pow(a, b / c) + 6 │ - Math.pow(a·+·b,·3) + 6 │ + (a·+·b)**3 + 7 7 │ Math.pow(2, a - b) + 8 8 │ Math.pow(a + b, c + d) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:7:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 5 │ Math.pow(a, b / c) + 6 │ Math.pow(a + b, 3) + > 7 │ Math.pow(2, a - b) + │ ^^^^^^^^^^^^^^^^^^ + 8 │ Math.pow(a + b, c + d) + 9 │ Math.pow(a = b, c = d) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 5 5 │ Math.pow(a, b / c) + 6 6 │ Math.pow(a + b, 3) + 7 │ - Math.pow(2,·a·-·b) + 7 │ + 2**(a·-·b) + 8 8 │ Math.pow(a + b, c + d) + 9 9 │ Math.pow(a = b, c = d) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:8:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ Math.pow(a + b, 3) + 7 │ Math.pow(2, a - b) + > 8 │ Math.pow(a + b, c + d) + │ ^^^^^^^^^^^^^^^^^^^^^^ + 9 │ Math.pow(a = b, c = d) + 10 │ Math.pow(a += b, c -= d) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ Math.pow(a + b, 3) + 7 7 │ Math.pow(2, a - b) + 8 │ - Math.pow(a·+·b,·c·+·d) + 8 │ + (a·+·b)**(c·+·d) + 9 9 │ Math.pow(a = b, c = d) + 10 10 │ Math.pow(a += b, c -= d) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:9:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ Math.pow(2, a - b) + 8 │ Math.pow(a + b, c + d) + > 9 │ Math.pow(a = b, c = d) + │ ^^^^^^^^^^^^^^^^^^^^^^ + 10 │ Math.pow(a += b, c -= d) + 11 │ Math.pow((a, b), (c, d)) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 7 7 │ Math.pow(2, a - b) + 8 8 │ Math.pow(a + b, c + d) + 9 │ - Math.pow(a·=·b,·c·=·d) + 9 │ + (a·=·b)**(c·=·d) + 10 10 │ Math.pow(a += b, c -= d) + 11 11 │ Math.pow((a, b), (c, d)) + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:10:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 8 │ Math.pow(a + b, c + d) + 9 │ Math.pow(a = b, c = d) + > 10 │ Math.pow(a += b, c -= d) + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 11 │ Math.pow((a, b), (c, d)) + 12 │ function *f() { Math.pow(yield, yield) } + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 8 8 │ Math.pow(a + b, c + d) + 9 9 │ Math.pow(a = b, c = d) + 10 │ - Math.pow(a·+=·b,·c·-=·d) + 10 │ + (a·+=·b)**(c·-=·d) + 11 11 │ Math.pow((a, b), (c, d)) + 12 12 │ function *f() { Math.pow(yield, yield) } + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:11:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 9 │ Math.pow(a = b, c = d) + 10 │ Math.pow(a += b, c -= d) + > 11 │ Math.pow((a, b), (c, d)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 12 │ function *f() { Math.pow(yield, yield) } + 13 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 9 9 │ Math.pow(a = b, c = d) + 10 10 │ Math.pow(a += b, c -= d) + 11 │ - Math.pow((a,·b),·(c,·d)) + 11 │ + (a,·b)**(c,·d) + 12 12 │ function *f() { Math.pow(yield, yield) } + 13 13 │ + + +``` + +``` +invalidBaseExpoentLowerPrecedence.js:12:17 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 10 │ Math.pow(a += b, c -= d) + 11 │ Math.pow((a, b), (c, d)) + > 12 │ function *f() { Math.pow(yield, yield) } + │ ^^^^^^^^^^^^^^^^^^^^^^ + 13 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 10 10 │ Math.pow(a += b, c -= d) + 11 11 │ Math.pow((a, b), (c, d)) + 12 │ - function·*f()·{·Math.pow(yield,·yield)·} + 12 │ + function·*f()·{·(yield)**(yield)·} + 13 13 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js new file mode 100644 index 00000000000..37e7748f9ed --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js @@ -0,0 +1,20 @@ ++ Math.pow(a, b); +- Math.pow(a, b); +! Math.pow(a, b); +typeof Math.pow(a, b); +void Math.pow(a, b); +Math.pow(a, b) .toString(); +Math.pow(a, b) (); +Math.pow(a, b) ``; + +// parents with a higher precedence, but the expression's role doesn't require parens +f(Math.pow(a, b)) +f(foo, Math.pow(a, b)) +f(Math.pow(a, b), foo) +f(foo, Math.pow(a, b), bar) +new F(Math.pow(a, b)) +new F(foo, Math.pow(a, b)) +new F(Math.pow(a, b), foo) +new F(foo, Math.pow(a, b), bar) +obj[Math.pow(a, b)] +[foo, Math.pow(a, b), bar] diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap new file mode 100644 index 00000000000..bca4b266d47 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap @@ -0,0 +1,455 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidParentsWithHigherPrecedence.js +--- +# Input +```js ++ Math.pow(a, b); +- Math.pow(a, b); +! Math.pow(a, b); +typeof Math.pow(a, b); +void Math.pow(a, b); +Math.pow(a, b) .toString(); +Math.pow(a, b) (); +Math.pow(a, b) ``; + +// parents with a higher precedence, but the expression's role doesn't require parens +f(Math.pow(a, b)) +f(foo, Math.pow(a, b)) +f(Math.pow(a, b), foo) +f(foo, Math.pow(a, b), bar) +new F(Math.pow(a, b)) +new F(foo, Math.pow(a, b)) +new F(Math.pow(a, b), foo) +new F(foo, Math.pow(a, b), bar) +obj[Math.pow(a, b)] +[foo, Math.pow(a, b), bar] + +``` + +# Diagnostics +``` +invalidParentsWithHigherPrecedence.js:1:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + > 1 │ + Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 2 │ - Math.pow(a, b); + 3 │ ! Math.pow(a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 │ - +·Math.pow(a,·b); + 1 │ + +·(a**b); + 2 2 │ - Math.pow(a, b); + 3 3 │ ! Math.pow(a, b); + + +``` + +``` +invalidParentsWithHigherPrecedence.js:2:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ + Math.pow(a, b); + > 2 │ - Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 3 │ ! Math.pow(a, b); + 4 │ typeof Math.pow(a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ + Math.pow(a, b); + 2 │ - -·Math.pow(a,·b); + 2 │ + -·(a**b); + 3 3 │ ! Math.pow(a, b); + 4 4 │ typeof Math.pow(a, b); + + +``` + +``` +invalidParentsWithHigherPrecedence.js:3:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ + Math.pow(a, b); + 2 │ - Math.pow(a, b); + > 3 │ ! Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 4 │ typeof Math.pow(a, b); + 5 │ void Math.pow(a, b); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ + Math.pow(a, b); + 2 2 │ - Math.pow(a, b); + 3 │ - !·Math.pow(a,·b); + 3 │ + !·(a**b); + 4 4 │ typeof Math.pow(a, b); + 5 5 │ void Math.pow(a, b); + + +``` + +``` +invalidParentsWithHigherPrecedence.js:4:8 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ - Math.pow(a, b); + 3 │ ! Math.pow(a, b); + > 4 │ typeof Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 5 │ void Math.pow(a, b); + 6 │ Math.pow(a, b) .toString(); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 2 2 │ - Math.pow(a, b); + 3 3 │ ! Math.pow(a, b); + 4 │ - typeof·Math.pow(a,·b); + 4 │ + typeof·(a**b); + 5 5 │ void Math.pow(a, b); + 6 6 │ Math.pow(a, b) .toString(); + + +``` + +``` +invalidParentsWithHigherPrecedence.js:5:6 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 3 │ ! Math.pow(a, b); + 4 │ typeof Math.pow(a, b); + > 5 │ void Math.pow(a, b); + │ ^^^^^^^^^^^^^^ + 6 │ Math.pow(a, b) .toString(); + 7 │ Math.pow(a, b) (); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 3 3 │ ! Math.pow(a, b); + 4 4 │ typeof Math.pow(a, b); + 5 │ - void·Math.pow(a,·b); + 5 │ + void·(a**b); + 6 6 │ Math.pow(a, b) .toString(); + 7 7 │ Math.pow(a, b) (); + + +``` + +``` +invalidParentsWithHigherPrecedence.js:6:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ typeof Math.pow(a, b); + 5 │ void Math.pow(a, b); + > 6 │ Math.pow(a, b) .toString(); + │ ^^^^^^^^^^^^^^ + 7 │ Math.pow(a, b) (); + 8 │ Math.pow(a, b) ``; + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ typeof Math.pow(a, b); + 5 5 │ void Math.pow(a, b); + 6 │ - Math.pow(a,·b)·.toString(); + 6 │ + (a**b)·.toString(); + 7 7 │ Math.pow(a, b) (); + 8 8 │ Math.pow(a, b) ``; + + +``` + +``` +invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 5 │ void Math.pow(a, b); + 6 │ Math.pow(a, b) .toString(); + > 7 │ Math.pow(a, b) (); + │ ^^^^^^^^^^^^^^ + 8 │ Math.pow(a, b) ``; + 9 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 5 5 │ void Math.pow(a, b); + 6 6 │ Math.pow(a, b) .toString(); + 7 │ - Math.pow(a,·b)·(); + 7 │ + (a**b)·(); + 8 8 │ Math.pow(a, b) ``; + 9 9 │ + + +``` + +``` +invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ Math.pow(a, b) .toString(); + 7 │ Math.pow(a, b) (); + > 8 │ Math.pow(a, b) ``; + │ ^^^^^^^^^^^^^^ + 9 │ + 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ Math.pow(a, b) .toString(); + 7 7 │ Math.pow(a, b) (); + 8 │ - Math.pow(a,·b)·``; + 8 │ + (a**b)·``; + 9 9 │ + 10 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + + +``` + +``` +invalidParentsWithHigherPrecedence.js:11:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + > 11 │ f(Math.pow(a, b)) + │ ^^^^^^^^^^^^^^ + 12 │ f(foo, Math.pow(a, b)) + 13 │ f(Math.pow(a, b), foo) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 9 9 │ + 10 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + 11 │ - f(Math.pow(a,·b)) + 11 │ + f(a**b) + 12 12 │ f(foo, Math.pow(a, b)) + 13 13 │ f(Math.pow(a, b), foo) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:12:8 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + 11 │ f(Math.pow(a, b)) + > 12 │ f(foo, Math.pow(a, b)) + │ ^^^^^^^^^^^^^^ + 13 │ f(Math.pow(a, b), foo) + 14 │ f(foo, Math.pow(a, b), bar) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 10 10 │ // parents with a higher precedence, but the expression's role doesn't require parens + 11 11 │ f(Math.pow(a, b)) + 12 │ - f(foo,·Math.pow(a,·b)) + 12 │ + f(foo,·a**b) + 13 13 │ f(Math.pow(a, b), foo) + 14 14 │ f(foo, Math.pow(a, b), bar) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:13:3 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 11 │ f(Math.pow(a, b)) + 12 │ f(foo, Math.pow(a, b)) + > 13 │ f(Math.pow(a, b), foo) + │ ^^^^^^^^^^^^^^ + 14 │ f(foo, Math.pow(a, b), bar) + 15 │ new F(Math.pow(a, b)) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 11 11 │ f(Math.pow(a, b)) + 12 12 │ f(foo, Math.pow(a, b)) + 13 │ - f(Math.pow(a,·b),·foo) + 13 │ + f(a**b,·foo) + 14 14 │ f(foo, Math.pow(a, b), bar) + 15 15 │ new F(Math.pow(a, b)) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:14:8 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ f(foo, Math.pow(a, b)) + 13 │ f(Math.pow(a, b), foo) + > 14 │ f(foo, Math.pow(a, b), bar) + │ ^^^^^^^^^^^^^^ + 15 │ new F(Math.pow(a, b)) + 16 │ new F(foo, Math.pow(a, b)) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ f(foo, Math.pow(a, b)) + 13 13 │ f(Math.pow(a, b), foo) + 14 │ - f(foo,·Math.pow(a,·b),·bar) + 14 │ + f(foo,·a**b,·bar) + 15 15 │ new F(Math.pow(a, b)) + 16 16 │ new F(foo, Math.pow(a, b)) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:15:7 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ f(Math.pow(a, b), foo) + 14 │ f(foo, Math.pow(a, b), bar) + > 15 │ new F(Math.pow(a, b)) + │ ^^^^^^^^^^^^^^ + 16 │ new F(foo, Math.pow(a, b)) + 17 │ new F(Math.pow(a, b), foo) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 13 13 │ f(Math.pow(a, b), foo) + 14 14 │ f(foo, Math.pow(a, b), bar) + 15 │ - new·F(Math.pow(a,·b)) + 15 │ + new·F(a**b) + 16 16 │ new F(foo, Math.pow(a, b)) + 17 17 │ new F(Math.pow(a, b), foo) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:16:12 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 14 │ f(foo, Math.pow(a, b), bar) + 15 │ new F(Math.pow(a, b)) + > 16 │ new F(foo, Math.pow(a, b)) + │ ^^^^^^^^^^^^^^ + 17 │ new F(Math.pow(a, b), foo) + 18 │ new F(foo, Math.pow(a, b), bar) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 14 14 │ f(foo, Math.pow(a, b), bar) + 15 15 │ new F(Math.pow(a, b)) + 16 │ - new·F(foo,·Math.pow(a,·b)) + 16 │ + new·F(foo,·a**b) + 17 17 │ new F(Math.pow(a, b), foo) + 18 18 │ new F(foo, Math.pow(a, b), bar) + + +``` + +``` +invalidParentsWithHigherPrecedence.js:17:7 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 15 │ new F(Math.pow(a, b)) + 16 │ new F(foo, Math.pow(a, b)) + > 17 │ new F(Math.pow(a, b), foo) + │ ^^^^^^^^^^^^^^ + 18 │ new F(foo, Math.pow(a, b), bar) + 19 │ obj[Math.pow(a, b)] + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 15 15 │ new F(Math.pow(a, b)) + 16 16 │ new F(foo, Math.pow(a, b)) + 17 │ - new·F(Math.pow(a,·b),·foo) + 17 │ + new·F(a**b,·foo) + 18 18 │ new F(foo, Math.pow(a, b), bar) + 19 19 │ obj[Math.pow(a, b)] + + +``` + +``` +invalidParentsWithHigherPrecedence.js:18:12 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 16 │ new F(foo, Math.pow(a, b)) + 17 │ new F(Math.pow(a, b), foo) + > 18 │ new F(foo, Math.pow(a, b), bar) + │ ^^^^^^^^^^^^^^ + 19 │ obj[Math.pow(a, b)] + 20 │ [foo, Math.pow(a, b), bar] + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 16 16 │ new F(foo, Math.pow(a, b)) + 17 17 │ new F(Math.pow(a, b), foo) + 18 │ - new·F(foo,·Math.pow(a,·b),·bar) + 18 │ + new·F(foo,·a**b,·bar) + 19 19 │ obj[Math.pow(a, b)] + 20 20 │ [foo, Math.pow(a, b), bar] + + +``` + +``` +invalidParentsWithHigherPrecedence.js:19:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 17 │ new F(Math.pow(a, b), foo) + 18 │ new F(foo, Math.pow(a, b), bar) + > 19 │ obj[Math.pow(a, b)] + │ ^^^^^^^^^^^^^^ + 20 │ [foo, Math.pow(a, b), bar] + 21 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 17 17 │ new F(Math.pow(a, b), foo) + 18 18 │ new F(foo, Math.pow(a, b), bar) + 19 │ - obj[Math.pow(a,·b)] + 19 │ + obj[a**b] + 20 20 │ [foo, Math.pow(a, b), bar] + 21 21 │ + + +``` + +``` +invalidParentsWithHigherPrecedence.js:20:7 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 18 │ new F(foo, Math.pow(a, b), bar) + 19 │ obj[Math.pow(a, b)] + > 20 │ [foo, Math.pow(a, b), bar] + │ ^^^^^^^^^^^^^^ + 21 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 18 18 │ new F(foo, Math.pow(a, b), bar) + 19 19 │ obj[Math.pow(a, b)] + 20 │ - [foo,·Math.pow(a,·b),·bar] + 20 │ + [foo,·a**b,·bar] + 21 21 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js new file mode 100644 index 00000000000..2733719fee6 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js @@ -0,0 +1,24 @@ +// parents with a lower precedence +a * Math.pow(b, c); + +Math.pow(a, b) * c; + +a + Math.pow(b, c); + +Math.pow(a, b)/c; + +a < Math.pow(b, c); + +Math.pow(a, b) > c; + +a === Math.pow(b, c); + +a ? Math.pow(b, c) : d; + +a = Math.pow(b, c); + +a += Math.pow(b, c); + +function *f() { yield Math.pow(a, b) } + +a, Math.pow(b, c), d diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap new file mode 100644 index 00000000000..6be437cbfdd --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap @@ -0,0 +1,320 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidParentsWithLowerPrecedence.js +--- +# Input +```js +// parents with a lower precedence +a * Math.pow(b, c); + +Math.pow(a, b) * c; + +a + Math.pow(b, c); + +Math.pow(a, b)/c; + +a < Math.pow(b, c); + +Math.pow(a, b) > c; + +a === Math.pow(b, c); + +a ? Math.pow(b, c) : d; + +a = Math.pow(b, c); + +a += Math.pow(b, c); + +function *f() { yield Math.pow(a, b) } + +a, Math.pow(b, c), d + +``` + +# Diagnostics +``` +invalidParentsWithLowerPrecedence.js:2:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // parents with a lower precedence + > 2 │ a * Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 3 │ + 4 │ Math.pow(a, b) * c; + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // parents with a lower precedence + 2 │ - a·*·Math.pow(b,·c); + 2 │ + a·*·b**c; + 3 3 │ + 4 4 │ Math.pow(a, b) * c; + + +``` + +``` +invalidParentsWithLowerPrecedence.js:4:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ a * Math.pow(b, c); + 3 │ + > 4 │ Math.pow(a, b) * c; + │ ^^^^^^^^^^^^^^ + 5 │ + 6 │ a + Math.pow(b, c); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 2 2 │ a * Math.pow(b, c); + 3 3 │ + 4 │ - Math.pow(a,·b)·*·c; + 4 │ + a**b·*·c; + 5 5 │ + 6 6 │ a + Math.pow(b, c); + + +``` + +``` +invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ Math.pow(a, b) * c; + 5 │ + > 6 │ a + Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 7 │ + 8 │ Math.pow(a, b)/c; + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ Math.pow(a, b) * c; + 5 5 │ + 6 │ - a·+·Math.pow(b,·c); + 6 │ + a·+·b**c; + 7 7 │ + 8 8 │ Math.pow(a, b)/c; + + +``` + +``` +invalidParentsWithLowerPrecedence.js:8:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ a + Math.pow(b, c); + 7 │ + > 8 │ Math.pow(a, b)/c; + │ ^^^^^^^^^^^^^^ + 9 │ + 10 │ a < Math.pow(b, c); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ a + Math.pow(b, c); + 7 7 │ + 8 │ - Math.pow(a,·b)/c; + 8 │ + a**b/c; + 9 9 │ + 10 10 │ a < Math.pow(b, c); + + +``` + +``` +invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 8 │ Math.pow(a, b)/c; + 9 │ + > 10 │ a < Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 11 │ + 12 │ Math.pow(a, b) > c; + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 8 8 │ Math.pow(a, b)/c; + 9 9 │ + 10 │ - a·<·Math.pow(b,·c); + 10 │ + a·<·b**c; + 11 11 │ + 12 12 │ Math.pow(a, b) > c; + + +``` + +``` +invalidParentsWithLowerPrecedence.js:12:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 10 │ a < Math.pow(b, c); + 11 │ + > 12 │ Math.pow(a, b) > c; + │ ^^^^^^^^^^^^^^ + 13 │ + 14 │ a === Math.pow(b, c); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 10 10 │ a < Math.pow(b, c); + 11 11 │ + 12 │ - Math.pow(a,·b)·>·c; + 12 │ + a**b·>·c; + 13 13 │ + 14 14 │ a === Math.pow(b, c); + + +``` + +``` +invalidParentsWithLowerPrecedence.js:14:7 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 12 │ Math.pow(a, b) > c; + 13 │ + > 14 │ a === Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 15 │ + 16 │ a ? Math.pow(b, c) : d; + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ Math.pow(a, b) > c; + 13 13 │ + 14 │ - a·===·Math.pow(b,·c); + 14 │ + a·===·b**c; + 15 15 │ + 16 16 │ a ? Math.pow(b, c) : d; + + +``` + +``` +invalidParentsWithLowerPrecedence.js:16:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 14 │ a === Math.pow(b, c); + 15 │ + > 16 │ a ? Math.pow(b, c) : d; + │ ^^^^^^^^^^^^^^ + 17 │ + 18 │ a = Math.pow(b, c); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 14 14 │ a === Math.pow(b, c); + 15 15 │ + 16 │ - a·?·Math.pow(b,·c)·:·d; + 16 │ + a·?·b**c·:·d; + 17 17 │ + 18 18 │ a = Math.pow(b, c); + + +``` + +``` +invalidParentsWithLowerPrecedence.js:18:5 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 16 │ a ? Math.pow(b, c) : d; + 17 │ + > 18 │ a = Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 19 │ + 20 │ a += Math.pow(b, c); + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 16 16 │ a ? Math.pow(b, c) : d; + 17 17 │ + 18 │ - a·=·Math.pow(b,·c); + 18 │ + a·=·b**c; + 19 19 │ + 20 20 │ a += Math.pow(b, c); + + +``` + +``` +invalidParentsWithLowerPrecedence.js:20:6 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 18 │ a = Math.pow(b, c); + 19 │ + > 20 │ a += Math.pow(b, c); + │ ^^^^^^^^^^^^^^ + 21 │ + 22 │ function *f() { yield Math.pow(a, b) } + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 18 18 │ a = Math.pow(b, c); + 19 19 │ + 20 │ - a·+=·Math.pow(b,·c); + 20 │ + a·+=·b**c; + 21 21 │ + 22 22 │ function *f() { yield Math.pow(a, b) } + + +``` + +``` +invalidParentsWithLowerPrecedence.js:22:23 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 20 │ a += Math.pow(b, c); + 21 │ + > 22 │ function *f() { yield Math.pow(a, b) } + │ ^^^^^^^^^^^^^^ + 23 │ + 24 │ a, Math.pow(b, c), d + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 20 20 │ a += Math.pow(b, c); + 21 21 │ + 22 │ - function·*f()·{·yield·Math.pow(a,·b)·} + 22 │ + function·*f()·{·yield·a**b·} + 23 23 │ + 24 24 │ a, Math.pow(b, c), d + + +``` + +``` +invalidParentsWithLowerPrecedence.js:24:4 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 22 │ function *f() { yield Math.pow(a, b) } + 23 │ + > 24 │ a, Math.pow(b, c), d + │ ^^^^^^^^^^^^^^ + 25 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 22 22 │ function *f() { yield Math.pow(a, b) } + 23 23 │ + 24 │ - a,·Math.pow(b,·c),·d + 24 │ + a,·b**c,·d + 25 25 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js new file mode 100644 index 00000000000..624305ec994 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js @@ -0,0 +1,9 @@ +// unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence +Math.pow(+a, b) +Math.pow(a, +b) +Math.pow(-a, b) +Math.pow(a, -b) +Math.pow(-2, 3) +Math.pow(2, -3) +async () => Math.pow(await a, b) +async () => Math.pow(a, await b) diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap new file mode 100644 index 00000000000..0d6d7b9e262 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap @@ -0,0 +1,209 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidUnaryExpression.js +--- +# Input +```js +// unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence +Math.pow(+a, b) +Math.pow(a, +b) +Math.pow(-a, b) +Math.pow(a, -b) +Math.pow(-2, 3) +Math.pow(2, -3) +async () => Math.pow(await a, b) +async () => Math.pow(a, await b) + +``` + +# Diagnostics +``` +invalidUnaryExpression.js:2:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence + > 2 │ Math.pow(+a, b) + │ ^^^^^^^^^^^^^^^ + 3 │ Math.pow(a, +b) + 4 │ Math.pow(-a, b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence + 2 │ - Math.pow(+a,·b) + 2 │ + (+a)**b + 3 3 │ Math.pow(a, +b) + 4 4 │ Math.pow(-a, b) + + +``` + +``` +invalidUnaryExpression.js:3:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence + 2 │ Math.pow(+a, b) + > 3 │ Math.pow(a, +b) + │ ^^^^^^^^^^^^^^^ + 4 │ Math.pow(-a, b) + 5 │ Math.pow(a, -b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 1 1 │ // unary expressions are exception by the language - parens are required for the base to disambiguate operator precedence + 2 2 │ Math.pow(+a, b) + 3 │ - Math.pow(a,·+b) + 3 │ + a**+b + 4 4 │ Math.pow(-a, b) + 5 5 │ Math.pow(a, -b) + + +``` + +``` +invalidUnaryExpression.js:4:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ Math.pow(+a, b) + 3 │ Math.pow(a, +b) + > 4 │ Math.pow(-a, b) + │ ^^^^^^^^^^^^^^^ + 5 │ Math.pow(a, -b) + 6 │ Math.pow(-2, 3) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 2 2 │ Math.pow(+a, b) + 3 3 │ Math.pow(a, +b) + 4 │ - Math.pow(-a,·b) + 4 │ + (-a)**b + 5 5 │ Math.pow(a, -b) + 6 6 │ Math.pow(-2, 3) + + +``` + +``` +invalidUnaryExpression.js:5:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 3 │ Math.pow(a, +b) + 4 │ Math.pow(-a, b) + > 5 │ Math.pow(a, -b) + │ ^^^^^^^^^^^^^^^ + 6 │ Math.pow(-2, 3) + 7 │ Math.pow(2, -3) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 3 3 │ Math.pow(a, +b) + 4 4 │ Math.pow(-a, b) + 5 │ - Math.pow(a,·-b) + 5 │ + a**-b + 6 6 │ Math.pow(-2, 3) + 7 7 │ Math.pow(2, -3) + + +``` + +``` +invalidUnaryExpression.js:6:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 4 │ Math.pow(-a, b) + 5 │ Math.pow(a, -b) + > 6 │ Math.pow(-2, 3) + │ ^^^^^^^^^^^^^^^ + 7 │ Math.pow(2, -3) + 8 │ async () => Math.pow(await a, b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 4 4 │ Math.pow(-a, b) + 5 5 │ Math.pow(a, -b) + 6 │ - Math.pow(-2,·3) + 6 │ + (-2)**3 + 7 7 │ Math.pow(2, -3) + 8 8 │ async () => Math.pow(await a, b) + + +``` + +``` +invalidUnaryExpression.js:7:1 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 5 │ Math.pow(a, -b) + 6 │ Math.pow(-2, 3) + > 7 │ Math.pow(2, -3) + │ ^^^^^^^^^^^^^^^ + 8 │ async () => Math.pow(await a, b) + 9 │ async () => Math.pow(a, await b) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 5 5 │ Math.pow(a, -b) + 6 6 │ Math.pow(-2, 3) + 7 │ - Math.pow(2,·-3) + 7 │ + 2**-3 + 8 8 │ async () => Math.pow(await a, b) + 9 9 │ async () => Math.pow(a, await b) + + +``` + +``` +invalidUnaryExpression.js:8:13 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 6 │ Math.pow(-2, 3) + 7 │ Math.pow(2, -3) + > 8 │ async () => Math.pow(await a, b) + │ ^^^^^^^^^^^^^^^^^^^^ + 9 │ async () => Math.pow(a, await b) + 10 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 6 6 │ Math.pow(-2, 3) + 7 7 │ Math.pow(2, -3) + 8 │ - async·()·=>·Math.pow(await·a,·b) + 8 │ + async·()·=>·(await·a)**b + 9 9 │ async () => Math.pow(a, await b) + 10 10 │ + + +``` + +``` +invalidUnaryExpression.js:9:13 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ Math.pow(2, -3) + 8 │ async () => Math.pow(await a, b) + > 9 │ async () => Math.pow(a, await b) + │ ^^^^^^^^^^^^^^^^^^^^ + 10 │ + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 7 7 │ Math.pow(2, -3) + 8 8 │ async () => Math.pow(await a, b) + 9 │ - async·()·=>·Math.pow(a,·await·b) + 9 │ + async·()·=>·a**await·b + 10 10 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js new file mode 100644 index 00000000000..83287ea52ff --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js @@ -0,0 +1,19 @@ +// shouldn't autofix if the call doesn't have exactly two arguments +Math.pow() +Math.pow(a) +Math.pow(a, b, c) +Math.pow(a, b, c, d) + +// shouldn't autofix if any of the arguments is spread +Math.pow(...a) +Math.pow(...a, b) +Math.pow(a, ...b) +Math.pow(a, b, ...c) + +// shouldn't autofix if that would remove comments +/* comment */Math.pow(a, b) +Math.pow(/**/a, b) +Math.pow(a, b/**/) +Math.pow(a, b)/* comment */; +Math.pow(a, b)// comment; +Math.pow(/**/a/**/, /**/b/**/) diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap new file mode 100644 index 00000000000..2031a0e4c84 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap @@ -0,0 +1,246 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: invalidWithoutAutofix.js +--- +# Input +```js +// shouldn't autofix if the call doesn't have exactly two arguments +Math.pow() +Math.pow(a) +Math.pow(a, b, c) +Math.pow(a, b, c, d) + +// shouldn't autofix if any of the arguments is spread +Math.pow(...a) +Math.pow(...a, b) +Math.pow(a, ...b) +Math.pow(a, b, ...c) + +// shouldn't autofix if that would remove comments +/* comment */Math.pow(a, b) +Math.pow(/**/a, b) +Math.pow(a, b/**/) +Math.pow(a, b)/* comment */; +Math.pow(a, b)// comment; +Math.pow(/**/a/**/, /**/b/**/) + +``` + +# Diagnostics +``` +invalidWithoutAutofix.js:2:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // shouldn't autofix if the call doesn't have exactly two arguments + > 2 │ Math.pow() + │ ^^^^^^^^^^ + 3 │ Math.pow(a) + 4 │ Math.pow(a, b, c) + + +``` + +``` +invalidWithoutAutofix.js:3:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 1 │ // shouldn't autofix if the call doesn't have exactly two arguments + 2 │ Math.pow() + > 3 │ Math.pow(a) + │ ^^^^^^^^^^^ + 4 │ Math.pow(a, b, c) + 5 │ Math.pow(a, b, c, d) + + +``` + +``` +invalidWithoutAutofix.js:4:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 2 │ Math.pow() + 3 │ Math.pow(a) + > 4 │ Math.pow(a, b, c) + │ ^^^^^^^^^^^^^^^^^ + 5 │ Math.pow(a, b, c, d) + 6 │ + + +``` + +``` +invalidWithoutAutofix.js:5:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 3 │ Math.pow(a) + 4 │ Math.pow(a, b, c) + > 5 │ Math.pow(a, b, c, d) + │ ^^^^^^^^^^^^^^^^^^^^ + 6 │ + 7 │ // shouldn't autofix if any of the arguments is spread + + +``` + +``` +invalidWithoutAutofix.js:8:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ // shouldn't autofix if any of the arguments is spread + > 8 │ Math.pow(...a) + │ ^^^^^^^^^^^^^^ + 9 │ Math.pow(...a, b) + 10 │ Math.pow(a, ...b) + + +``` + +``` +invalidWithoutAutofix.js:9:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 7 │ // shouldn't autofix if any of the arguments is spread + 8 │ Math.pow(...a) + > 9 │ Math.pow(...a, b) + │ ^^^^^^^^^^^^^^^^^ + 10 │ Math.pow(a, ...b) + 11 │ Math.pow(a, b, ...c) + + +``` + +``` +invalidWithoutAutofix.js:10:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 8 │ Math.pow(...a) + 9 │ Math.pow(...a, b) + > 10 │ Math.pow(a, ...b) + │ ^^^^^^^^^^^^^^^^^ + 11 │ Math.pow(a, b, ...c) + 12 │ + + +``` + +``` +invalidWithoutAutofix.js:11:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 9 │ Math.pow(...a, b) + 10 │ Math.pow(a, ...b) + > 11 │ Math.pow(a, b, ...c) + │ ^^^^^^^^^^^^^^^^^^^^ + 12 │ + 13 │ // shouldn't autofix if that would remove comments + + +``` + +``` +invalidWithoutAutofix.js:14:14 lint/nursery/useExponentiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ // shouldn't autofix if that would remove comments + > 14 │ /* comment */Math.pow(a, b) + │ ^^^^^^^^^^^^^^ + 15 │ Math.pow(/**/a, b) + 16 │ Math.pow(a, b/**/) + + i Suggested fix: Use the '**' operator instead of 'Math.pow'. + + 12 12 │ + 13 13 │ // shouldn't autofix if that would remove comments + 14 │ - /*·comment·*/Math.pow(a,·b) + 14 │ + /*·comment·*/a**b + 15 15 │ Math.pow(/**/a, b) + 16 16 │ Math.pow(a, b/**/) + + +``` + +``` +invalidWithoutAutofix.js:15:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 13 │ // shouldn't autofix if that would remove comments + 14 │ /* comment */Math.pow(a, b) + > 15 │ Math.pow(/**/a, b) + │ ^^^^^^^^^^^^^^^^^^ + 16 │ Math.pow(a, b/**/) + 17 │ Math.pow(a, b)/* comment */; + + +``` + +``` +invalidWithoutAutofix.js:16:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 14 │ /* comment */Math.pow(a, b) + 15 │ Math.pow(/**/a, b) + > 16 │ Math.pow(a, b/**/) + │ ^^^^^^^^^^^^^^^^^^ + 17 │ Math.pow(a, b)/* comment */; + 18 │ Math.pow(a, b)// comment; + + +``` + +``` +invalidWithoutAutofix.js:17:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 15 │ Math.pow(/**/a, b) + 16 │ Math.pow(a, b/**/) + > 17 │ Math.pow(a, b)/* comment */; + │ ^^^^^^^^^^^^^^ + 18 │ Math.pow(a, b)// comment; + 19 │ Math.pow(/**/a/**/, /**/b/**/) + + +``` + +``` +invalidWithoutAutofix.js:18:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 16 │ Math.pow(a, b/**/) + 17 │ Math.pow(a, b)/* comment */; + > 18 │ Math.pow(a, b)// comment; + │ ^^^^^^^^^^^^^^ + 19 │ Math.pow(/**/a/**/, /**/b/**/) + 20 │ + + +``` + +``` +invalidWithoutAutofix.js:19:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use the '**' operator instead of 'Math.pow'. + + 17 │ Math.pow(a, b)/* comment */; + 18 │ Math.pow(a, b)// comment; + > 19 │ Math.pow(/**/a/**/, /**/b/**/) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 20 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js new file mode 100644 index 00000000000..0bd3251be7d --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js @@ -0,0 +1,28 @@ + +Object.pow(a, b) + +Math.max(a, b) + +Math + +Math(a, b) + +pow + +pow(a, b) + +Math.pow + +Math.Pow(a, b) + +math.pow(a, b) + +foo.Math.pow(a, b) + +new Math.pow(a, b) + +Math[pow](a, b) + +globalThis.Object.pow(a, b) + +globalThis.Math.max(a, b) diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap new file mode 100644 index 00000000000..075ae9595fd --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap @@ -0,0 +1,39 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 74 +expression: valid.js +--- +# Input +```js + +Object.pow(a, b) + +Math.max(a, b) + +Math + +Math(a, b) + +pow + +pow(a, b) + +Math.pow + +Math.Pow(a, b) + +math.pow(a, b) + +foo.Math.pow(a, b) + +new Math.pow(a, b) + +Math[pow](a, b) + +globalThis.Object.pow(a, b) + +globalThis.Math.max(a, b) + +``` + + diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 0a127cfe76a..fadbe7360b6 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -783,6 +783,8 @@ struct NurserySchema { use_default_switch_clause_last: Option, #[doc = "Enforce all dependencies are correctly specified."] use_exhaustive_dependencies: Option, + #[doc = "Disallow the use of Math.pow in favor of the ** operator."] + use_exponentiation: Option, #[doc = "Promotes the use of .flatMap() when map().flat() are used together."] use_flat_map: Option, #[doc = "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals"] @@ -792,7 +794,7 @@ struct NurserySchema { } impl Nursery { const CATEGORY_NAME: &'static str = "nursery"; - pub(crate) const CATEGORY_RULES: [&'static str; 30] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 31] = [ "noAccessKey", "noBannedTypes", "noConditionalAssignment", @@ -820,6 +822,7 @@ impl Nursery { "useConst", "useDefaultSwitchClauseLast", "useExhaustiveDependencies", + "useExponentiation", "useFlatMap", "useNumericLiterals", "useValidForDirection", diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 196d84f10c9..d5e5615a015 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1057,6 +1057,17 @@ } ] }, + "useExponentiation": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useFlatMap": { "description": "Promotes the use of .flatMap() when map().flat() are used together.", "anyOf": [ diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 556ec1fd195..daa70654473 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -459,6 +459,10 @@ export interface Nursery { * Enforce all dependencies are correctly specified. */ useExhaustiveDependencies?: RuleConfiguration; + /** + * Disallow the use of Math.pow in favor of the ** operator. + */ + useExponentiation?: RuleConfiguration; /** * Promotes the use of .flatMap() when map().flat() are used together. */ @@ -699,6 +703,7 @@ export type Category = | "lint/nursery/useConst" | "lint/nursery/useDefaultSwitchClauseLast" | "lint/nursery/useExhaustiveDependencies" + | "lint/nursery/useExponentiation" | "lint/nursery/useFlatMap" | "lint/nursery/useNumericLiterals" | "lint/nursery/useValidForDirection" diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 196d84f10c9..d5e5615a015 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1057,6 +1057,17 @@ } ] }, + "useExponentiation": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useFlatMap": { "description": "Promotes the use of .flatMap() when map().flat() are used together.", "anyOf": [ diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index a30cd3735e1..4cd788031ff 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -607,6 +607,12 @@ Enforce default clauses in switch statements to be last Enforce all dependencies are correctly specified.
+

+ useExponentiation +

+Disallow the use of Math.pow in favor of the ** operator. +
+

useFlatMap

diff --git a/website/src/pages/lint/rules/useExponentiation.md b/website/src/pages/lint/rules/useExponentiation.md new file mode 100644 index 00000000000..aa80f4671f1 --- /dev/null +++ b/website/src/pages/lint/rules/useExponentiation.md @@ -0,0 +1,111 @@ +--- +title: Lint Rule useExponentiation +parent: lint/rules/index +--- + +# useExponentiation (since v11.0.0) + +Disallow the use of `Math.pow` in favor of the `**` operator. + +>Introduced in ES2016, the infix exponentiation operator ** is an alternative for the standard Math.pow function. +Infix notation is considered to be more readable and thus more preferable than the function notation. + + +Source: https://eslint.org/docs/latest/rules/prefer-exponentiation-operator + +## Examples + +### Invalid + +```jsx +const foo = Math.pow(2, 8); +``` + +
nursery/useExponentiation.js:1:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Use the '**' operator instead of 'Math.pow'.
+  
+  > 1 │ const foo = Math.pow(2, 8);
+               ^^^^^^^^^^^^^^
+    2 │ 
+  
+   Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1  - const·foo·=·Math.pow(2,·8);
+      1+ const·foo·=·2**8;
+    2 2  
+  
+
+ +```jsx +const bar = Math.pow(a, b); +``` + +
nursery/useExponentiation.js:1:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Use the '**' operator instead of 'Math.pow'.
+  
+  > 1 │ const bar = Math.pow(a, b);
+               ^^^^^^^^^^^^^^
+    2 │ 
+  
+   Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1  - const·bar·=·Math.pow(a,·b);
+      1+ const·bar·=·a**b;
+    2 2  
+  
+
+ +```jsx +let baz = Math.pow(a + b, c + d); +``` + +
nursery/useExponentiation.js:1:11 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Use the '**' operator instead of 'Math.pow'.
+  
+  > 1 │ let baz = Math.pow(a + b, c + d);
+             ^^^^^^^^^^^^^^^^^^^^^^
+    2 │ 
+  
+   Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1  - let·baz·=·Math.pow(a·+·b,·c·+·d);
+      1+ let·baz·=·(a·+·b)**(c·+·d);
+    2 2  
+  
+
+ +```jsx +let quux = Math.pow(-1, n); +``` + +
nursery/useExponentiation.js:1:12 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Use the '**' operator instead of 'Math.pow'.
+  
+  > 1 │ let quux = Math.pow(-1, n);
+              ^^^^^^^^^^^^^^^
+    2 │ 
+  
+   Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1  - let·quux·=·Math.pow(-1,·n);
+      1+ let·quux·=·(-1)**n;
+    2 2  
+  
+
+ +### Valid + +```jsx +const foo = 2 ** 8; + +const bar = a ** b; + +let baz = (a + b) ** (c + d); + +let quux = (-1) ** n; +``` + From e182e34e4f3870249ff279b68d8334a6eec6e83f Mon Sep 17 00:00:00 2001 From: kaioduarte Date: Thu, 24 Nov 2022 16:59:23 +0000 Subject: [PATCH 02/11] rename rule `useExponentiation` to `useExponentiationOperator` --- crates/rome_diagnostics_categories/src/categories.rs | 2 +- crates/rome_js_analyze/src/analyzers/nursery.rs | 4 ++-- ...onentiation.rs => use_exponentiation_operator.rs} | 6 +++--- .../invalid.js | 0 .../invalid.js.snap | 0 .../invalidAdjacentTokens.js | 0 .../invalidAdjacentTokens.js.snap | 0 .../invalidBaseExpoentHigherPrecedence.js | 0 .../invalidBaseExpoentHigherPrecedence.js.snap | 0 .../invalidBaseExpoentLowerPrecedence.js | 0 .../invalidBaseExpoentLowerPrecedence.js.snap | 0 .../invalidParentsWithHigherPrecedence.js | 0 .../invalidParentsWithHigherPrecedence.js.snap | 0 .../invalidParentsWithLowerPrecedence.js | 0 .../invalidParentsWithLowerPrecedence.js.snap | 0 .../invalidUnaryExpression.js | 0 .../invalidUnaryExpression.js.snap | 0 .../invalidWithoutAutofix.js | 0 .../invalidWithoutAutofix.js.snap | 0 .../valid.js | 0 .../valid.js.snap | 0 .../rome_service/src/configuration/linter/rules.rs | 4 ++-- editors/vscode/configuration_schema.json | 2 +- npm/backend-jsonrpc/src/workspace.ts | 4 ++-- npm/rome/configuration_schema.json | 2 +- website/src/pages/lint/rules/index.mdx | 4 ++-- ...xponentiation.md => useExponentiationOperator.md} | 12 ++++++------ 27 files changed, 20 insertions(+), 20 deletions(-) rename crates/rome_js_analyze/src/analyzers/nursery/{use_exponentiation.rs => use_exponentiation_operator.rs} (98%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalid.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalid.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidAdjacentTokens.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidAdjacentTokens.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidBaseExpoentHigherPrecedence.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidBaseExpoentHigherPrecedence.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidBaseExpoentLowerPrecedence.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidBaseExpoentLowerPrecedence.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidParentsWithHigherPrecedence.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidParentsWithHigherPrecedence.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidParentsWithLowerPrecedence.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidParentsWithLowerPrecedence.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidUnaryExpression.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidUnaryExpression.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidWithoutAutofix.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/invalidWithoutAutofix.js.snap (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/valid.js (100%) rename crates/rome_js_analyze/tests/specs/nursery/{useExponentiation => useExponentiationOperator}/valid.js.snap (100%) rename website/src/pages/lint/rules/{useExponentiation.md => useExponentiationOperator.md} (94%) diff --git a/crates/rome_diagnostics_categories/src/categories.rs b/crates/rome_diagnostics_categories/src/categories.rs index 65f2043bd32..c57795ee4f1 100644 --- a/crates/rome_diagnostics_categories/src/categories.rs +++ b/crates/rome_diagnostics_categories/src/categories.rs @@ -99,7 +99,7 @@ define_dategories! { "lint/nursery/useConst":"https://docs.rome.tools/lint/rules/useConst", "lint/nursery/useDefaultSwitchClauseLast":"https://docs.rome.tools/lint/rules/useDefaultSwitchClauseLast", "lint/nursery/useExhaustiveDependencies": "https://docs.rome.tools/lint/rules/useExhaustiveDependencies", - "lint/nursery/useExponentiation": "https://docs.rome.tools/lint/rules/useExponentiation", + "lint/nursery/useExponentiationOperator": "https://docs.rome.tools/lint/rules/useExponentiationOperator", "lint/nursery/useFlatMap": "https://docs.rome.tools/lint/rules/useFlatMap", "lint/nursery/useNumericLiterals": "https://docs.rome.tools/lint/rules/useNumericLiterals", "lint/nursery/useValidForDirection": "https://docs.rome.tools/lint/rules/useValidForDirection", diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index ed918c78a9b..8a1cee94a6d 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -21,8 +21,8 @@ mod no_string_case_mismatch; mod no_unsafe_finally; mod no_void_type_return; mod use_default_switch_clause_last; -mod use_exponentiation; +mod use_exponentiation_operator; mod use_flat_map; mod use_numeric_literals; mod use_valid_for_direction; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_exponentiation :: UseExponentiation , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs similarity index 98% rename from crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs rename to crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs index db236cb92c6..4b6cbb2d97b 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs @@ -48,14 +48,14 @@ declare_rule! { /// let quux = (-1) ** n; /// ``` /// - pub(crate) UseExponentiation { + pub(crate) UseExponentiationOperator { version: "11.0.0", - name: "useExponentiation", + name: "useExponentiationOperator", recommended: false, } } -impl Rule for UseExponentiation { +impl Rule for UseExponentiationOperator { type Query = Ast; type State = (); type Signals = Option; diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalid.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidAdjacentTokens.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentHigherPrecedence.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidBaseExpoentLowerPrecedence.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithHigherPrecedence.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidParentsWithLowerPrecedence.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidUnaryExpression.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/invalidWithoutAutofix.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/nursery/useExponentiation/valid.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index fadbe7360b6..cd1d41ebe20 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -784,7 +784,7 @@ struct NurserySchema { #[doc = "Enforce all dependencies are correctly specified."] use_exhaustive_dependencies: Option, #[doc = "Disallow the use of Math.pow in favor of the ** operator."] - use_exponentiation: Option, + use_exponentiation_operator: Option, #[doc = "Promotes the use of .flatMap() when map().flat() are used together."] use_flat_map: Option, #[doc = "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals"] @@ -822,7 +822,7 @@ impl Nursery { "useConst", "useDefaultSwitchClauseLast", "useExhaustiveDependencies", - "useExponentiation", + "useExponentiationOperator", "useFlatMap", "useNumericLiterals", "useValidForDirection", diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index d5e5615a015..eb5faf5409a 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1057,7 +1057,7 @@ } ] }, - "useExponentiation": { + "useExponentiationOperator": { "description": "Disallow the use of Math.pow in favor of the ** operator.", "anyOf": [ { diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index daa70654473..c32ec480523 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -462,7 +462,7 @@ export interface Nursery { /** * Disallow the use of Math.pow in favor of the ** operator. */ - useExponentiation?: RuleConfiguration; + useExponentiationOperator?: RuleConfiguration; /** * Promotes the use of .flatMap() when map().flat() are used together. */ @@ -703,7 +703,7 @@ export type Category = | "lint/nursery/useConst" | "lint/nursery/useDefaultSwitchClauseLast" | "lint/nursery/useExhaustiveDependencies" - | "lint/nursery/useExponentiation" + | "lint/nursery/useExponentiationOperator" | "lint/nursery/useFlatMap" | "lint/nursery/useNumericLiterals" | "lint/nursery/useValidForDirection" diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index d5e5615a015..eb5faf5409a 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1057,7 +1057,7 @@ } ] }, - "useExponentiation": { + "useExponentiationOperator": { "description": "Disallow the use of Math.pow in favor of the ** operator.", "anyOf": [ { diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index 4cd788031ff..8babb0a7bd6 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -607,8 +607,8 @@ Enforce default clauses in switch statements to be last Enforce all dependencies are correctly specified.
-

- useExponentiation +

+ useExponentiationOperator

Disallow the use of Math.pow in favor of the ** operator.
diff --git a/website/src/pages/lint/rules/useExponentiation.md b/website/src/pages/lint/rules/useExponentiationOperator.md similarity index 94% rename from website/src/pages/lint/rules/useExponentiation.md rename to website/src/pages/lint/rules/useExponentiationOperator.md index aa80f4671f1..49e2e3c6a06 100644 --- a/website/src/pages/lint/rules/useExponentiation.md +++ b/website/src/pages/lint/rules/useExponentiationOperator.md @@ -1,9 +1,9 @@ --- -title: Lint Rule useExponentiation +title: Lint Rule useExponentiationOperator parent: lint/rules/index --- -# useExponentiation (since v11.0.0) +# useExponentiationOperator (since v11.0.0) Disallow the use of `Math.pow` in favor of the `**` operator. @@ -21,7 +21,7 @@ Source: https://eslint.org/docs/latest/rules/prefer-exponentiation-operator const foo = Math.pow(2, 8); ``` -
nursery/useExponentiation.js:1:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/useExponentiationOperator.js:1:13 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
    Use the '**' operator instead of 'Math.pow'.
   
@@ -41,7 +41,7 @@ const foo = Math.pow(2, 8);
 const bar = Math.pow(a, b);
 ```
 
-
nursery/useExponentiation.js:1:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/useExponentiationOperator.js:1:13 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
    Use the '**' operator instead of 'Math.pow'.
   
@@ -61,7 +61,7 @@ const bar = Math.pow(a, b);
 let baz = Math.pow(a + b, c + d);
 ```
 
-
nursery/useExponentiation.js:1:11 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/useExponentiationOperator.js:1:11 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
    Use the '**' operator instead of 'Math.pow'.
   
@@ -81,7 +81,7 @@ let baz = Math.pow(a + b, c + d);
 let quux = Math.pow(-1, n);
 ```
 
-
nursery/useExponentiation.js:1:12 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/useExponentiationOperator.js:1:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
    Use the '**' operator instead of 'Math.pow'.
   

From aa9e43e14ad8728963c1426ffa72650f9eeb21cb Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Thu, 24 Nov 2022 17:07:49 +0000
Subject: [PATCH 03/11] fix: update snapshots after renaming

---
 .../useExponentiationOperator/invalid.js.snap | 48 +++++++++----------
 .../invalidAdjacentTokens.js.snap             | 20 ++++----
 ...invalidBaseExpoentHigherPrecedence.js.snap | 18 +++----
 .../invalidBaseExpoentLowerPrecedence.js.snap | 22 ++++-----
 ...invalidParentsWithHigherPrecedence.js.snap | 36 +++++++-------
 .../invalidParentsWithLowerPrecedence.js.snap | 24 +++++-----
 .../invalidUnaryExpression.js.snap            | 16 +++----
 .../invalidWithoutAutofix.js.snap             | 28 +++++------
 8 files changed, 106 insertions(+), 106 deletions(-)

diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
index 05e6553a2f0..e9ba6f26f70 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
@@ -46,7 +46,7 @@ a+Math.pow(b, c)+d
 
 # Diagnostics
 ```
-invalid.js:1:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:1:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -66,7 +66,7 @@ invalid.js:1:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:2:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:2:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -88,7 +88,7 @@ invalid.js:2:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:5:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -111,7 +111,7 @@ invalid.js:5:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:6:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -135,7 +135,7 @@ invalid.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -159,7 +159,7 @@ invalid.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:8:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -183,7 +183,7 @@ invalid.js:8:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:9:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:9:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -207,7 +207,7 @@ invalid.js:9:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━
 ```
 
 ```
-invalid.js:10:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:10:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -231,7 +231,7 @@ invalid.js:10:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:13:9 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:13:9 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -254,7 +254,7 @@ invalid.js:13:9 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:14:4 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:14:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -278,7 +278,7 @@ invalid.js:14:4 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:15:6 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:15:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -302,7 +302,7 @@ invalid.js:15:6 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:16:19 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:16:19 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -326,7 +326,7 @@ invalid.js:16:19 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:17:8 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:17:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -350,7 +350,7 @@ invalid.js:17:8 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:18:25 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:18:25 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -374,7 +374,7 @@ invalid.js:18:25 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:19:4 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:19:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -398,7 +398,7 @@ invalid.js:19:4 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:22:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:22:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -421,7 +421,7 @@ invalid.js:22:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:23:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:23:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -445,7 +445,7 @@ invalid.js:23:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:26:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:26:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -468,7 +468,7 @@ invalid.js:26:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:27:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:27:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -492,7 +492,7 @@ invalid.js:27:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:28:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:28:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -516,7 +516,7 @@ invalid.js:28:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:29:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:29:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -540,7 +540,7 @@ invalid.js:29:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:30:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:30:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -564,7 +564,7 @@ invalid.js:30:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:33:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:33:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -587,7 +587,7 @@ invalid.js:33:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━
 ```
 
 ```
-invalid.js:36:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:36:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
index 72a433a0e52..24cf98470d6 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
@@ -25,7 +25,7 @@ Math.pow(a, b)**Math.pow(c, d)
 
 # Diagnostics
 ```
-invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -47,7 +47,7 @@ invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -71,7 +71,7 @@ invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:12:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:12:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -94,7 +94,7 @@ invalidAdjacentTokens.js:12:2 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:13:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:13:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -118,7 +118,7 @@ invalidAdjacentTokens.js:13:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:13:18 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:13:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -142,7 +142,7 @@ invalidAdjacentTokens.js:13:18 lint/nursery/useExponentiation  FIXABLE  ━━
 ```
 
 ```
-invalidAdjacentTokens.js:14:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:14:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -166,7 +166,7 @@ invalidAdjacentTokens.js:14:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:14:10 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:14:10 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -190,7 +190,7 @@ invalidAdjacentTokens.js:14:10 lint/nursery/useExponentiation  FIXABLE  ━━
 ```
 
 ```
-invalidAdjacentTokens.js:14:26 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:14:26 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -214,7 +214,7 @@ invalidAdjacentTokens.js:14:26 lint/nursery/useExponentiation  FIXABLE  ━━
 ```
 
 ```
-invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -236,7 +236,7 @@ invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidAdjacentTokens.js:15:17 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:15:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap
index 7ecff81c383..1926c6f67ea 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentHigherPrecedence.js.snap
@@ -20,7 +20,7 @@ expression: invalidBaseExpoentHigherPrecedence.js
 
 # Diagnostics
 ```
-invalidBaseExpoentHigherPrecedence.js:2:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:2:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -42,7 +42,7 @@ invalidBaseExpoentHigherPrecedence.js:2:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:3:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:3:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -66,7 +66,7 @@ invalidBaseExpoentHigherPrecedence.js:3:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:4:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:4:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -90,7 +90,7 @@ invalidBaseExpoentHigherPrecedence.js:4:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:5:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:5:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -114,7 +114,7 @@ invalidBaseExpoentHigherPrecedence.js:5:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:6:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:6:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -138,7 +138,7 @@ invalidBaseExpoentHigherPrecedence.js:6:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:7:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:7:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -162,7 +162,7 @@ invalidBaseExpoentHigherPrecedence.js:7:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:8:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:8:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -186,7 +186,7 @@ invalidBaseExpoentHigherPrecedence.js:8:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:9:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:9:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -210,7 +210,7 @@ invalidBaseExpoentHigherPrecedence.js:9:2 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentHigherPrecedence.js:10:2 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidBaseExpoentHigherPrecedence.js:10:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap
index d77df6b1d04..f29bfb0e4b4 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidBaseExpoentLowerPrecedence.js.snap
@@ -22,7 +22,7 @@ function *f() { Math.pow(yield, yield) }
 
 # Diagnostics
 ```
-invalidBaseExpoentLowerPrecedence.js:2:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:2:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -44,7 +44,7 @@ invalidBaseExpoentLowerPrecedence.js:2:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:3:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:3:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -68,7 +68,7 @@ invalidBaseExpoentLowerPrecedence.js:3:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:4:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:4:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -92,7 +92,7 @@ invalidBaseExpoentLowerPrecedence.js:4:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:5:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -116,7 +116,7 @@ invalidBaseExpoentLowerPrecedence.js:5:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:6:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -140,7 +140,7 @@ invalidBaseExpoentLowerPrecedence.js:6:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -164,7 +164,7 @@ invalidBaseExpoentLowerPrecedence.js:7:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -188,7 +188,7 @@ invalidBaseExpoentLowerPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:9:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:9:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -212,7 +212,7 @@ invalidBaseExpoentLowerPrecedence.js:9:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:10:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:10:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -236,7 +236,7 @@ invalidBaseExpoentLowerPrecedence.js:10:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:11:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:11:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -260,7 +260,7 @@ invalidBaseExpoentLowerPrecedence.js:11:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidBaseExpoentLowerPrecedence.js:12:17 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidBaseExpoentLowerPrecedence.js:12:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
index bca4b266d47..4369d8cd28c 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
@@ -30,7 +30,7 @@ obj[Math.pow(a, b)]
 
 # Diagnostics
 ```
-invalidParentsWithHigherPrecedence.js:1:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:1:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -50,7 +50,7 @@ invalidParentsWithHigherPrecedence.js:1:3 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:2:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:2:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -72,7 +72,7 @@ invalidParentsWithHigherPrecedence.js:2:3 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:3:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:3:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -96,7 +96,7 @@ invalidParentsWithHigherPrecedence.js:3:3 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:4:8 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:4:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -120,7 +120,7 @@ invalidParentsWithHigherPrecedence.js:4:8 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:5:6 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:5:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -144,7 +144,7 @@ invalidParentsWithHigherPrecedence.js:5:6 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:6:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -168,7 +168,7 @@ invalidParentsWithHigherPrecedence.js:6:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -192,7 +192,7 @@ invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -216,7 +216,7 @@ invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:11:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:11:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -239,7 +239,7 @@ invalidParentsWithHigherPrecedence.js:11:3 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:12:8 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:12:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -263,7 +263,7 @@ invalidParentsWithHigherPrecedence.js:12:8 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:13:3 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:13:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -287,7 +287,7 @@ invalidParentsWithHigherPrecedence.js:13:3 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:14:8 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:14:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -311,7 +311,7 @@ invalidParentsWithHigherPrecedence.js:14:8 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:15:7 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:15:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -335,7 +335,7 @@ invalidParentsWithHigherPrecedence.js:15:7 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:16:12 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:16:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -359,7 +359,7 @@ invalidParentsWithHigherPrecedence.js:16:12 lint/nursery/useExponentiation  FIXA
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:17:7 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:17:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -383,7 +383,7 @@ invalidParentsWithHigherPrecedence.js:17:7 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:18:12 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:18:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -407,7 +407,7 @@ invalidParentsWithHigherPrecedence.js:18:12 lint/nursery/useExponentiation  FIXA
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:19:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:19:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -431,7 +431,7 @@ invalidParentsWithHigherPrecedence.js:19:5 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:20:7 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:20:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
index 6be437cbfdd..8d8ad59a9d4 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
@@ -34,7 +34,7 @@ a, Math.pow(b, c), d
 
 # Diagnostics
 ```
-invalidParentsWithLowerPrecedence.js:2:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:2:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -56,7 +56,7 @@ invalidParentsWithLowerPrecedence.js:2:5 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:4:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:4:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -80,7 +80,7 @@ invalidParentsWithLowerPrecedence.js:4:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -104,7 +104,7 @@ invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -128,7 +128,7 @@ invalidParentsWithLowerPrecedence.js:8:1 lint/nursery/useExponentiation  FIXABLE
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -152,7 +152,7 @@ invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:12:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:12:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -176,7 +176,7 @@ invalidParentsWithLowerPrecedence.js:12:1 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:14:7 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:14:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -200,7 +200,7 @@ invalidParentsWithLowerPrecedence.js:14:7 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:16:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:16:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -224,7 +224,7 @@ invalidParentsWithLowerPrecedence.js:16:5 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:18:5 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:18:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -248,7 +248,7 @@ invalidParentsWithLowerPrecedence.js:18:5 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:20:6 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:20:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -272,7 +272,7 @@ invalidParentsWithLowerPrecedence.js:20:6 lint/nursery/useExponentiation  FIXABL
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:22:23 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:22:23 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -296,7 +296,7 @@ invalidParentsWithLowerPrecedence.js:22:23 lint/nursery/useExponentiation  FIXAB
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:24:4 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:24:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap
index 0d6d7b9e262..e34c0be71e7 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidUnaryExpression.js.snap
@@ -19,7 +19,7 @@ async () => Math.pow(a, await b)
 
 # Diagnostics
 ```
-invalidUnaryExpression.js:2:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:2:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -41,7 +41,7 @@ invalidUnaryExpression.js:2:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:3:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:3:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -65,7 +65,7 @@ invalidUnaryExpression.js:3:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:4:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:4:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -89,7 +89,7 @@ invalidUnaryExpression.js:4:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:5:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -113,7 +113,7 @@ invalidUnaryExpression.js:5:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:6:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -137,7 +137,7 @@ invalidUnaryExpression.js:6:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -161,7 +161,7 @@ invalidUnaryExpression.js:7:1 lint/nursery/useExponentiation  FIXABLE  ━━━
 ```
 
 ```
-invalidUnaryExpression.js:8:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:8:13 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -185,7 +185,7 @@ invalidUnaryExpression.js:8:13 lint/nursery/useExponentiation  FIXABLE  ━━
 ```
 
 ```
-invalidUnaryExpression.js:9:13 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidUnaryExpression.js:9:13 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap
index 2031a0e4c84..5febba49cea 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidWithoutAutofix.js.snap
@@ -29,7 +29,7 @@ Math.pow(/**/a/**/, /**/b/**/)
 
 # Diagnostics
 ```
-invalidWithoutAutofix.js:2:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:2:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -43,7 +43,7 @@ invalidWithoutAutofix.js:2:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:3:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:3:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -58,7 +58,7 @@ invalidWithoutAutofix.js:3:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:4:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:4:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -73,7 +73,7 @@ invalidWithoutAutofix.js:4:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:5:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:5:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -88,7 +88,7 @@ invalidWithoutAutofix.js:5:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:8:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:8:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -102,7 +102,7 @@ invalidWithoutAutofix.js:8:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:9:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:9:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -117,7 +117,7 @@ invalidWithoutAutofix.js:9:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:10:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:10:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -132,7 +132,7 @@ invalidWithoutAutofix.js:10:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:11:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:11:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -147,7 +147,7 @@ invalidWithoutAutofix.js:11:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:14:14 lint/nursery/useExponentiation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:14:14 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -170,7 +170,7 @@ invalidWithoutAutofix.js:14:14 lint/nursery/useExponentiation  FIXABLE  ━━
 ```
 
 ```
-invalidWithoutAutofix.js:15:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:15:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -185,7 +185,7 @@ invalidWithoutAutofix.js:15:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:16:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:16:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -200,7 +200,7 @@ invalidWithoutAutofix.js:16:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:17:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:17:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -215,7 +215,7 @@ invalidWithoutAutofix.js:17:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:18:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:18:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
@@ -230,7 +230,7 @@ invalidWithoutAutofix.js:18:1 lint/nursery/useExponentiation ━━━━━━
 ```
 
 ```
-invalidWithoutAutofix.js:19:1 lint/nursery/useExponentiation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalidWithoutAutofix.js:19:1 lint/nursery/useExponentiationOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   

From 66e8ac4871a8b0b44d8dd043ee9e4d8205840995 Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Sat, 26 Nov 2022 22:25:47 +0000
Subject: [PATCH 04/11] chore: address PR comments

---
 .../nursery/use_exponentiation_operator.rs    | 171 ++++++++----------
 1 file changed, 74 insertions(+), 97 deletions(-)

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 4b6cbb2d97b..4bef99d215e 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -5,8 +5,7 @@ use rome_console::markup;
 use rome_diagnostics::Applicability;
 use rome_js_factory::{make, syntax::T};
 use rome_js_syntax::{AnyJsExpression, JsBinaryOperator, JsCallExpression, OperatorPrecedence};
-use rome_rowan::{AstNode, AstNodeList, AstSeparatedList, BatchMutationExt};
-use std::iter;
+use rome_rowan::{AstNode, AstSeparatedList, BatchMutationExt};
 
 declare_rule! {
     /// Disallow the use of `Math.pow` in favor of the `**` operator.
@@ -55,6 +54,45 @@ declare_rule! {
     }
 }
 
+pub struct MathPowCall {
+    base: AnyJsExpression,
+    exponent: AnyJsExpression,
+}
+
+impl MathPowCall {
+    fn get_base(&self) -> Option {
+        Some(if self.does_base_need_parens()? {
+            parenthesize_any_js_expression(&self.base)
+        } else {
+            self.base.clone()
+        })
+    }
+
+    fn get_exponent(&self) -> Option {
+        Some(if self.does_exponent_need_parens()? {
+            parenthesize_any_js_expression(&self.exponent)
+        } else {
+            self.exponent.clone()
+        })
+    }
+
+    /// Determines whether the base expression needs parens in an exponentiation binary expression.
+    fn does_base_need_parens(&self) -> Option {
+        Some(
+            // '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c
+            self.base.precedence().ok()? <= OperatorPrecedence::Exponential
+				// An unary operator cannot be used immediately before an exponentiation expression
+				|| self.base.as_js_unary_expression().is_some()
+				|| self.base.as_js_await_expression().is_some(),
+        )
+    }
+
+    /// Determines whether the exponent expression needs parens in an exponentiation binary expression.
+    fn does_exponent_need_parens(&self) -> Option {
+        Some(self.exponent.precedence().ok()? < OperatorPrecedence::Exponential)
+    }
+}
+
 impl Rule for UseExponentiationOperator {
     type Query = Ast;
     type State = ();
@@ -64,7 +102,7 @@ impl Rule for UseExponentiationOperator {
     fn run(ctx: &RuleContext) -> Self::Signals {
         let node = ctx.query();
 
-        match node.callee().ok()?.omit_parentheses() {
+        let has_math_pow = match node.callee().ok()?.omit_parentheses() {
             AnyJsExpression::JsStaticMemberExpression(static_member_expr) => {
                 let has_math = static_member_expr
                     .object()
@@ -81,9 +119,7 @@ impl Rule for UseExponentiationOperator {
                     .token_text_trimmed()
                     == "pow";
 
-                if has_math && has_pow {
-                    return Some(());
-                }
+                has_math && has_pow
             }
             AnyJsExpression::JsComputedMemberExpression(computed_member_expr) => {
                 let has_math = computed_member_expr
@@ -92,36 +128,18 @@ impl Rule for UseExponentiationOperator {
                     .omit_parentheses()
                     .as_reference_identifier()?
                     .has_name("Math");
-                let member_expr = computed_member_expr.member().ok()?;
-
-                let has_pow = match member_expr {
-                    AnyJsExpression::AnyJsLiteralExpression(literal_expr) => {
-                        literal_expr
-                            .as_js_string_literal_expression()?
-                            .inner_string_text()
-                            .ok()?
-                            .text()
-                            == "pow"
-                    }
-                    AnyJsExpression::JsTemplateExpression(template) => {
-                        template.elements().len() == 1
-                            && template
-                                .elements()
-                                .into_iter()
-                                .next()?
-                                .as_js_template_chunk_element()?
-                                .syntax()
-                                .text_trimmed()
-                                == "pow"
-                    }
-                    _ => false,
-                };
+                let has_pow = computed_member_expr
+                    .member()
+                    .ok()?
+                    .is_string_constant("pow");
 
-                if has_math && has_pow {
-                    return Some(());
-                }
+                has_math && has_pow
             }
-            _ => {}
+            _ => false,
+        };
+
+        if has_math_pow {
+            return Some(());
         }
 
         None
@@ -138,33 +156,32 @@ impl Rule for UseExponentiationOperator {
     }
 
     fn action(ctx: &RuleContext, _: &Self::State) -> Option {
-        let mut mutation = ctx.root().begin();
         let node = ctx.query();
 
         if !should_suggest_fix(node)? {
             return None;
         }
 
+        let mut mutation = ctx.root().begin();
         let [base, exponent] = node.get_arguments_by_index([0, 1]);
-        let mut base_expr = base?.as_any_js_expression()?.clone().omit_parentheses();
-        let mut exponent_expr = exponent?.as_any_js_expression()?.clone().omit_parentheses();
 
-        if does_base_need_parens(&base_expr)? {
-            base_expr = parenthesize_js_any_expression(&base_expr);
-        }
+        let math_pow_call = MathPowCall {
+            base: base?.as_js_any_expression()?.clone().omit_parentheses(),
+            exponent: exponent?.as_js_any_expression()?.clone().omit_parentheses(),
+        };
 
-        if does_exponent_need_parens(&exponent_expr)? {
-            exponent_expr = parenthesize_js_any_expression(&exponent_expr);
-        }
-
-        let new_node = make::js_binary_expression(base_expr, make::token(T![**]), exponent_expr);
+        let new_node = make::js_binary_expression(
+            math_pow_call.get_base()?,
+            make::token(T![**]),
+            math_pow_call.get_exponent()?,
+        );
 
         if let Some(parent) = does_parent_expression_need_parens(node) {
             mutation.replace_node(
                 AnyJsExpression::from(node.clone()),
-                parenthesize_js_any_expression(&AnyJsExpression::from(new_node)),
+                parenthesize_any_js_expression(&AnyJsExpression::from(new_node)),
             );
-            mutation.replace_node(parent.clone(), parenthesize_js_any_expression(&parent));
+            mutation.replace_node(parent.clone(), parenthesize_any_js_expression(&parent));
         } else {
             mutation.replace_node(
                 AnyJsExpression::from(node.clone()),
@@ -182,7 +199,7 @@ impl Rule for UseExponentiationOperator {
 }
 
 /// Verify if the autofix is safe to be applied and won't remove comments.
-/// Argument list is considered valid if its length is 2 and there's no spread arg.
+/// Argument list is considered valid if there's no spread arg and leading/trailing comments.
 fn should_suggest_fix(node: &JsCallExpression) -> Option {
     let arguments = node.arguments().ok()?;
     let args_count = arguments.args().len();
@@ -193,20 +210,16 @@ fn should_suggest_fix(node: &JsCallExpression) -> Option {
             && !arguments.l_paren_token().ok()?.has_trailing_comments()
             && !arguments.r_paren_token().ok()?.has_leading_comments()
             && !arguments.r_paren_token().ok()?.has_trailing_comments()
-            && arguments
-                .args()
-                .into_iter()
-                .filter_map(|arg| arg.ok())
-                .all(|arg| {
-                    !arg.syntax().has_leading_comments()
-                        && !arg.syntax().has_trailing_comments()
-                        && arg.as_js_spread().is_none()
-                }),
+            && arguments.args().into_iter().flatten().all(|arg| {
+                !arg.syntax().has_leading_comments()
+                    && !arg.syntax().has_trailing_comments()
+                    && arg.as_js_spread().is_none()
+            }),
     )
 }
 
 /// Wraps a [AnyJsExpression] in paretheses
-fn parenthesize_js_any_expression(expr: &AnyJsExpression) -> AnyJsExpression {
+fn parenthesize_any_js_expression(expr: &AnyJsExpression) -> AnyJsExpression {
     AnyJsExpression::from(make::js_parenthesized_expression(
         make::token(T!['(']),
         expr.clone(),
@@ -214,32 +227,13 @@ fn parenthesize_js_any_expression(expr: &AnyJsExpression) -> AnyJsExpression {
     ))
 }
 
-/// Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
-fn does_base_need_parens(expr: &AnyJsExpression) -> Option {
-    Some(
-        // '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c
-        expr.precedence().ok()? <= OperatorPrecedence::Exponential
-			// An unary operator cannot be used immediately before an exponentiation expression
-            || expr.as_js_unary_expression().is_some()
-            || expr.as_js_await_expression().is_some(),
-    )
-}
-
-/// Determines whether the given node needs parens if used as the exponent in an exponentiation binary expression.
-fn does_exponent_need_parens(expr: &AnyJsExpression) -> Option {
-    Some(expr.precedence().ok()? < OperatorPrecedence::Exponential)
-}
-
 /// Determines whether the given parent node needs parens if used as the exponent in an exponentiation binary expression.
 fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option {
-    // Skips already parenthesized expressions
-    if has_parenthesized_parent_expression(AnyJsExpression::from(node.clone()))? {
-        return None;
-    }
-
     let parent = node.parent::()?;
 
-    let needs_parentheses = match parent.clone() {
+    let needs_parentheses = match &parent {
+        // Skips already parenthesized expressions
+        AnyJsExpression::JsParenthesizedExpression(_) => return None,
         AnyJsExpression::JsBinaryExpression(bin_expr) => {
             bin_expr.operator().ok()? != JsBinaryOperator::Exponent
                 && bin_expr.right().ok()?.as_js_call_expression()? != node
@@ -284,20 +278,3 @@ fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option Option {
-    let mut has_parenthesized_parent = false;
-
-    iter::successors(expression.parent::(), |parent| {
-        if matches!(parent, AnyJsExpression::JsParenthesizedExpression(_)) {
-            has_parenthesized_parent = true;
-            parent.parent::()
-        } else {
-            None
-        }
-    })
-    .last();
-
-    Some(has_parenthesized_parent)
-}

From 132fb30cc7086599006a757a78c01c101212f1ee Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Sun, 27 Nov 2022 01:12:05 +0000
Subject: [PATCH 05/11] fix: review binary expression condition to apply
 parenthenses

---
 .../src/analyzers/nursery/use_exponentiation_operator.rs      | 2 +-
 .../useExponentiationOperator/invalidAdjacentTokens.js.snap   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 4bef99d215e..59f8d95c2d6 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -236,7 +236,7 @@ fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option return None,
         AnyJsExpression::JsBinaryExpression(bin_expr) => {
             bin_expr.operator().ok()? != JsBinaryOperator::Exponent
-                && bin_expr.right().ok()?.as_js_call_expression()? != node
+                || bin_expr.right().ok()?.as_js_call_expression()? != node
         }
         AnyJsExpression::JsCallExpression(call_expr) => !call_expr
             .arguments()
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
index 24cf98470d6..709199a9faf 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
@@ -1,6 +1,6 @@
 ---
 source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 74
+assertion_line: 73
 expression: invalidAdjacentTokens.js
 ---
 # Input
@@ -229,7 +229,7 @@ invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiationOperator  FIXABLE  
     13 13 │   Math.pow(a, b) + Math.pow(c, d)
     14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
     15    │ - Math.pow(a,·b)**Math.pow(c,·d)
-       15 │ + a**b**Math.pow(c,·d)
+       15 │ + (a**b)**Math.pow(c,·d)
     16 16 │   
   
 

From 5e8b4bbfdd45e4959950c6953655222e1a899abd Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Sun, 27 Nov 2022 01:12:40 +0000
Subject: [PATCH 06/11] chore: support class expressions and declaration

---
 .../nursery/use_exponentiation_operator.rs    |  54 +++++++--
 .../useExponentiationOperator/invalidClass.js |   4 +
 .../invalidClass.js.snap                      | 104 +++++++++++++++++
 .../useExponentiationOperator/invalidClass.ts |   5 +
 .../invalidClass.ts.snap                      | 109 ++++++++++++++++++
 5 files changed, 264 insertions(+), 12 deletions(-)
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts.snap

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 59f8d95c2d6..3726636966e 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -4,7 +4,10 @@ use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
 use rome_console::markup;
 use rome_diagnostics::Applicability;
 use rome_js_factory::{make, syntax::T};
-use rome_js_syntax::{AnyJsExpression, JsBinaryOperator, JsCallExpression, OperatorPrecedence};
+use rome_js_syntax::{
+    AnyJsExpression, JsBinaryOperator, JsCallExpression, JsClassDeclaration, JsClassExpression,
+    JsExtendsClause, OperatorPrecedence,
+};
 use rome_rowan::{AstNode, AstSeparatedList, BatchMutationExt};
 
 declare_rule! {
@@ -176,12 +179,15 @@ impl Rule for UseExponentiationOperator {
             math_pow_call.get_exponent()?,
         );
 
-        if let Some(parent) = does_parent_expression_need_parens(node) {
+        if let Some((needs_parens, parent)) = does_exponentiation_expression_need_parens(node) {
+            if needs_parens && parent.is_some() {
+                mutation.replace_node(parent.clone()?, parenthesize_any_js_expression(&parent?));
+            }
+
             mutation.replace_node(
                 AnyJsExpression::from(node.clone()),
                 parenthesize_any_js_expression(&AnyJsExpression::from(new_node)),
             );
-            mutation.replace_node(parent.clone(), parenthesize_any_js_expression(&parent));
         } else {
             mutation.replace_node(
                 AnyJsExpression::from(node.clone()),
@@ -228,10 +234,37 @@ fn parenthesize_any_js_expression(expr: &AnyJsExpression) -> AnyJsExpression {
 }
 
 /// Determines whether the given parent node needs parens if used as the exponent in an exponentiation binary expression.
-fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option {
-    let parent = node.parent::()?;
+fn does_exponentiation_expression_need_parens(
+    node: &JsCallExpression,
+) -> Option<(bool, Option)> {
+    if let Some(parent) = node.parent::() {
+        if does_expression_need_parens(node, &parent)? {
+            return Some((true, Some(parent)));
+        }
+    }
+
+    if let Some(extends_clause) = node.parent::() {
+        if extends_clause.parent::().is_some() {
+            return Some((true, None));
+        }
+
+        if let Some(class_expr) = extends_clause.parent::() {
+            let class_expr = AnyJsExpression::from(class_expr);
+            if does_expression_need_parens(node, &class_expr)? {
+                return Some((true, Some(class_expr)));
+            }
+        }
+    }
+
+    None
+}
 
-    let needs_parentheses = match &parent {
+/// Determines whether the given expression needs parens when used in an exponentiation binary expression.
+fn does_expression_need_parens(
+    node: &JsCallExpression,
+    expression: &AnyJsExpression,
+) -> Option {
+    let needs_parentheses = match &expression {
         // Skips already parenthesized expressions
         AnyJsExpression::JsParenthesizedExpression(_) => return None,
         AnyJsExpression::JsBinaryExpression(bin_expr) => {
@@ -266,15 +299,12 @@ fn does_parent_expression_need_parens(node: &JsCallExpression) -> Option {
             member_expr.member().ok()?.as_js_call_expression()? != node
         }
-        AnyJsExpression::JsStaticMemberExpression(_)
+        AnyJsExpression::JsClassExpression(_)
+        | AnyJsExpression::JsStaticMemberExpression(_)
         | AnyJsExpression::JsUnaryExpression(_)
         | AnyJsExpression::JsTemplateExpression(_) => true,
         _ => false,
     };
 
-    if needs_parentheses && parent.precedence().ok()? >= OperatorPrecedence::Exponential {
-        return Some(parent);
-    }
-
-    None
+    Some(needs_parentheses && expression.precedence().ok()? >= OperatorPrecedence::Exponential)
 }
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
new file mode 100644
index 00000000000..c29128dbd1b
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
@@ -0,0 +1,4 @@
+class C extends Math.pow(a, b) {}
+(class extends Math.pow(a, b) {})
+(class extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) {}
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
new file mode 100644
index 00000000000..e537b3455a5
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
@@ -0,0 +1,104 @@
+---
+source: crates/rome_js_analyze/tests/spec_tests.rs
+assertion_line: 73
+expression: invalidClass.js
+---
+# Input
+```js
+class C extends Math.pow(a, b) {}
+(class extends Math.pow(a, b) {})
+(class extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) {}
+
+```
+
+# Diagnostics
+```
+invalidClass.js:1:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+  > 1 │ class C extends Math.pow(a, b) {}
+      │                 ^^^^^^^^^^^^^^
+    2 │ (class extends Math.pow(a, b) {})
+    3 │ (class extends (Math.pow(a, b)) {})
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1   │ - class·C·extends·Math.pow(a,·b)·{}
+      1 │ + class·C·extends·(a**b)·{}
+    2 2 │   (class extends Math.pow(a, b) {})
+    3 3 │   (class extends (Math.pow(a, b)) {})
+  
+
+```
+
+```
+invalidClass.js:2:16 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    1 │ class C extends Math.pow(a, b) {}
+  > 2 │ (class extends Math.pow(a, b) {})
+      │                ^^^^^^^^^^^^^^
+    3 │ (class extends (Math.pow(a, b)) {})
+    4 │ class C extends (Math.pow(a, b)) {}
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1 1 │   class C extends Math.pow(a, b) {}
+    2   │ - (class·extends·Math.pow(a,·b)·{})
+      2 │ + (class·extends·(a**b)·{})
+    3 3 │   (class extends (Math.pow(a, b)) {})
+    4 4 │   class C extends (Math.pow(a, b)) {}
+  
+
+```
+
+```
+invalidClass.js:3:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    1 │ class C extends Math.pow(a, b) {}
+    2 │ (class extends Math.pow(a, b) {})
+  > 3 │ (class extends (Math.pow(a, b)) {})
+      │                 ^^^^^^^^^^^^^^
+    4 │ class C extends (Math.pow(a, b)) {}
+    5 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1 1 │   class C extends Math.pow(a, b) {}
+    2 2 │   (class extends Math.pow(a, b) {})
+    3   │ - (class·extends·(Math.pow(a,·b))·{})
+      3 │ + (class·extends·(a**b)·{})
+    4 4 │   class C extends (Math.pow(a, b)) {}
+    5 5 │   
+  
+
+```
+
+```
+invalidClass.js:4:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    2 │ (class extends Math.pow(a, b) {})
+    3 │ (class extends (Math.pow(a, b)) {})
+  > 4 │ class C extends (Math.pow(a, b)) {}
+      │                  ^^^^^^^^^^^^^^
+    5 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    2 2 │   (class extends Math.pow(a, b) {})
+    3 3 │   (class extends (Math.pow(a, b)) {})
+    4   │ - class·C·extends·(Math.pow(a,·b))·{}
+      4 │ + class·C·extends·(a**b)·{}
+    5 5 │   
+  
+
+```
+
+
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts
new file mode 100644
index 00000000000..b39b13fe88a
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts
@@ -0,0 +1,5 @@
+// @ts-nocheck
+class C extends Math.pow(a, b) implements Foo {}
+(class A extends Math.pow(a, b) implements Foo {})
+(class A extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) implements Foo, Bar {}
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts.snap
new file mode 100644
index 00000000000..4d9e4be653e
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts.snap
@@ -0,0 +1,109 @@
+---
+source: crates/rome_js_analyze/tests/spec_tests.rs
+assertion_line: 73
+expression: invalidClass.ts
+---
+# Input
+```js
+// @ts-nocheck
+class C extends Math.pow(a, b) implements Foo {}
+(class A extends Math.pow(a, b) implements Foo {})
+(class A extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) implements Foo, Bar {}
+
+```
+
+# Diagnostics
+```
+invalidClass.ts:2:20 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    1 │ // @ts-nocheck
+  > 2 │ class C extends Math.pow(a, b) implements Foo {}
+      │                    ^^^^^^^^^^^^^^
+    3 │ (class A extends Math.pow(a, b) implements Foo {})
+    4 │ (class A extends (Math.pow(a, b)) {})
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1 1 │   // @ts-nocheck
+    2   │ - class·C·extends·Math.pow(a,·b)·implements·Foo·{}
+      2 │ + class·C·extends·(a**b)·implements·Foo·{}
+    3 3 │   (class A extends Math.pow(a, b) implements Foo {})
+    4 4 │   (class A extends (Math.pow(a, b)) {})
+  
+
+```
+
+```
+invalidClass.ts:3:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    1 │ // @ts-nocheck
+    2 │ class C extends Math.pow(a, b) implements Foo {}
+  > 3 │ (class A extends Math.pow(a, b) implements Foo {})
+      │                  ^^^^^^^^^^^^^^
+    4 │ (class A extends (Math.pow(a, b)) {})
+    5 │ class C extends (Math.pow(a, b)) implements Foo, Bar {}
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    1 1 │   // @ts-nocheck
+    2 2 │   class C extends Math.pow(a, b) implements Foo {}
+    3   │ - (class·A·extends·Math.pow(a,·b)·implements·Foo·{})
+      3 │ + (class·A·extends·(a**b)·implements·Foo·{})
+    4 4 │   (class A extends (Math.pow(a, b)) {})
+    5 5 │   class C extends (Math.pow(a, b)) implements Foo, Bar {}
+  
+
+```
+
+```
+invalidClass.ts:4:22 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    2 │ class C extends Math.pow(a, b) implements Foo {}
+    3 │ (class A extends Math.pow(a, b) implements Foo {})
+  > 4 │ (class A extends (Math.pow(a, b)) {})
+      │                      ^^^^^^^^^^^^^^
+    5 │ class C extends (Math.pow(a, b)) implements Foo, Bar {}
+    6 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    2 2 │   class C extends Math.pow(a, b) implements Foo {}
+    3 3 │   (class A extends Math.pow(a, b) implements Foo {})
+    4   │ - (class·A·extends·(Math.pow(a,·b))·{})
+      4 │ + (class·A·extends·(a**b)·{})
+    5 5 │   class C extends (Math.pow(a, b)) implements Foo, Bar {}
+    6 6 │   
+  
+
+```
+
+```
+invalidClass.ts:5:21 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    3 │ (class A extends Math.pow(a, b) implements Foo {})
+    4 │ (class A extends (Math.pow(a, b)) {})
+  > 5 │ class C extends (Math.pow(a, b)) implements Foo, Bar {}
+      │                     ^^^^^^^^^^^^^^
+    6 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    3 3 │   (class A extends Math.pow(a, b) implements Foo {})
+    4 4 │   (class A extends (Math.pow(a, b)) {})
+    5   │ - class·C·extends·(Math.pow(a,·b))·implements·Foo,·Bar·{}
+      5 │ + class·C·extends·(a**b)·implements·Foo,·Bar·{}
+    6 6 │   
+  
+
+```
+
+

From c7a2e1fdfcaa46341b5cd5d746a02be66cf33601 Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Sun, 27 Nov 2022 02:23:20 +0000
Subject: [PATCH 07/11] chore: support `in` expression

---
 .../nursery/use_exponentiation_operator.rs    | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 3726636966e..718f7652c1d 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -6,7 +6,7 @@ use rome_diagnostics::Applicability;
 use rome_js_factory::{make, syntax::T};
 use rome_js_syntax::{
     AnyJsExpression, JsBinaryOperator, JsCallExpression, JsClassDeclaration, JsClassExpression,
-    JsExtendsClause, OperatorPrecedence,
+    JsExtendsClause, JsInExpression, OperatorPrecedence,
 };
 use rome_rowan::{AstNode, AstSeparatedList, BatchMutationExt};
 
@@ -169,8 +169,8 @@ impl Rule for UseExponentiationOperator {
         let [base, exponent] = node.get_arguments_by_index([0, 1]);
 
         let math_pow_call = MathPowCall {
-            base: base?.as_js_any_expression()?.clone().omit_parentheses(),
-            exponent: exponent?.as_js_any_expression()?.clone().omit_parentheses(),
+            base: base?.as_any_js_expression()?.clone().omit_parentheses(),
+            exponent: exponent?.as_any_js_expression()?.clone().omit_parentheses(),
         };
 
         let new_node = make::js_binary_expression(
@@ -268,8 +268,16 @@ fn does_expression_need_parens(
         // Skips already parenthesized expressions
         AnyJsExpression::JsParenthesizedExpression(_) => return None,
         AnyJsExpression::JsBinaryExpression(bin_expr) => {
+            if bin_expr.parent::().is_some() {
+                return Some(true);
+            }
+
+            let binding = bin_expr.right().ok()?;
+            let call_expr = binding.as_js_call_expression();
+
             bin_expr.operator().ok()? != JsBinaryOperator::Exponent
-                || bin_expr.right().ok()?.as_js_call_expression()? != node
+                || call_expr.is_none()
+                || call_expr? != node
         }
         AnyJsExpression::JsCallExpression(call_expr) => !call_expr
             .arguments()
@@ -297,8 +305,12 @@ fn does_expression_need_parens(
             })
             .any(|arg| &arg == node),
         AnyJsExpression::JsComputedMemberExpression(member_expr) => {
-            member_expr.member().ok()?.as_js_call_expression()? != node
+            let binding = member_expr.member().ok()?;
+            let call_expr = binding.as_js_call_expression();
+
+            call_expr.is_none() || call_expr? != node
         }
+        AnyJsExpression::JsInExpression(_) => return Some(true),
         AnyJsExpression::JsClassExpression(_)
         | AnyJsExpression::JsStaticMemberExpression(_)
         | AnyJsExpression::JsUnaryExpression(_)

From 87bca7023411a8c9329a331ea336fb064e14bc26 Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Sun, 27 Nov 2022 02:23:34 +0000
Subject: [PATCH 08/11] chore: add more tests

---
 .../useExponentiationOperator/invalid.js      |  28 +-
 .../useExponentiationOperator/invalid.js.snap | 916 +++++++++++++-----
 .../invalidAdjacentTokens.js                  |  14 +-
 .../invalidAdjacentTokens.js.snap             | 375 +++++--
 .../useExponentiationOperator/invalidClass.js |   4 -
 .../invalidClass.js.snap                      | 104 --
 .../invalidParentsWithHigherPrecedence.js     |   1 +
 ...invalidParentsWithHigherPrecedence.js.snap | 273 +++---
 .../invalidParentsWithLowerPrecedence.js      |  11 -
 .../invalidParentsWithLowerPrecedence.js.snap | 283 +++---
 .../useExponentiationOperator/valid.js        |  16 +-
 .../useExponentiationOperator/valid.js.snap   |  18 +-
 12 files changed, 1259 insertions(+), 784 deletions(-)
 delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
 delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap

diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js
index 8b3819cc2cf..456fa7714ca 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js
@@ -2,8 +2,6 @@ Math.pow(a, b);
 (Math).pow(a, b);
 
 // able to catch some workarounds
-Math['pow'](a, b);
-Math["pow"](a, b);
 Math[`pow`](a, b);
 (Math)['pow'](a, b);
 (Math)["pow"](a, b);
@@ -18,9 +16,35 @@ switch(foo){ case Math.pow(a, b): break; }
 function foo(bar, baz = Math.pow(a, b), quux){}
 `${Math.pow(a, b)}`
 
+// non-expression parents that do require parens
+class C extends Math.pow(a, b) {}
+
 // already parenthesised, shouldn't insert extra parens
 +(Math.pow(a, b))
 (Math.pow(a, b)).toString()
+(class extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) {}
+
+// '**' is right-associative, that applies to both parent and child nodes
+a ** Math.pow(b, c);
+Math.pow(a, b) ** c;
+Math.pow(a, b ** c);
+Math.pow(a ** b, c);
+a ** Math.pow(b ** c, d ** e) ** f;
+
+// doesn't remove already existing unnecessary parens around the whole expression
+(Math.pow(a, b));
+foo + (Math.pow(a, b));
+(Math.pow(a, b)) + foo;
+`${(Math.pow(a, b))}`;
+
+// doesn't preserve unnecessary parens around base and exponent
+Math.pow((a), (b))
+Math.pow(((a)), ((b)))
+Math.pow((a.foo), b)
+Math.pow(a, (b.foo))
+Math.pow((a()), b)
+Math.pow(a, (b()))
 
 // Optional chaining
 Math.pow?.(a, b)
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
index e9ba6f26f70..c2b32cfe9de 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalid.js.snap
@@ -1,6 +1,6 @@
 ---
 source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 74
+assertion_line: 73
 expression: invalid.js
 ---
 # Input
@@ -9,8 +9,6 @@ Math.pow(a, b);
 (Math).pow(a, b);
 
 // able to catch some workarounds
-Math['pow'](a, b);
-Math["pow"](a, b);
 Math[`pow`](a, b);
 (Math)['pow'](a, b);
 (Math)["pow"](a, b);
@@ -25,9 +23,35 @@ switch(foo){ case Math.pow(a, b): break; }
 function foo(bar, baz = Math.pow(a, b), quux){}
 `${Math.pow(a, b)}`
 
+// non-expression parents that do require parens
+class C extends Math.pow(a, b) {}
+
 // already parenthesised, shouldn't insert extra parens
 +(Math.pow(a, b))
 (Math.pow(a, b)).toString()
+(class extends (Math.pow(a, b)) {})
+class C extends (Math.pow(a, b)) {}
+
+// '**' is right-associative, that applies to both parent and child nodes
+a ** Math.pow(b, c);
+Math.pow(a, b) ** c;
+Math.pow(a, b ** c);
+Math.pow(a ** b, c);
+a ** Math.pow(b ** c, d ** e) ** f;
+
+// doesn't remove already existing unnecessary parens around the whole expression
+(Math.pow(a, b));
+foo + (Math.pow(a, b));
+(Math.pow(a, b)) + foo;
+`${(Math.pow(a, b))}`;
+
+// doesn't preserve unnecessary parens around base and exponent
+Math.pow((a), (b))
+Math.pow(((a)), ((b)))
+Math.pow((a.foo), b)
+Math.pow(a, (b.foo))
+Math.pow((a()), b)
+Math.pow(a, (b()))
 
 // Optional chaining
 Math.pow?.(a, b)
@@ -93,19 +117,19 @@ invalid.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━
   ! Use the '**' operator instead of 'Math.pow'.
   
     4 │ // able to catch some workarounds
-  > 5 │ Math['pow'](a, b);
+  > 5 │ Math[`pow`](a, b);
       │ ^^^^^^^^^^^^^^^^^
-    6 │ Math["pow"](a, b);
-    7 │ Math[`pow`](a, b);
+    6 │ (Math)['pow'](a, b);
+    7 │ (Math)["pow"](a, b);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
      3  3 │   
      4  4 │   // able to catch some workarounds
-     5    │ - Math['pow'](a,·b);
+     5    │ - Math[`pow`](a,·b);
         5 │ + a**b;
-     6  6 │   Math["pow"](a, b);
-     7  7 │   Math[`pow`](a, b);
+     6  6 │   (Math)['pow'](a, b);
+     7  7 │   (Math)["pow"](a, b);
   
 
 ```
@@ -116,20 +140,20 @@ invalid.js:6:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━
   ! Use the '**' operator instead of 'Math.pow'.
   
     4 │ // able to catch some workarounds
-    5 │ Math['pow'](a, b);
-  > 6 │ Math["pow"](a, b);
-      │ ^^^^^^^^^^^^^^^^^
-    7 │ Math[`pow`](a, b);
-    8 │ (Math)['pow'](a, b);
+    5 │ Math[`pow`](a, b);
+  > 6 │ (Math)['pow'](a, b);
+      │ ^^^^^^^^^^^^^^^^^^^
+    7 │ (Math)["pow"](a, b);
+    8 │ (Math)[`pow`](a, b);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
      4  4 │   // able to catch some workarounds
-     5  5 │   Math['pow'](a, b);
-     6    │ - Math["pow"](a,·b);
+     5  5 │   Math[`pow`](a, b);
+     6    │ - (Math)['pow'](a,·b);
         6 │ + a**b;
-     7  7 │   Math[`pow`](a, b);
-     8  8 │   (Math)['pow'](a, b);
+     7  7 │   (Math)["pow"](a, b);
+     8  8 │   (Math)[`pow`](a, b);
   
 
 ```
@@ -139,21 +163,21 @@ invalid.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    5 │ Math['pow'](a, b);
-    6 │ Math["pow"](a, b);
-  > 7 │ Math[`pow`](a, b);
-      │ ^^^^^^^^^^^^^^^^^
-    8 │ (Math)['pow'](a, b);
-    9 │ (Math)["pow"](a, b);
+    5 │ Math[`pow`](a, b);
+    6 │ (Math)['pow'](a, b);
+  > 7 │ (Math)["pow"](a, b);
+      │ ^^^^^^^^^^^^^^^^^^^
+    8 │ (Math)[`pow`](a, b);
+    9 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     5  5 │   Math['pow'](a, b);
-     6  6 │   Math["pow"](a, b);
-     7    │ - Math[`pow`](a,·b);
+     5  5 │   Math[`pow`](a, b);
+     6  6 │   (Math)['pow'](a, b);
+     7    │ - (Math)["pow"](a,·b);
         7 │ + a**b;
-     8  8 │   (Math)['pow'](a, b);
-     9  9 │   (Math)["pow"](a, b);
+     8  8 │   (Math)[`pow`](a, b);
+     9  9 │   
   
 
 ```
@@ -163,446 +187,826 @@ invalid.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-     6 │ Math["pow"](a, b);
-     7 │ Math[`pow`](a, b);
-   > 8 │ (Math)['pow'](a, b);
+     6 │ (Math)['pow'](a, b);
+     7 │ (Math)["pow"](a, b);
+   > 8 │ (Math)[`pow`](a, b);
        │ ^^^^^^^^^^^^^^^^^^^
-     9 │ (Math)["pow"](a, b);
-    10 │ (Math)[`pow`](a, b);
+     9 │ 
+    10 │ // non-expression parents that don't require parens
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     6  6 │   Math["pow"](a, b);
-     7  7 │   Math[`pow`](a, b);
-     8    │ - (Math)['pow'](a,·b);
+     6  6 │   (Math)['pow'](a, b);
+     7  7 │   (Math)["pow"](a, b);
+     8    │ - (Math)[`pow`](a,·b);
         8 │ + a**b;
-     9  9 │   (Math)["pow"](a, b);
-    10 10 │   (Math)[`pow`](a, b);
+     9  9 │   
+    10 10 │   // non-expression parents that don't require parens
   
 
 ```
 
 ```
-invalid.js:9:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:11:9 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-     7 │ Math[`pow`](a, b);
-     8 │ (Math)['pow'](a, b);
-   > 9 │ (Math)["pow"](a, b);
-       │ ^^^^^^^^^^^^^^^^^^^
-    10 │ (Math)[`pow`](a, b);
-    11 │ 
+    10 │ // non-expression parents that don't require parens
+  > 11 │ var x = Math.pow(a, b);
+       │         ^^^^^^^^^^^^^^
+    12 │ if(Math.pow(a, b)){}
+    13 │ for(;Math.pow(a, b);){}
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     7  7 │   Math[`pow`](a, b);
-     8  8 │   (Math)['pow'](a, b);
-     9    │ - (Math)["pow"](a,·b);
-        9 │ + a**b;
-    10 10 │   (Math)[`pow`](a, b);
-    11 11 │   
+     9  9 │   
+    10 10 │   // non-expression parents that don't require parens
+    11    │ - var·x·=·Math.pow(a,·b);
+       11 │ + var·x·=·a**b;
+    12 12 │   if(Math.pow(a, b)){}
+    13 13 │   for(;Math.pow(a, b);){}
   
 
 ```
 
 ```
-invalid.js:10:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:12:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-     8 │ (Math)['pow'](a, b);
-     9 │ (Math)["pow"](a, b);
-  > 10 │ (Math)[`pow`](a, b);
-       │ ^^^^^^^^^^^^^^^^^^^
-    11 │ 
-    12 │ // non-expression parents that don't require parens
+    10 │ // non-expression parents that don't require parens
+    11 │ var x = Math.pow(a, b);
+  > 12 │ if(Math.pow(a, b)){}
+       │    ^^^^^^^^^^^^^^
+    13 │ for(;Math.pow(a, b);){}
+    14 │ switch(foo){ case Math.pow(a, b): break; }
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     8  8 │   (Math)['pow'](a, b);
-     9  9 │   (Math)["pow"](a, b);
-    10    │ - (Math)[`pow`](a,·b);
-       10 │ + a**b;
-    11 11 │   
-    12 12 │   // non-expression parents that don't require parens
+    10 10 │   // non-expression parents that don't require parens
+    11 11 │   var x = Math.pow(a, b);
+    12    │ - if(Math.pow(a,·b)){}
+       12 │ + if(a**b){}
+    13 13 │   for(;Math.pow(a, b);){}
+    14 14 │   switch(foo){ case Math.pow(a, b): break; }
   
 
 ```
 
 ```
-invalid.js:13:9 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:13:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ // non-expression parents that don't require parens
-  > 13 │ var x = Math.pow(a, b);
-       │         ^^^^^^^^^^^^^^
-    14 │ if(Math.pow(a, b)){}
-    15 │ for(;Math.pow(a, b);){}
+    11 │ var x = Math.pow(a, b);
+    12 │ if(Math.pow(a, b)){}
+  > 13 │ for(;Math.pow(a, b);){}
+       │      ^^^^^^^^^^^^^^
+    14 │ switch(foo){ case Math.pow(a, b): break; }
+    15 │ { foo: Math.pow(a, b) }
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    11 11 │   var x = Math.pow(a, b);
+    12 12 │   if(Math.pow(a, b)){}
+    13    │ - for(;Math.pow(a,·b);){}
+       13 │ + for(;a**b;){}
+    14 14 │   switch(foo){ case Math.pow(a, b): break; }
+    15 15 │   { foo: Math.pow(a, b) }
+  
+
+```
+
+```
+invalid.js:14:19 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    12 │ if(Math.pow(a, b)){}
+    13 │ for(;Math.pow(a, b);){}
+  > 14 │ switch(foo){ case Math.pow(a, b): break; }
+       │                   ^^^^^^^^^^^^^^
+    15 │ { foo: Math.pow(a, b) }
+    16 │ function foo(bar, baz = Math.pow(a, b), quux){}
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    12 12 │   if(Math.pow(a, b)){}
+    13 13 │   for(;Math.pow(a, b);){}
+    14    │ - switch(foo){·case·Math.pow(a,·b):·break;·}
+       14 │ + switch(foo){·case·a**b:·break;·}
+    15 15 │   { foo: Math.pow(a, b) }
+    16 16 │   function foo(bar, baz = Math.pow(a, b), quux){}
+  
+
+```
+
+```
+invalid.js:15:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    13 │ for(;Math.pow(a, b);){}
+    14 │ switch(foo){ case Math.pow(a, b): break; }
+  > 15 │ { foo: Math.pow(a, b) }
+       │        ^^^^^^^^^^^^^^
+    16 │ function foo(bar, baz = Math.pow(a, b), quux){}
+    17 │ `${Math.pow(a, b)}`
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    13 13 │   for(;Math.pow(a, b);){}
+    14 14 │   switch(foo){ case Math.pow(a, b): break; }
+    15    │ - {·foo:·Math.pow(a,·b)·}
+       15 │ + {·foo:·a**b·}
+    16 16 │   function foo(bar, baz = Math.pow(a, b), quux){}
+    17 17 │   `${Math.pow(a, b)}`
+  
+
+```
+
+```
+invalid.js:16:25 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    14 │ switch(foo){ case Math.pow(a, b): break; }
+    15 │ { foo: Math.pow(a, b) }
+  > 16 │ function foo(bar, baz = Math.pow(a, b), quux){}
+       │                         ^^^^^^^^^^^^^^
+    17 │ `${Math.pow(a, b)}`
+    18 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    11 11 │   
-    12 12 │   // non-expression parents that don't require parens
-    13    │ - var·x·=·Math.pow(a,·b);
-       13 │ + var·x·=·a**b;
-    14 14 │   if(Math.pow(a, b)){}
-    15 15 │   for(;Math.pow(a, b);){}
+    14 14 │   switch(foo){ case Math.pow(a, b): break; }
+    15 15 │   { foo: Math.pow(a, b) }
+    16    │ - function·foo(bar,·baz·=·Math.pow(a,·b),·quux){}
+       16 │ + function·foo(bar,·baz·=·a**b,·quux){}
+    17 17 │   `${Math.pow(a, b)}`
+    18 18 │   
   
 
 ```
 
 ```
-invalid.js:14:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:17:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ // non-expression parents that don't require parens
-    13 │ var x = Math.pow(a, b);
-  > 14 │ if(Math.pow(a, b)){}
+    15 │ { foo: Math.pow(a, b) }
+    16 │ function foo(bar, baz = Math.pow(a, b), quux){}
+  > 17 │ `${Math.pow(a, b)}`
        │    ^^^^^^^^^^^^^^
-    15 │ for(;Math.pow(a, b);){}
-    16 │ switch(foo){ case Math.pow(a, b): break; }
+    18 │ 
+    19 │ // non-expression parents that do require parens
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    15 15 │   { foo: Math.pow(a, b) }
+    16 16 │   function foo(bar, baz = Math.pow(a, b), quux){}
+    17    │ - `${Math.pow(a,·b)}`
+       17 │ + `${a**b}`
+    18 18 │   
+    19 19 │   // non-expression parents that do require parens
+  
+
+```
+
+```
+invalid.js:20:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    19 │ // non-expression parents that do require parens
+  > 20 │ class C extends Math.pow(a, b) {}
+       │                 ^^^^^^^^^^^^^^
+    21 │ 
+    22 │ // already parenthesised, shouldn't insert extra parens
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    18 18 │   
+    19 19 │   // non-expression parents that do require parens
+    20    │ - class·C·extends·Math.pow(a,·b)·{}
+       20 │ + class·C·extends·(a**b)·{}
+    21 21 │   
+    22 22 │   // already parenthesised, shouldn't insert extra parens
+  
+
+```
+
+```
+invalid.js:23:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    22 │ // already parenthesised, shouldn't insert extra parens
+  > 23 │ +(Math.pow(a, b))
+       │   ^^^^^^^^^^^^^^
+    24 │ (Math.pow(a, b)).toString()
+    25 │ (class extends (Math.pow(a, b)) {})
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    21 21 │   
+    22 22 │   // already parenthesised, shouldn't insert extra parens
+    23    │ - +(Math.pow(a,·b))
+       23 │ + +(a**b)
+    24 24 │   (Math.pow(a, b)).toString()
+    25 25 │   (class extends (Math.pow(a, b)) {})
+  
+
+```
+
+```
+invalid.js:24:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    22 │ // already parenthesised, shouldn't insert extra parens
+    23 │ +(Math.pow(a, b))
+  > 24 │ (Math.pow(a, b)).toString()
+       │  ^^^^^^^^^^^^^^
+    25 │ (class extends (Math.pow(a, b)) {})
+    26 │ class C extends (Math.pow(a, b)) {}
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    22 22 │   // already parenthesised, shouldn't insert extra parens
+    23 23 │   +(Math.pow(a, b))
+    24    │ - (Math.pow(a,·b)).toString()
+       24 │ + (a**b).toString()
+    25 25 │   (class extends (Math.pow(a, b)) {})
+    26 26 │   class C extends (Math.pow(a, b)) {}
+  
+
+```
+
+```
+invalid.js:25:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    23 │ +(Math.pow(a, b))
+    24 │ (Math.pow(a, b)).toString()
+  > 25 │ (class extends (Math.pow(a, b)) {})
+       │                 ^^^^^^^^^^^^^^
+    26 │ class C extends (Math.pow(a, b)) {}
+    27 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   // non-expression parents that don't require parens
-    13 13 │   var x = Math.pow(a, b);
-    14    │ - if(Math.pow(a,·b)){}
-       14 │ + if(a**b){}
-    15 15 │   for(;Math.pow(a, b);){}
-    16 16 │   switch(foo){ case Math.pow(a, b): break; }
+    23 23 │   +(Math.pow(a, b))
+    24 24 │   (Math.pow(a, b)).toString()
+    25    │ - (class·extends·(Math.pow(a,·b))·{})
+       25 │ + (class·extends·(a**b)·{})
+    26 26 │   class C extends (Math.pow(a, b)) {}
+    27 27 │   
   
 
 ```
 
 ```
-invalid.js:15:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:26:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    13 │ var x = Math.pow(a, b);
-    14 │ if(Math.pow(a, b)){}
-  > 15 │ for(;Math.pow(a, b);){}
+    24 │ (Math.pow(a, b)).toString()
+    25 │ (class extends (Math.pow(a, b)) {})
+  > 26 │ class C extends (Math.pow(a, b)) {}
+       │                  ^^^^^^^^^^^^^^
+    27 │ 
+    28 │ // '**' is right-associative, that applies to both parent and child nodes
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    24 24 │   (Math.pow(a, b)).toString()
+    25 25 │   (class extends (Math.pow(a, b)) {})
+    26    │ - class·C·extends·(Math.pow(a,·b))·{}
+       26 │ + class·C·extends·(a**b)·{}
+    27 27 │   
+    28 28 │   // '**' is right-associative, that applies to both parent and child nodes
+  
+
+```
+
+```
+invalid.js:29:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    28 │ // '**' is right-associative, that applies to both parent and child nodes
+  > 29 │ a ** Math.pow(b, c);
        │      ^^^^^^^^^^^^^^
-    16 │ switch(foo){ case Math.pow(a, b): break; }
-    17 │ { foo: Math.pow(a, b) }
+    30 │ Math.pow(a, b) ** c;
+    31 │ Math.pow(a, b ** c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    13 13 │   var x = Math.pow(a, b);
-    14 14 │   if(Math.pow(a, b)){}
-    15    │ - for(;Math.pow(a,·b);){}
-       15 │ + for(;a**b;){}
-    16 16 │   switch(foo){ case Math.pow(a, b): break; }
-    17 17 │   { foo: Math.pow(a, b) }
+    27 27 │   
+    28 28 │   // '**' is right-associative, that applies to both parent and child nodes
+    29    │ - a·**·Math.pow(b,·c);
+       29 │ + a·**·b**c;
+    30 30 │   Math.pow(a, b) ** c;
+    31 31 │   Math.pow(a, b ** c);
   
 
 ```
 
 ```
-invalid.js:16:19 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:30:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    14 │ if(Math.pow(a, b)){}
-    15 │ for(;Math.pow(a, b);){}
-  > 16 │ switch(foo){ case Math.pow(a, b): break; }
-       │                   ^^^^^^^^^^^^^^
-    17 │ { foo: Math.pow(a, b) }
-    18 │ function foo(bar, baz = Math.pow(a, b), quux){}
+    28 │ // '**' is right-associative, that applies to both parent and child nodes
+    29 │ a ** Math.pow(b, c);
+  > 30 │ Math.pow(a, b) ** c;
+       │ ^^^^^^^^^^^^^^
+    31 │ Math.pow(a, b ** c);
+    32 │ Math.pow(a ** b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    14 14 │   if(Math.pow(a, b)){}
-    15 15 │   for(;Math.pow(a, b);){}
-    16    │ - switch(foo){·case·Math.pow(a,·b):·break;·}
-       16 │ + switch(foo){·case·a**b:·break;·}
-    17 17 │   { foo: Math.pow(a, b) }
-    18 18 │   function foo(bar, baz = Math.pow(a, b), quux){}
+    28 28 │   // '**' is right-associative, that applies to both parent and child nodes
+    29 29 │   a ** Math.pow(b, c);
+    30    │ - Math.pow(a,·b)·**·c;
+       30 │ + (a**b)·**·c;
+    31 31 │   Math.pow(a, b ** c);
+    32 32 │   Math.pow(a ** b, c);
   
 
 ```
 
 ```
-invalid.js:17:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:31:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    15 │ for(;Math.pow(a, b);){}
-    16 │ switch(foo){ case Math.pow(a, b): break; }
-  > 17 │ { foo: Math.pow(a, b) }
-       │        ^^^^^^^^^^^^^^
-    18 │ function foo(bar, baz = Math.pow(a, b), quux){}
-    19 │ `${Math.pow(a, b)}`
+    29 │ a ** Math.pow(b, c);
+    30 │ Math.pow(a, b) ** c;
+  > 31 │ Math.pow(a, b ** c);
+       │ ^^^^^^^^^^^^^^^^^^^
+    32 │ Math.pow(a ** b, c);
+    33 │ a ** Math.pow(b ** c, d ** e) ** f;
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    15 15 │   for(;Math.pow(a, b);){}
-    16 16 │   switch(foo){ case Math.pow(a, b): break; }
-    17    │ - {·foo:·Math.pow(a,·b)·}
-       17 │ + {·foo:·a**b·}
-    18 18 │   function foo(bar, baz = Math.pow(a, b), quux){}
-    19 19 │   `${Math.pow(a, b)}`
+    29 29 │   a ** Math.pow(b, c);
+    30 30 │   Math.pow(a, b) ** c;
+    31    │ - Math.pow(a,·b·**·c);
+       31 │ + a**b·**·c;
+    32 32 │   Math.pow(a ** b, c);
+    33 33 │   a ** Math.pow(b ** c, d ** e) ** f;
   
 
 ```
 
 ```
-invalid.js:18:25 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:32:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    16 │ switch(foo){ case Math.pow(a, b): break; }
-    17 │ { foo: Math.pow(a, b) }
-  > 18 │ function foo(bar, baz = Math.pow(a, b), quux){}
-       │                         ^^^^^^^^^^^^^^
-    19 │ `${Math.pow(a, b)}`
-    20 │ 
+    30 │ Math.pow(a, b) ** c;
+    31 │ Math.pow(a, b ** c);
+  > 32 │ Math.pow(a ** b, c);
+       │ ^^^^^^^^^^^^^^^^^^^
+    33 │ a ** Math.pow(b ** c, d ** e) ** f;
+    34 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    16 16 │   switch(foo){ case Math.pow(a, b): break; }
-    17 17 │   { foo: Math.pow(a, b) }
-    18    │ - function·foo(bar,·baz·=·Math.pow(a,·b),·quux){}
-       18 │ + function·foo(bar,·baz·=·a**b,·quux){}
-    19 19 │   `${Math.pow(a, b)}`
-    20 20 │   
+    30 30 │   Math.pow(a, b) ** c;
+    31 31 │   Math.pow(a, b ** c);
+    32    │ - Math.pow(a·**·b,·c);
+       32 │ + (a·**·b)**c;
+    33 33 │   a ** Math.pow(b ** c, d ** e) ** f;
+    34 34 │   
   
 
 ```
 
 ```
-invalid.js:19:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:33:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    17 │ { foo: Math.pow(a, b) }
-    18 │ function foo(bar, baz = Math.pow(a, b), quux){}
-  > 19 │ `${Math.pow(a, b)}`
-       │    ^^^^^^^^^^^^^^
-    20 │ 
-    21 │ // already parenthesised, shouldn't insert extra parens
+    31 │ Math.pow(a, b ** c);
+    32 │ Math.pow(a ** b, c);
+  > 33 │ a ** Math.pow(b ** c, d ** e) ** f;
+       │      ^^^^^^^^^^^^^^^^^^^^^^^^
+    34 │ 
+    35 │ // doesn't remove already existing unnecessary parens around the whole expression
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    17 17 │   { foo: Math.pow(a, b) }
-    18 18 │   function foo(bar, baz = Math.pow(a, b), quux){}
-    19    │ - `${Math.pow(a,·b)}`
-       19 │ + `${a**b}`
-    20 20 │   
-    21 21 │   // already parenthesised, shouldn't insert extra parens
+    31 31 │   Math.pow(a, b ** c);
+    32 32 │   Math.pow(a ** b, c);
+    33    │ - a·**·Math.pow(b·**·c,·d·**·e)·**·f;
+       33 │ + a·**·((b·**·c)**d·**·e)·**·f;
+    34 34 │   
+    35 35 │   // doesn't remove already existing unnecessary parens around the whole expression
   
 
 ```
 
 ```
-invalid.js:22:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:36:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    21 │ // already parenthesised, shouldn't insert extra parens
-  > 22 │ +(Math.pow(a, b))
-       │   ^^^^^^^^^^^^^^
-    23 │ (Math.pow(a, b)).toString()
-    24 │ 
+    35 │ // doesn't remove already existing unnecessary parens around the whole expression
+  > 36 │ (Math.pow(a, b));
+       │  ^^^^^^^^^^^^^^
+    37 │ foo + (Math.pow(a, b));
+    38 │ (Math.pow(a, b)) + foo;
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    34 34 │   
+    35 35 │   // doesn't remove already existing unnecessary parens around the whole expression
+    36    │ - (Math.pow(a,·b));
+       36 │ + (a**b);
+    37 37 │   foo + (Math.pow(a, b));
+    38 38 │   (Math.pow(a, b)) + foo;
+  
+
+```
+
+```
+invalid.js:37:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    35 │ // doesn't remove already existing unnecessary parens around the whole expression
+    36 │ (Math.pow(a, b));
+  > 37 │ foo + (Math.pow(a, b));
+       │        ^^^^^^^^^^^^^^
+    38 │ (Math.pow(a, b)) + foo;
+    39 │ `${(Math.pow(a, b))}`;
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    20 20 │   
-    21 21 │   // already parenthesised, shouldn't insert extra parens
-    22    │ - +(Math.pow(a,·b))
-       22 │ + +(a**b)
-    23 23 │   (Math.pow(a, b)).toString()
-    24 24 │   
+    35 35 │   // doesn't remove already existing unnecessary parens around the whole expression
+    36 36 │   (Math.pow(a, b));
+    37    │ - foo·+·(Math.pow(a,·b));
+       37 │ + foo·+·(a**b);
+    38 38 │   (Math.pow(a, b)) + foo;
+    39 39 │   `${(Math.pow(a, b))}`;
   
 
 ```
 
 ```
-invalid.js:23:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:38:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    21 │ // already parenthesised, shouldn't insert extra parens
-    22 │ +(Math.pow(a, b))
-  > 23 │ (Math.pow(a, b)).toString()
+    36 │ (Math.pow(a, b));
+    37 │ foo + (Math.pow(a, b));
+  > 38 │ (Math.pow(a, b)) + foo;
        │  ^^^^^^^^^^^^^^
-    24 │ 
-    25 │ // Optional chaining
+    39 │ `${(Math.pow(a, b))}`;
+    40 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    36 36 │   (Math.pow(a, b));
+    37 37 │   foo + (Math.pow(a, b));
+    38    │ - (Math.pow(a,·b))·+·foo;
+       38 │ + (a**b)·+·foo;
+    39 39 │   `${(Math.pow(a, b))}`;
+    40 40 │   
+  
+
+```
+
+```
+invalid.js:39:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    37 │ foo + (Math.pow(a, b));
+    38 │ (Math.pow(a, b)) + foo;
+  > 39 │ `${(Math.pow(a, b))}`;
+       │     ^^^^^^^^^^^^^^
+    40 │ 
+    41 │ // doesn't preserve unnecessary parens around base and exponent
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    37 37 │   foo + (Math.pow(a, b));
+    38 38 │   (Math.pow(a, b)) + foo;
+    39    │ - `${(Math.pow(a,·b))}`;
+       39 │ + `${(a**b)}`;
+    40 40 │   
+    41 41 │   // doesn't preserve unnecessary parens around base and exponent
+  
+
+```
+
+```
+invalid.js:42:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    41 │ // doesn't preserve unnecessary parens around base and exponent
+  > 42 │ Math.pow((a), (b))
+       │ ^^^^^^^^^^^^^^^^^^
+    43 │ Math.pow(((a)), ((b)))
+    44 │ Math.pow((a.foo), b)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    21 21 │   // already parenthesised, shouldn't insert extra parens
-    22 22 │   +(Math.pow(a, b))
-    23    │ - (Math.pow(a,·b)).toString()
-       23 │ + (a**b).toString()
-    24 24 │   
-    25 25 │   // Optional chaining
+    40 40 │   
+    41 41 │   // doesn't preserve unnecessary parens around base and exponent
+    42    │ - Math.pow((a),·(b))
+       42 │ + a**b
+    43 43 │   Math.pow(((a)), ((b)))
+    44 44 │   Math.pow((a.foo), b)
   
 
 ```
 
 ```
-invalid.js:26:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:43:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    25 │ // Optional chaining
-  > 26 │ Math.pow?.(a, b)
+    41 │ // doesn't preserve unnecessary parens around base and exponent
+    42 │ Math.pow((a), (b))
+  > 43 │ Math.pow(((a)), ((b)))
+       │ ^^^^^^^^^^^^^^^^^^^^^^
+    44 │ Math.pow((a.foo), b)
+    45 │ Math.pow(a, (b.foo))
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    41 41 │   // doesn't preserve unnecessary parens around base and exponent
+    42 42 │   Math.pow((a), (b))
+    43    │ - Math.pow(((a)),·((b)))
+       43 │ + a**b
+    44 44 │   Math.pow((a.foo), b)
+    45 45 │   Math.pow(a, (b.foo))
+  
+
+```
+
+```
+invalid.js:44:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    42 │ Math.pow((a), (b))
+    43 │ Math.pow(((a)), ((b)))
+  > 44 │ Math.pow((a.foo), b)
+       │ ^^^^^^^^^^^^^^^^^^^^
+    45 │ Math.pow(a, (b.foo))
+    46 │ Math.pow((a()), b)
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    42 42 │   Math.pow((a), (b))
+    43 43 │   Math.pow(((a)), ((b)))
+    44    │ - Math.pow((a.foo),·b)
+       44 │ + a.foo**b
+    45 45 │   Math.pow(a, (b.foo))
+    46 46 │   Math.pow((a()), b)
+  
+
+```
+
+```
+invalid.js:45:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    43 │ Math.pow(((a)), ((b)))
+    44 │ Math.pow((a.foo), b)
+  > 45 │ Math.pow(a, (b.foo))
+       │ ^^^^^^^^^^^^^^^^^^^^
+    46 │ Math.pow((a()), b)
+    47 │ Math.pow(a, (b()))
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    43 43 │   Math.pow(((a)), ((b)))
+    44 44 │   Math.pow((a.foo), b)
+    45    │ - Math.pow(a,·(b.foo))
+       45 │ + a**b.foo
+    46 46 │   Math.pow((a()), b)
+    47 47 │   Math.pow(a, (b()))
+  
+
+```
+
+```
+invalid.js:46:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    44 │ Math.pow((a.foo), b)
+    45 │ Math.pow(a, (b.foo))
+  > 46 │ Math.pow((a()), b)
+       │ ^^^^^^^^^^^^^^^^^^
+    47 │ Math.pow(a, (b()))
+    48 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    44 44 │   Math.pow((a.foo), b)
+    45 45 │   Math.pow(a, (b.foo))
+    46    │ - Math.pow((a()),·b)
+       46 │ + a()**b
+    47 47 │   Math.pow(a, (b()))
+    48 48 │   
+  
+
+```
+
+```
+invalid.js:47:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    45 │ Math.pow(a, (b.foo))
+    46 │ Math.pow((a()), b)
+  > 47 │ Math.pow(a, (b()))
+       │ ^^^^^^^^^^^^^^^^^^
+    48 │ 
+    49 │ // Optional chaining
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    45 45 │   Math.pow(a, (b.foo))
+    46 46 │   Math.pow((a()), b)
+    47    │ - Math.pow(a,·(b()))
+       47 │ + a**b()
+    48 48 │   
+    49 49 │   // Optional chaining
+  
+
+```
+
+```
+invalid.js:50:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    49 │ // Optional chaining
+  > 50 │ Math.pow?.(a, b)
        │ ^^^^^^^^^^^^^^^^
-    27 │ Math?.pow(a, b)
-    28 │ Math?.pow?.(a, b)
+    51 │ Math?.pow(a, b)
+    52 │ Math?.pow?.(a, b)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    24 24 │   
-    25 25 │   // Optional chaining
-    26    │ - Math.pow?.(a,·b)
-       26 │ + a**b
-    27 27 │   Math?.pow(a, b)
-    28 28 │   Math?.pow?.(a, b)
+    48 48 │   
+    49 49 │   // Optional chaining
+    50    │ - Math.pow?.(a,·b)
+       50 │ + a**b
+    51 51 │   Math?.pow(a, b)
+    52 52 │   Math?.pow?.(a, b)
   
 
 ```
 
 ```
-invalid.js:27:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:51:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    25 │ // Optional chaining
-    26 │ Math.pow?.(a, b)
-  > 27 │ Math?.pow(a, b)
+    49 │ // Optional chaining
+    50 │ Math.pow?.(a, b)
+  > 51 │ Math?.pow(a, b)
        │ ^^^^^^^^^^^^^^^
-    28 │ Math?.pow?.(a, b)
-    29 │ ;(Math?.pow)(a, b)
+    52 │ Math?.pow?.(a, b)
+    53 │ ;(Math?.pow)(a, b)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    25 25 │   // Optional chaining
-    26 26 │   Math.pow?.(a, b)
-    27    │ - Math?.pow(a,·b)
-       27 │ + a**b
-    28 28 │   Math?.pow?.(a, b)
-    29 29 │   ;(Math?.pow)(a, b)
+    49 49 │   // Optional chaining
+    50 50 │   Math.pow?.(a, b)
+    51    │ - Math?.pow(a,·b)
+       51 │ + a**b
+    52 52 │   Math?.pow?.(a, b)
+    53 53 │   ;(Math?.pow)(a, b)
   
 
 ```
 
 ```
-invalid.js:28:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:52:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    26 │ Math.pow?.(a, b)
-    27 │ Math?.pow(a, b)
-  > 28 │ Math?.pow?.(a, b)
+    50 │ Math.pow?.(a, b)
+    51 │ Math?.pow(a, b)
+  > 52 │ Math?.pow?.(a, b)
        │ ^^^^^^^^^^^^^^^^^
-    29 │ ;(Math?.pow)(a, b)
-    30 │ ;(Math?.pow)?.(a, b)
+    53 │ ;(Math?.pow)(a, b)
+    54 │ ;(Math?.pow)?.(a, b)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    26 26 │   Math.pow?.(a, b)
-    27 27 │   Math?.pow(a, b)
-    28    │ - Math?.pow?.(a,·b)
-       28 │ + a**b
-    29 29 │   ;(Math?.pow)(a, b)
-    30 30 │   ;(Math?.pow)?.(a, b)
+    50 50 │   Math.pow?.(a, b)
+    51 51 │   Math?.pow(a, b)
+    52    │ - Math?.pow?.(a,·b)
+       52 │ + a**b
+    53 53 │   ;(Math?.pow)(a, b)
+    54 54 │   ;(Math?.pow)?.(a, b)
   
 
 ```
 
 ```
-invalid.js:29:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:53:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    27 │ Math?.pow(a, b)
-    28 │ Math?.pow?.(a, b)
-  > 29 │ ;(Math?.pow)(a, b)
+    51 │ Math?.pow(a, b)
+    52 │ Math?.pow?.(a, b)
+  > 53 │ ;(Math?.pow)(a, b)
        │  ^^^^^^^^^^^^^^^^^
-    30 │ ;(Math?.pow)?.(a, b)
-    31 │ 
+    54 │ ;(Math?.pow)?.(a, b)
+    55 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    27 27 │   Math?.pow(a, b)
-    28 28 │   Math?.pow?.(a, b)
-    29    │ - ;(Math?.pow)(a,·b)
-       29 │ + ;a**b
-    30 30 │   ;(Math?.pow)?.(a, b)
-    31 31 │   
+    51 51 │   Math?.pow(a, b)
+    52 52 │   Math?.pow?.(a, b)
+    53    │ - ;(Math?.pow)(a,·b)
+       53 │ + ;a**b
+    54 54 │   ;(Math?.pow)?.(a, b)
+    55 55 │   
   
 
 ```
 
 ```
-invalid.js:30:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:54:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    28 │ Math?.pow?.(a, b)
-    29 │ ;(Math?.pow)(a, b)
-  > 30 │ ;(Math?.pow)?.(a, b)
+    52 │ Math?.pow?.(a, b)
+    53 │ ;(Math?.pow)(a, b)
+  > 54 │ ;(Math?.pow)?.(a, b)
        │  ^^^^^^^^^^^^^^^^^^^
-    31 │ 
-    32 │ // doesn't put extra parens
+    55 │ 
+    56 │ // doesn't put extra parens
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    28 28 │   Math?.pow?.(a, b)
-    29 29 │   ;(Math?.pow)(a, b)
-    30    │ - ;(Math?.pow)?.(a,·b)
-       30 │ + ;a**b
-    31 31 │   
-    32 32 │   // doesn't put extra parens
+    52 52 │   Math?.pow?.(a, b)
+    53 53 │   ;(Math?.pow)(a, b)
+    54    │ - ;(Math?.pow)?.(a,·b)
+       54 │ + ;a**b
+    55 55 │   
+    56 56 │   // doesn't put extra parens
   
 
 ```
 
 ```
-invalid.js:33:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:57:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    32 │ // doesn't put extra parens
-  > 33 │ Math.pow((a + b), (c + d))
+    56 │ // doesn't put extra parens
+  > 57 │ Math.pow((a + b), (c + d))
        │ ^^^^^^^^^^^^^^^^^^^^^^^^^^
-    34 │ 
-    35 │ // tokens that can be adjacent
+    58 │ 
+    59 │ // tokens that can be adjacent
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    31 31 │   
-    32 32 │   // doesn't put extra parens
-    33    │ - Math.pow((a·+·b),·(c·+·d))
-       33 │ + (a·+·b)**(c·+·d)
-    34 34 │   
-    35 35 │   // tokens that can be adjacent
+    55 55 │   
+    56 56 │   // doesn't put extra parens
+    57    │ - Math.pow((a·+·b),·(c·+·d))
+       57 │ + (a·+·b)**(c·+·d)
+    58 58 │   
+    59 59 │   // tokens that can be adjacent
   
 
 ```
 
 ```
-invalid.js:36:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+invalid.js:60:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    35 │ // tokens that can be adjacent
-  > 36 │ a+Math.pow(b, c)+d
+    59 │ // tokens that can be adjacent
+  > 60 │ a+Math.pow(b, c)+d
        │   ^^^^^^^^^^^^^^
-    37 │ 
+    61 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    34 34 │   
-    35 35 │   // tokens that can be adjacent
-    36    │ - a+Math.pow(b,·c)+d
-       36 │ + a+b**c+d
-    37 37 │   
+    58 58 │   
+    59 59 │   // tokens that can be adjacent
+    60    │ - a+Math.pow(b,·c)+d
+       60 │ + a+b**c+d
+    61 61 │   
   
 
 ```
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js
index 06f52066619..aa3279d66ed 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js
@@ -1,15 +1,19 @@
 // tokens that cannot be adjacent
 a+Math.pow(++b, c);
 (a)+(Math).pow((++b), c);
+Math.pow(a, b)in c
+Math.pow(a, (b))in (c)
+a+Math.pow(++b, c)in d
+a+Math.pow( ++b, c )in d
 
-// not supported yet
-//Math.pow(a, b)in c
-//Math.pow(a, (b))in (c)
-//a+Math.pow(++b, c)in d
-//a+Math.pow( ++b, c )in d
+// tokens that cannot be adjacent, but there is already space or something else between
+a+ Math.pow(++b, c) in d
+// a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+a+(Math.pow(++b, c))in d
 
 // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
 +Math.pow(++a, b)
+Math.pow(a, b + c)in d
 Math.pow(a, b) + Math.pow(c, d)
 Math.pow(Math.pow(a, b), Math.pow(c, d))
 Math.pow(a, b)**Math.pow(c, d)
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
index 709199a9faf..d390782ed03 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidAdjacentTokens.js.snap
@@ -8,15 +8,19 @@ expression: invalidAdjacentTokens.js
 // tokens that cannot be adjacent
 a+Math.pow(++b, c);
 (a)+(Math).pow((++b), c);
+Math.pow(a, b)in c
+Math.pow(a, (b))in (c)
+a+Math.pow(++b, c)in d
+a+Math.pow( ++b, c )in d
 
-// not supported yet
-//Math.pow(a, b)in c
-//Math.pow(a, (b))in (c)
-//a+Math.pow(++b, c)in d
-//a+Math.pow( ++b, c )in d
+// tokens that cannot be adjacent, but there is already space or something else between
+a+ Math.pow(++b, c) in d
+// a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+a+(Math.pow(++b, c))in d
 
 // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
 +Math.pow(++a, b)
+Math.pow(a, b + c)in d
 Math.pow(a, b) + Math.pow(c, d)
 Math.pow(Math.pow(a, b), Math.pow(c, d))
 Math.pow(a, b)**Math.pow(c, d)
@@ -33,7 +37,7 @@ invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiationOperator  FIXABLE  
   > 2 │ a+Math.pow(++b, c);
       │   ^^^^^^^^^^^^^^^^
     3 │ (a)+(Math).pow((++b), c);
-    4 │ 
+    4 │ Math.pow(a, b)in c
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
@@ -41,7 +45,7 @@ invalidAdjacentTokens.js:2:3 lint/nursery/useExponentiationOperator  FIXABLE  
      2    │ - a+Math.pow(++b,·c);
         2 │ + a+++b**c;
      3  3 │   (a)+(Math).pow((++b), c);
-     4  4 │   
+     4  4 │   Math.pow(a, b)in c
   
 
 ```
@@ -55,8 +59,8 @@ invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiationOperator  FIXABLE  
     2 │ a+Math.pow(++b, c);
   > 3 │ (a)+(Math).pow((++b), c);
       │     ^^^^^^^^^^^^^^^^^^^^
-    4 │ 
-    5 │ // not supported yet
+    4 │ Math.pow(a, b)in c
+    5 │ Math.pow(a, (b))in (c)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
@@ -64,195 +68,362 @@ invalidAdjacentTokens.js:3:5 lint/nursery/useExponentiationOperator  FIXABLE  
      2  2 │   a+Math.pow(++b, c);
      3    │ - (a)+(Math).pow((++b),·c);
         3 │ + (a)+++b**c;
-     4  4 │   
-     5  5 │   // not supported yet
+     4  4 │   Math.pow(a, b)in c
+     5  5 │   Math.pow(a, (b))in (c)
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:12:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:4:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-  > 12 │ +Math.pow(++a, b)
+    2 │ a+Math.pow(++b, c);
+    3 │ (a)+(Math).pow((++b), c);
+  > 4 │ Math.pow(a, b)in c
+      │ ^^^^^^^^^^^^^^
+    5 │ Math.pow(a, (b))in (c)
+    6 │ a+Math.pow(++b, c)in d
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     2  2 │   a+Math.pow(++b, c);
+     3  3 │   (a)+(Math).pow((++b), c);
+     4    │ - Math.pow(a,·b)in·c
+        4 │ + (a**b)in·c
+     5  5 │   Math.pow(a, (b))in (c)
+     6  6 │   a+Math.pow(++b, c)in d
+  
+
+```
+
+```
+invalidAdjacentTokens.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    3 │ (a)+(Math).pow((++b), c);
+    4 │ Math.pow(a, b)in c
+  > 5 │ Math.pow(a, (b))in (c)
+      │ ^^^^^^^^^^^^^^^^
+    6 │ a+Math.pow(++b, c)in d
+    7 │ a+Math.pow( ++b, c )in d
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     3  3 │   (a)+(Math).pow((++b), c);
+     4  4 │   Math.pow(a, b)in c
+     5    │ - Math.pow(a,·(b))in·(c)
+        5 │ + (a**b)in·(c)
+     6  6 │   a+Math.pow(++b, c)in d
+     7  7 │   a+Math.pow( ++b, c )in d
+  
+
+```
+
+```
+invalidAdjacentTokens.js:6:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    4 │ Math.pow(a, b)in c
+    5 │ Math.pow(a, (b))in (c)
+  > 6 │ a+Math.pow(++b, c)in d
+      │   ^^^^^^^^^^^^^^^^
+    7 │ a+Math.pow( ++b, c )in d
+    8 │ 
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     4  4 │   Math.pow(a, b)in c
+     5  5 │   Math.pow(a, (b))in (c)
+     6    │ - a+Math.pow(++b,·c)in·d
+        6 │ + a+(++b**c)in·d
+     7  7 │   a+Math.pow( ++b, c )in d
+     8  8 │   
+  
+
+```
+
+```
+invalidAdjacentTokens.js:7:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    5 │ Math.pow(a, (b))in (c)
+    6 │ a+Math.pow(++b, c)in d
+  > 7 │ a+Math.pow( ++b, c )in d
+      │   ^^^^^^^^^^^^^^^^^^
+    8 │ 
+    9 │ // tokens that cannot be adjacent, but there is already space or something else between
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     5  5 │   Math.pow(a, (b))in (c)
+     6  6 │   a+Math.pow(++b, c)in d
+     7    │ - a+Math.pow(·++b,·c·)in·d
+        7 │ + a+(++b**c·)in·d
+     8  8 │   
+     9  9 │   // tokens that cannot be adjacent, but there is already space or something else between
+  
+
+```
+
+```
+invalidAdjacentTokens.js:10:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+     9 │ // tokens that cannot be adjacent, but there is already space or something else between
+  > 10 │ a+ Math.pow(++b, c) in d
+       │    ^^^^^^^^^^^^^^^^
+    11 │ // a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+    12 │ a+(Math.pow(++b, c))in d
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     8  8 │   
+     9  9 │   // tokens that cannot be adjacent, but there is already space or something else between
+    10    │ - a+·Math.pow(++b,·c)·in·d
+       10 │ + a+·(++b**c)·in·d
+    11 11 │   // a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+    12 12 │   a+(Math.pow(++b, c))in d
+  
+
+```
+
+```
+invalidAdjacentTokens.js:12:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    10 │ a+ Math.pow(++b, c) in d
+    11 │ // a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+  > 12 │ a+(Math.pow(++b, c))in d
+       │    ^^^^^^^^^^^^^^^^
+    13 │ 
+    14 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    10 10 │   a+ Math.pow(++b, c) in d
+    11 11 │   // a+/**/Math.pow(++b, c)/**/in d // ignored because of comments
+    12    │ - a+(Math.pow(++b,·c))in·d
+       12 │ + a+(++b**c)in·d
+    13 13 │   
+    14 14 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+  
+
+```
+
+```
+invalidAdjacentTokens.js:15:2 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    14 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+  > 15 │ +Math.pow(++a, b)
        │  ^^^^^^^^^^^^^^^^
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-    14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    16 │ Math.pow(a, b + c)in d
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+    13 13 │   
+    14 14 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+    15    │ - +Math.pow(++a,·b)
+       15 │ + +(++a**b)
+    16 16 │   Math.pow(a, b + c)in d
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+  
+
+```
+
+```
+invalidAdjacentTokens.js:16:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    14 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+    15 │ +Math.pow(++a, b)
+  > 16 │ Math.pow(a, b + c)in d
+       │ ^^^^^^^^^^^^^^^^^^
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+    18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    10 10 │   
-    11 11 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-    12    │ - +Math.pow(++a,·b)
-       12 │ + +(++a**b)
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
+    14 14 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
+    15 15 │   +Math.pow(++a, b)
+    16    │ - Math.pow(a,·b·+·c)in·d
+       16 │ + (a**(b·+·c))in·d
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18 18 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:13:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:17:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-    12 │ +Math.pow(++a, b)
-  > 13 │ Math.pow(a, b) + Math.pow(c, d)
+    15 │ +Math.pow(++a, b)
+    16 │ Math.pow(a, b + c)in d
+  > 17 │ Math.pow(a, b) + Math.pow(c, d)
        │ ^^^^^^^^^^^^^^
-    14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15 │ Math.pow(a, b)**Math.pow(c, d)
+    18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19 │ Math.pow(a, b)**Math.pow(c, d)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    11 11 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-    12 12 │   +Math.pow(++a, b)
-    13    │ - Math.pow(a,·b)·+·Math.pow(c,·d)
-       13 │ + a**b·+·Math.pow(c,·d)
-    14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15 15 │   Math.pow(a, b)**Math.pow(c, d)
+    15 15 │   +Math.pow(++a, b)
+    16 16 │   Math.pow(a, b + c)in d
+    17    │ - Math.pow(a,·b)·+·Math.pow(c,·d)
+       17 │ + a**b·+·Math.pow(c,·d)
+    18 18 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19 19 │   Math.pow(a, b)**Math.pow(c, d)
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:13:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:17:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    11 │ // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-    12 │ +Math.pow(++a, b)
-  > 13 │ Math.pow(a, b) + Math.pow(c, d)
+    15 │ +Math.pow(++a, b)
+    16 │ Math.pow(a, b + c)in d
+  > 17 │ Math.pow(a, b) + Math.pow(c, d)
        │                  ^^^^^^^^^^^^^^
-    14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15 │ Math.pow(a, b)**Math.pow(c, d)
+    18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19 │ Math.pow(a, b)**Math.pow(c, d)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    11 11 │   // tokens that cannot be adjacent, but the autofix inserts parens required for precedence
-    12 12 │   +Math.pow(++a, b)
-    13    │ - Math.pow(a,·b)·+·Math.pow(c,·d)
-       13 │ + Math.pow(a,·b)·+·c**d
-    14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15 15 │   Math.pow(a, b)**Math.pow(c, d)
+    15 15 │   +Math.pow(++a, b)
+    16 16 │   Math.pow(a, b + c)in d
+    17    │ - Math.pow(a,·b)·+·Math.pow(c,·d)
+       17 │ + Math.pow(a,·b)·+·c**d
+    18 18 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19 19 │   Math.pow(a, b)**Math.pow(c, d)
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:14:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:18:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ +Math.pow(++a, b)
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-  > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    16 │ Math.pow(a, b + c)in d
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+  > 18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
        │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    15 │ Math.pow(a, b)**Math.pow(c, d)
-    16 │ 
+    19 │ Math.pow(a, b)**Math.pow(c, d)
+    20 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   +Math.pow(++a, b)
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
-       14 │ + Math.pow(a,·b)**Math.pow(c,·d)
-    15 15 │   Math.pow(a, b)**Math.pow(c, d)
-    16 16 │   
+    16 16 │   Math.pow(a, b + c)in d
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
+       18 │ + Math.pow(a,·b)**Math.pow(c,·d)
+    19 19 │   Math.pow(a, b)**Math.pow(c, d)
+    20 20 │   
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:14:10 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:18:10 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ +Math.pow(++a, b)
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-  > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    16 │ Math.pow(a, b + c)in d
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+  > 18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
        │          ^^^^^^^^^^^^^^
-    15 │ Math.pow(a, b)**Math.pow(c, d)
-    16 │ 
+    19 │ Math.pow(a, b)**Math.pow(c, d)
+    20 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   +Math.pow(++a, b)
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
-       14 │ + Math.pow(a**b,·Math.pow(c,·d))
-    15 15 │   Math.pow(a, b)**Math.pow(c, d)
-    16 16 │   
+    16 16 │   Math.pow(a, b + c)in d
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
+       18 │ + Math.pow(a**b,·Math.pow(c,·d))
+    19 19 │   Math.pow(a, b)**Math.pow(c, d)
+    20 20 │   
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:14:26 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:18:26 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ +Math.pow(++a, b)
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-  > 14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+    16 │ Math.pow(a, b + c)in d
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+  > 18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
        │                          ^^^^^^^^^^^^^^
-    15 │ Math.pow(a, b)**Math.pow(c, d)
-    16 │ 
+    19 │ Math.pow(a, b)**Math.pow(c, d)
+    20 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   +Math.pow(++a, b)
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
-       14 │ + Math.pow(Math.pow(a,·b),·c**d)
-    15 15 │   Math.pow(a, b)**Math.pow(c, d)
-    16 16 │   
+    16 16 │   Math.pow(a, b + c)in d
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18    │ - Math.pow(Math.pow(a,·b),·Math.pow(c,·d))
+       18 │ + Math.pow(Math.pow(a,·b),·c**d)
+    19 19 │   Math.pow(a, b)**Math.pow(c, d)
+    20 20 │   
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:15:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:19:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-    14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
-  > 15 │ Math.pow(a, b)**Math.pow(c, d)
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+    18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+  > 19 │ Math.pow(a, b)**Math.pow(c, d)
        │ ^^^^^^^^^^^^^^
-    16 │ 
+    20 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15    │ - Math.pow(a,·b)**Math.pow(c,·d)
-       15 │ + (a**b)**Math.pow(c,·d)
-    16 16 │   
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18 18 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19    │ - Math.pow(a,·b)**Math.pow(c,·d)
+       19 │ + (a**b)**Math.pow(c,·d)
+    20 20 │   
   
 
 ```
 
 ```
-invalidAdjacentTokens.js:15:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
+invalidAdjacentTokens.js:19:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    13 │ Math.pow(a, b) + Math.pow(c, d)
-    14 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
-  > 15 │ Math.pow(a, b)**Math.pow(c, d)
+    17 │ Math.pow(a, b) + Math.pow(c, d)
+    18 │ Math.pow(Math.pow(a, b), Math.pow(c, d))
+  > 19 │ Math.pow(a, b)**Math.pow(c, d)
        │                 ^^^^^^^^^^^^^^
-    16 │ 
+    20 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    13 13 │   Math.pow(a, b) + Math.pow(c, d)
-    14 14 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
-    15    │ - Math.pow(a,·b)**Math.pow(c,·d)
-       15 │ + Math.pow(a,·b)**c**d
-    16 16 │   
+    17 17 │   Math.pow(a, b) + Math.pow(c, d)
+    18 18 │   Math.pow(Math.pow(a, b), Math.pow(c, d))
+    19    │ - Math.pow(a,·b)**Math.pow(c,·d)
+       19 │ + Math.pow(a,·b)**c**d
+    20 20 │   
   
 
 ```
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
deleted file mode 100644
index c29128dbd1b..00000000000
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
+++ /dev/null
@@ -1,4 +0,0 @@
-class C extends Math.pow(a, b) {}
-(class extends Math.pow(a, b) {})
-(class extends (Math.pow(a, b)) {})
-class C extends (Math.pow(a, b)) {}
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
deleted file mode 100644
index e537b3455a5..00000000000
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
+++ /dev/null
@@ -1,104 +0,0 @@
----
-source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 73
-expression: invalidClass.js
----
-# Input
-```js
-class C extends Math.pow(a, b) {}
-(class extends Math.pow(a, b) {})
-(class extends (Math.pow(a, b)) {})
-class C extends (Math.pow(a, b)) {}
-
-```
-
-# Diagnostics
-```
-invalidClass.js:1:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-  ! Use the '**' operator instead of 'Math.pow'.
-  
-  > 1 │ class C extends Math.pow(a, b) {}
-      │                 ^^^^^^^^^^^^^^
-    2 │ (class extends Math.pow(a, b) {})
-    3 │ (class extends (Math.pow(a, b)) {})
-  
-  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
-  
-    1   │ - class·C·extends·Math.pow(a,·b)·{}
-      1 │ + class·C·extends·(a**b)·{}
-    2 2 │   (class extends Math.pow(a, b) {})
-    3 3 │   (class extends (Math.pow(a, b)) {})
-  
-
-```
-
-```
-invalidClass.js:2:16 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-  ! Use the '**' operator instead of 'Math.pow'.
-  
-    1 │ class C extends Math.pow(a, b) {}
-  > 2 │ (class extends Math.pow(a, b) {})
-      │                ^^^^^^^^^^^^^^
-    3 │ (class extends (Math.pow(a, b)) {})
-    4 │ class C extends (Math.pow(a, b)) {}
-  
-  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
-  
-    1 1 │   class C extends Math.pow(a, b) {}
-    2   │ - (class·extends·Math.pow(a,·b)·{})
-      2 │ + (class·extends·(a**b)·{})
-    3 3 │   (class extends (Math.pow(a, b)) {})
-    4 4 │   class C extends (Math.pow(a, b)) {}
-  
-
-```
-
-```
-invalidClass.js:3:17 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-  ! Use the '**' operator instead of 'Math.pow'.
-  
-    1 │ class C extends Math.pow(a, b) {}
-    2 │ (class extends Math.pow(a, b) {})
-  > 3 │ (class extends (Math.pow(a, b)) {})
-      │                 ^^^^^^^^^^^^^^
-    4 │ class C extends (Math.pow(a, b)) {}
-    5 │ 
-  
-  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
-  
-    1 1 │   class C extends Math.pow(a, b) {}
-    2 2 │   (class extends Math.pow(a, b) {})
-    3   │ - (class·extends·(Math.pow(a,·b))·{})
-      3 │ + (class·extends·(a**b)·{})
-    4 4 │   class C extends (Math.pow(a, b)) {}
-    5 5 │   
-  
-
-```
-
-```
-invalidClass.js:4:18 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-  ! Use the '**' operator instead of 'Math.pow'.
-  
-    2 │ (class extends Math.pow(a, b) {})
-    3 │ (class extends (Math.pow(a, b)) {})
-  > 4 │ class C extends (Math.pow(a, b)) {}
-      │                  ^^^^^^^^^^^^^^
-    5 │ 
-  
-  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
-  
-    2 2 │   (class extends Math.pow(a, b) {})
-    3 3 │   (class extends (Math.pow(a, b)) {})
-    4   │ - class·C·extends·(Math.pow(a,·b))·{}
-      4 │ + class·C·extends·(a**b)·{}
-    5 5 │   
-  
-
-```
-
-
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js
index 37e7748f9ed..6aa6b6f80fa 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js
@@ -6,6 +6,7 @@ void Math.pow(a, b);
 Math.pow(a, b) .toString();
 Math.pow(a, b) ();
 Math.pow(a, b) ``;
+(class extends Math.pow(a, b) {})
 
 // parents with a higher precedence, but the expression's role doesn't require parens
 f(Math.pow(a, b))
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
index 4369d8cd28c..d2909c6a7f3 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithHigherPrecedence.js.snap
@@ -1,6 +1,6 @@
 ---
 source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 74
+assertion_line: 73
 expression: invalidParentsWithHigherPrecedence.js
 ---
 # Input
@@ -13,6 +13,7 @@ void Math.pow(a, b);
 Math.pow(a, b) .toString();
 Math.pow(a, b) ();
 Math.pow(a, b) ``;
+(class extends Math.pow(a, b) {})
 
 // parents with a higher precedence, but the expression's role doesn't require parens
 f(Math.pow(a, b))
@@ -177,7 +178,7 @@ invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiationOperator
   > 7 │ Math.pow(a, b) ();
       │ ^^^^^^^^^^^^^^
     8 │ Math.pow(a, b) ``;
-    9 │ 
+    9 │ (class extends Math.pow(a, b) {})
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
@@ -186,7 +187,7 @@ invalidParentsWithHigherPrecedence.js:7:1 lint/nursery/useExponentiationOperator
      7    │ - Math.pow(a,·b)·();
         7 │ + (a**b)·();
      8  8 │   Math.pow(a, b) ``;
-     9  9 │   
+     9  9 │   (class extends Math.pow(a, b) {})
   
 
 ```
@@ -200,8 +201,8 @@ invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiationOperator
      7 │ Math.pow(a, b) ();
    > 8 │ Math.pow(a, b) ``;
        │ ^^^^^^^^^^^^^^
-     9 │ 
-    10 │ // parents with a higher precedence, but the expression's role doesn't require parens
+     9 │ (class extends Math.pow(a, b) {})
+    10 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
@@ -209,245 +210,269 @@ invalidParentsWithHigherPrecedence.js:8:1 lint/nursery/useExponentiationOperator
      7  7 │   Math.pow(a, b) ();
      8    │ - Math.pow(a,·b)·``;
         8 │ + (a**b)·``;
-     9  9 │   
-    10 10 │   // parents with a higher precedence, but the expression's role doesn't require parens
+     9  9 │   (class extends Math.pow(a, b) {})
+    10 10 │   
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:11:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:9:16 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    10 │ // parents with a higher precedence, but the expression's role doesn't require parens
-  > 11 │ f(Math.pow(a, b))
+     7 │ Math.pow(a, b) ();
+     8 │ Math.pow(a, b) ``;
+   > 9 │ (class extends Math.pow(a, b) {})
+       │                ^^^^^^^^^^^^^^
+    10 │ 
+    11 │ // parents with a higher precedence, but the expression's role doesn't require parens
+  
+  i Suggested fix: Use the '**' operator instead of 'Math.pow'.
+  
+     7  7 │   Math.pow(a, b) ();
+     8  8 │   Math.pow(a, b) ``;
+     9    │ - (class·extends·Math.pow(a,·b)·{})
+        9 │ + (class·extends·(a**b)·{})
+    10 10 │   
+    11 11 │   // parents with a higher precedence, but the expression's role doesn't require parens
+  
+
+```
+
+```
+invalidParentsWithHigherPrecedence.js:12:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+
+  ! Use the '**' operator instead of 'Math.pow'.
+  
+    11 │ // parents with a higher precedence, but the expression's role doesn't require parens
+  > 12 │ f(Math.pow(a, b))
        │   ^^^^^^^^^^^^^^
-    12 │ f(foo, Math.pow(a, b))
-    13 │ f(Math.pow(a, b), foo)
+    13 │ f(foo, Math.pow(a, b))
+    14 │ f(Math.pow(a, b), foo)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     9  9 │   
-    10 10 │   // parents with a higher precedence, but the expression's role doesn't require parens
-    11    │ - f(Math.pow(a,·b))
-       11 │ + f(a**b)
-    12 12 │   f(foo, Math.pow(a, b))
-    13 13 │   f(Math.pow(a, b), foo)
+    10 10 │   
+    11 11 │   // parents with a higher precedence, but the expression's role doesn't require parens
+    12    │ - f(Math.pow(a,·b))
+       12 │ + f(a**b)
+    13 13 │   f(foo, Math.pow(a, b))
+    14 14 │   f(Math.pow(a, b), foo)
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:12:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:13:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    10 │ // parents with a higher precedence, but the expression's role doesn't require parens
-    11 │ f(Math.pow(a, b))
-  > 12 │ f(foo, Math.pow(a, b))
+    11 │ // parents with a higher precedence, but the expression's role doesn't require parens
+    12 │ f(Math.pow(a, b))
+  > 13 │ f(foo, Math.pow(a, b))
        │        ^^^^^^^^^^^^^^
-    13 │ f(Math.pow(a, b), foo)
-    14 │ f(foo, Math.pow(a, b), bar)
+    14 │ f(Math.pow(a, b), foo)
+    15 │ f(foo, Math.pow(a, b), bar)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    10 10 │   // parents with a higher precedence, but the expression's role doesn't require parens
-    11 11 │   f(Math.pow(a, b))
-    12    │ - f(foo,·Math.pow(a,·b))
-       12 │ + f(foo,·a**b)
-    13 13 │   f(Math.pow(a, b), foo)
-    14 14 │   f(foo, Math.pow(a, b), bar)
+    11 11 │   // parents with a higher precedence, but the expression's role doesn't require parens
+    12 12 │   f(Math.pow(a, b))
+    13    │ - f(foo,·Math.pow(a,·b))
+       13 │ + f(foo,·a**b)
+    14 14 │   f(Math.pow(a, b), foo)
+    15 15 │   f(foo, Math.pow(a, b), bar)
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:13:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:14:3 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    11 │ f(Math.pow(a, b))
-    12 │ f(foo, Math.pow(a, b))
-  > 13 │ f(Math.pow(a, b), foo)
+    12 │ f(Math.pow(a, b))
+    13 │ f(foo, Math.pow(a, b))
+  > 14 │ f(Math.pow(a, b), foo)
        │   ^^^^^^^^^^^^^^
-    14 │ f(foo, Math.pow(a, b), bar)
-    15 │ new F(Math.pow(a, b))
+    15 │ f(foo, Math.pow(a, b), bar)
+    16 │ new F(Math.pow(a, b))
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    11 11 │   f(Math.pow(a, b))
-    12 12 │   f(foo, Math.pow(a, b))
-    13    │ - f(Math.pow(a,·b),·foo)
-       13 │ + f(a**b,·foo)
-    14 14 │   f(foo, Math.pow(a, b), bar)
-    15 15 │   new F(Math.pow(a, b))
+    12 12 │   f(Math.pow(a, b))
+    13 13 │   f(foo, Math.pow(a, b))
+    14    │ - f(Math.pow(a,·b),·foo)
+       14 │ + f(a**b,·foo)
+    15 15 │   f(foo, Math.pow(a, b), bar)
+    16 16 │   new F(Math.pow(a, b))
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:14:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:15:8 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ f(foo, Math.pow(a, b))
-    13 │ f(Math.pow(a, b), foo)
-  > 14 │ f(foo, Math.pow(a, b), bar)
+    13 │ f(foo, Math.pow(a, b))
+    14 │ f(Math.pow(a, b), foo)
+  > 15 │ f(foo, Math.pow(a, b), bar)
        │        ^^^^^^^^^^^^^^
-    15 │ new F(Math.pow(a, b))
-    16 │ new F(foo, Math.pow(a, b))
+    16 │ new F(Math.pow(a, b))
+    17 │ new F(foo, Math.pow(a, b))
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   f(foo, Math.pow(a, b))
-    13 13 │   f(Math.pow(a, b), foo)
-    14    │ - f(foo,·Math.pow(a,·b),·bar)
-       14 │ + f(foo,·a**b,·bar)
-    15 15 │   new F(Math.pow(a, b))
-    16 16 │   new F(foo, Math.pow(a, b))
+    13 13 │   f(foo, Math.pow(a, b))
+    14 14 │   f(Math.pow(a, b), foo)
+    15    │ - f(foo,·Math.pow(a,·b),·bar)
+       15 │ + f(foo,·a**b,·bar)
+    16 16 │   new F(Math.pow(a, b))
+    17 17 │   new F(foo, Math.pow(a, b))
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:15:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:16:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    13 │ f(Math.pow(a, b), foo)
-    14 │ f(foo, Math.pow(a, b), bar)
-  > 15 │ new F(Math.pow(a, b))
+    14 │ f(Math.pow(a, b), foo)
+    15 │ f(foo, Math.pow(a, b), bar)
+  > 16 │ new F(Math.pow(a, b))
        │       ^^^^^^^^^^^^^^
-    16 │ new F(foo, Math.pow(a, b))
-    17 │ new F(Math.pow(a, b), foo)
+    17 │ new F(foo, Math.pow(a, b))
+    18 │ new F(Math.pow(a, b), foo)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    13 13 │   f(Math.pow(a, b), foo)
-    14 14 │   f(foo, Math.pow(a, b), bar)
-    15    │ - new·F(Math.pow(a,·b))
-       15 │ + new·F(a**b)
-    16 16 │   new F(foo, Math.pow(a, b))
-    17 17 │   new F(Math.pow(a, b), foo)
+    14 14 │   f(Math.pow(a, b), foo)
+    15 15 │   f(foo, Math.pow(a, b), bar)
+    16    │ - new·F(Math.pow(a,·b))
+       16 │ + new·F(a**b)
+    17 17 │   new F(foo, Math.pow(a, b))
+    18 18 │   new F(Math.pow(a, b), foo)
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:16:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:17:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    14 │ f(foo, Math.pow(a, b), bar)
-    15 │ new F(Math.pow(a, b))
-  > 16 │ new F(foo, Math.pow(a, b))
+    15 │ f(foo, Math.pow(a, b), bar)
+    16 │ new F(Math.pow(a, b))
+  > 17 │ new F(foo, Math.pow(a, b))
        │            ^^^^^^^^^^^^^^
-    17 │ new F(Math.pow(a, b), foo)
-    18 │ new F(foo, Math.pow(a, b), bar)
+    18 │ new F(Math.pow(a, b), foo)
+    19 │ new F(foo, Math.pow(a, b), bar)
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    14 14 │   f(foo, Math.pow(a, b), bar)
-    15 15 │   new F(Math.pow(a, b))
-    16    │ - new·F(foo,·Math.pow(a,·b))
-       16 │ + new·F(foo,·a**b)
-    17 17 │   new F(Math.pow(a, b), foo)
-    18 18 │   new F(foo, Math.pow(a, b), bar)
+    15 15 │   f(foo, Math.pow(a, b), bar)
+    16 16 │   new F(Math.pow(a, b))
+    17    │ - new·F(foo,·Math.pow(a,·b))
+       17 │ + new·F(foo,·a**b)
+    18 18 │   new F(Math.pow(a, b), foo)
+    19 19 │   new F(foo, Math.pow(a, b), bar)
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:17:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:18:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    15 │ new F(Math.pow(a, b))
-    16 │ new F(foo, Math.pow(a, b))
-  > 17 │ new F(Math.pow(a, b), foo)
+    16 │ new F(Math.pow(a, b))
+    17 │ new F(foo, Math.pow(a, b))
+  > 18 │ new F(Math.pow(a, b), foo)
        │       ^^^^^^^^^^^^^^
-    18 │ new F(foo, Math.pow(a, b), bar)
-    19 │ obj[Math.pow(a, b)]
+    19 │ new F(foo, Math.pow(a, b), bar)
+    20 │ obj[Math.pow(a, b)]
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    15 15 │   new F(Math.pow(a, b))
-    16 16 │   new F(foo, Math.pow(a, b))
-    17    │ - new·F(Math.pow(a,·b),·foo)
-       17 │ + new·F(a**b,·foo)
-    18 18 │   new F(foo, Math.pow(a, b), bar)
-    19 19 │   obj[Math.pow(a, b)]
+    16 16 │   new F(Math.pow(a, b))
+    17 17 │   new F(foo, Math.pow(a, b))
+    18    │ - new·F(Math.pow(a,·b),·foo)
+       18 │ + new·F(a**b,·foo)
+    19 19 │   new F(foo, Math.pow(a, b), bar)
+    20 20 │   obj[Math.pow(a, b)]
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:18:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:19:12 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    16 │ new F(foo, Math.pow(a, b))
-    17 │ new F(Math.pow(a, b), foo)
-  > 18 │ new F(foo, Math.pow(a, b), bar)
+    17 │ new F(foo, Math.pow(a, b))
+    18 │ new F(Math.pow(a, b), foo)
+  > 19 │ new F(foo, Math.pow(a, b), bar)
        │            ^^^^^^^^^^^^^^
-    19 │ obj[Math.pow(a, b)]
-    20 │ [foo, Math.pow(a, b), bar]
+    20 │ obj[Math.pow(a, b)]
+    21 │ [foo, Math.pow(a, b), bar]
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    16 16 │   new F(foo, Math.pow(a, b))
-    17 17 │   new F(Math.pow(a, b), foo)
-    18    │ - new·F(foo,·Math.pow(a,·b),·bar)
-       18 │ + new·F(foo,·a**b,·bar)
-    19 19 │   obj[Math.pow(a, b)]
-    20 20 │   [foo, Math.pow(a, b), bar]
+    17 17 │   new F(foo, Math.pow(a, b))
+    18 18 │   new F(Math.pow(a, b), foo)
+    19    │ - new·F(foo,·Math.pow(a,·b),·bar)
+       19 │ + new·F(foo,·a**b,·bar)
+    20 20 │   obj[Math.pow(a, b)]
+    21 21 │   [foo, Math.pow(a, b), bar]
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:19:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:20:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    17 │ new F(Math.pow(a, b), foo)
-    18 │ new F(foo, Math.pow(a, b), bar)
-  > 19 │ obj[Math.pow(a, b)]
+    18 │ new F(Math.pow(a, b), foo)
+    19 │ new F(foo, Math.pow(a, b), bar)
+  > 20 │ obj[Math.pow(a, b)]
        │     ^^^^^^^^^^^^^^
-    20 │ [foo, Math.pow(a, b), bar]
-    21 │ 
+    21 │ [foo, Math.pow(a, b), bar]
+    22 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    17 17 │   new F(Math.pow(a, b), foo)
-    18 18 │   new F(foo, Math.pow(a, b), bar)
-    19    │ - obj[Math.pow(a,·b)]
-       19 │ + obj[a**b]
-    20 20 │   [foo, Math.pow(a, b), bar]
-    21 21 │   
+    18 18 │   new F(Math.pow(a, b), foo)
+    19 19 │   new F(foo, Math.pow(a, b), bar)
+    20    │ - obj[Math.pow(a,·b)]
+       20 │ + obj[a**b]
+    21 21 │   [foo, Math.pow(a, b), bar]
+    22 22 │   
   
 
 ```
 
 ```
-invalidParentsWithHigherPrecedence.js:20:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithHigherPrecedence.js:21:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    18 │ new F(foo, Math.pow(a, b), bar)
-    19 │ obj[Math.pow(a, b)]
-  > 20 │ [foo, Math.pow(a, b), bar]
+    19 │ new F(foo, Math.pow(a, b), bar)
+    20 │ obj[Math.pow(a, b)]
+  > 21 │ [foo, Math.pow(a, b), bar]
        │       ^^^^^^^^^^^^^^
-    21 │ 
+    22 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    18 18 │   new F(foo, Math.pow(a, b), bar)
-    19 19 │   obj[Math.pow(a, b)]
-    20    │ - [foo,·Math.pow(a,·b),·bar]
-       20 │ + [foo,·a**b,·bar]
-    21 21 │   
+    19 19 │   new F(foo, Math.pow(a, b), bar)
+    20 20 │   obj[Math.pow(a, b)]
+    21    │ - [foo,·Math.pow(a,·b),·bar]
+       21 │ + [foo,·a**b,·bar]
+    22 22 │   
   
 
 ```
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js
index 2733719fee6..6a2a5567555 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js
@@ -1,24 +1,13 @@
 // parents with a lower precedence
 a * Math.pow(b, c);
-
 Math.pow(a, b) * c;
-
 a + Math.pow(b, c);
-
 Math.pow(a, b)/c;
-
 a < Math.pow(b, c);
-
 Math.pow(a, b) > c;
-
 a === Math.pow(b, c);
-
 a ? Math.pow(b, c) : d;
-
 a = Math.pow(b, c);
-
 a += Math.pow(b, c);
-
 function *f() { yield Math.pow(a, b) }
-
 a, Math.pow(b, c), d
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
index 8d8ad59a9d4..806af270d67 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidParentsWithLowerPrecedence.js.snap
@@ -1,33 +1,22 @@
 ---
 source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 74
+assertion_line: 73
 expression: invalidParentsWithLowerPrecedence.js
 ---
 # Input
 ```js
 // parents with a lower precedence
 a * Math.pow(b, c);
-
 Math.pow(a, b) * c;
-
 a + Math.pow(b, c);
-
 Math.pow(a, b)/c;
-
 a < Math.pow(b, c);
-
 Math.pow(a, b) > c;
-
 a === Math.pow(b, c);
-
 a ? Math.pow(b, c) : d;
-
 a = Math.pow(b, c);
-
 a += Math.pow(b, c);
-
 function *f() { yield Math.pow(a, b) }
-
 a, Math.pow(b, c), d
 
 ```
@@ -41,278 +30,278 @@ invalidParentsWithLowerPrecedence.js:2:5 lint/nursery/useExponentiationOperator
     1 │ // parents with a lower precedence
   > 2 │ a * Math.pow(b, c);
       │     ^^^^^^^^^^^^^^
-    3 │ 
-    4 │ Math.pow(a, b) * c;
+    3 │ Math.pow(a, b) * c;
+    4 │ a + Math.pow(b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
      1  1 │   // parents with a lower precedence
      2    │ - a·*·Math.pow(b,·c);
         2 │ + a·*·b**c;
-     3  3 │   
-     4  4 │   Math.pow(a, b) * c;
+     3  3 │   Math.pow(a, b) * c;
+     4  4 │   a + Math.pow(b, c);
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:4:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:3:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
+    1 │ // parents with a lower precedence
     2 │ a * Math.pow(b, c);
-    3 │ 
-  > 4 │ Math.pow(a, b) * c;
+  > 3 │ Math.pow(a, b) * c;
       │ ^^^^^^^^^^^^^^
-    5 │ 
-    6 │ a + Math.pow(b, c);
+    4 │ a + Math.pow(b, c);
+    5 │ Math.pow(a, b)/c;
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
+     1  1 │   // parents with a lower precedence
      2  2 │   a * Math.pow(b, c);
-     3  3 │   
-     4    │ - Math.pow(a,·b)·*·c;
-        4 │ + a**b·*·c;
-     5  5 │   
-     6  6 │   a + Math.pow(b, c);
+     3    │ - Math.pow(a,·b)·*·c;
+        3 │ + a**b·*·c;
+     4  4 │   a + Math.pow(b, c);
+     5  5 │   Math.pow(a, b)/c;
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:4:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    4 │ Math.pow(a, b) * c;
-    5 │ 
-  > 6 │ a + Math.pow(b, c);
+    2 │ a * Math.pow(b, c);
+    3 │ Math.pow(a, b) * c;
+  > 4 │ a + Math.pow(b, c);
       │     ^^^^^^^^^^^^^^
-    7 │ 
-    8 │ Math.pow(a, b)/c;
+    5 │ Math.pow(a, b)/c;
+    6 │ a < Math.pow(b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     4  4 │   Math.pow(a, b) * c;
-     5  5 │   
-     6    │ - a·+·Math.pow(b,·c);
-        6 │ + a·+·b**c;
-     7  7 │   
-     8  8 │   Math.pow(a, b)/c;
+     2  2 │   a * Math.pow(b, c);
+     3  3 │   Math.pow(a, b) * c;
+     4    │ - a·+·Math.pow(b,·c);
+        4 │ + a·+·b**c;
+     5  5 │   Math.pow(a, b)/c;
+     6  6 │   a < Math.pow(b, c);
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:8:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:5:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-     6 │ a + Math.pow(b, c);
-     7 │ 
-   > 8 │ Math.pow(a, b)/c;
-       │ ^^^^^^^^^^^^^^
-     9 │ 
-    10 │ a < Math.pow(b, c);
+    3 │ Math.pow(a, b) * c;
+    4 │ a + Math.pow(b, c);
+  > 5 │ Math.pow(a, b)/c;
+      │ ^^^^^^^^^^^^^^
+    6 │ a < Math.pow(b, c);
+    7 │ Math.pow(a, b) > c;
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     6  6 │   a + Math.pow(b, c);
-     7  7 │   
-     8    │ - Math.pow(a,·b)/c;
-        8 │ + a**b/c;
-     9  9 │   
-    10 10 │   a < Math.pow(b, c);
+     3  3 │   Math.pow(a, b) * c;
+     4  4 │   a + Math.pow(b, c);
+     5    │ - Math.pow(a,·b)/c;
+        5 │ + a**b/c;
+     6  6 │   a < Math.pow(b, c);
+     7  7 │   Math.pow(a, b) > c;
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:6:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-     8 │ Math.pow(a, b)/c;
-     9 │ 
-  > 10 │ a < Math.pow(b, c);
-       │     ^^^^^^^^^^^^^^
-    11 │ 
-    12 │ Math.pow(a, b) > c;
+    4 │ a + Math.pow(b, c);
+    5 │ Math.pow(a, b)/c;
+  > 6 │ a < Math.pow(b, c);
+      │     ^^^^^^^^^^^^^^
+    7 │ Math.pow(a, b) > c;
+    8 │ a === Math.pow(b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-     8  8 │   Math.pow(a, b)/c;
-     9  9 │   
-    10    │ - a·<·Math.pow(b,·c);
-       10 │ + a·<·b**c;
-    11 11 │   
-    12 12 │   Math.pow(a, b) > c;
+     4  4 │   a + Math.pow(b, c);
+     5  5 │   Math.pow(a, b)/c;
+     6    │ - a·<·Math.pow(b,·c);
+        6 │ + a·<·b**c;
+     7  7 │   Math.pow(a, b) > c;
+     8  8 │   a === Math.pow(b, c);
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:12:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:7:1 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    10 │ a < Math.pow(b, c);
-    11 │ 
-  > 12 │ Math.pow(a, b) > c;
-       │ ^^^^^^^^^^^^^^
-    13 │ 
-    14 │ a === Math.pow(b, c);
+    5 │ Math.pow(a, b)/c;
+    6 │ a < Math.pow(b, c);
+  > 7 │ Math.pow(a, b) > c;
+      │ ^^^^^^^^^^^^^^
+    8 │ a === Math.pow(b, c);
+    9 │ a ? Math.pow(b, c) : d;
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    10 10 │   a < Math.pow(b, c);
-    11 11 │   
-    12    │ - Math.pow(a,·b)·>·c;
-       12 │ + a**b·>·c;
-    13 13 │   
-    14 14 │   a === Math.pow(b, c);
+     5  5 │   Math.pow(a, b)/c;
+     6  6 │   a < Math.pow(b, c);
+     7    │ - Math.pow(a,·b)·>·c;
+        7 │ + a**b·>·c;
+     8  8 │   a === Math.pow(b, c);
+     9  9 │   a ? Math.pow(b, c) : d;
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:14:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:8:7 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    12 │ Math.pow(a, b) > c;
-    13 │ 
-  > 14 │ a === Math.pow(b, c);
+     6 │ a < Math.pow(b, c);
+     7 │ Math.pow(a, b) > c;
+   > 8 │ a === Math.pow(b, c);
        │       ^^^^^^^^^^^^^^
-    15 │ 
-    16 │ a ? Math.pow(b, c) : d;
+     9 │ a ? Math.pow(b, c) : d;
+    10 │ a = Math.pow(b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    12 12 │   Math.pow(a, b) > c;
-    13 13 │   
-    14    │ - a·===·Math.pow(b,·c);
-       14 │ + a·===·b**c;
-    15 15 │   
-    16 16 │   a ? Math.pow(b, c) : d;
+     6  6 │   a < Math.pow(b, c);
+     7  7 │   Math.pow(a, b) > c;
+     8    │ - a·===·Math.pow(b,·c);
+        8 │ + a·===·b**c;
+     9  9 │   a ? Math.pow(b, c) : d;
+    10 10 │   a = Math.pow(b, c);
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:16:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:9:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    14 │ a === Math.pow(b, c);
-    15 │ 
-  > 16 │ a ? Math.pow(b, c) : d;
+     7 │ Math.pow(a, b) > c;
+     8 │ a === Math.pow(b, c);
+   > 9 │ a ? Math.pow(b, c) : d;
        │     ^^^^^^^^^^^^^^
-    17 │ 
-    18 │ a = Math.pow(b, c);
+    10 │ a = Math.pow(b, c);
+    11 │ a += Math.pow(b, c);
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    14 14 │   a === Math.pow(b, c);
-    15 15 │   
-    16    │ - a·?·Math.pow(b,·c)·:·d;
-       16 │ + a·?·b**c·:·d;
-    17 17 │   
-    18 18 │   a = Math.pow(b, c);
+     7  7 │   Math.pow(a, b) > c;
+     8  8 │   a === Math.pow(b, c);
+     9    │ - a·?·Math.pow(b,·c)·:·d;
+        9 │ + a·?·b**c·:·d;
+    10 10 │   a = Math.pow(b, c);
+    11 11 │   a += Math.pow(b, c);
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:18:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:10:5 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    16 │ a ? Math.pow(b, c) : d;
-    17 │ 
-  > 18 │ a = Math.pow(b, c);
+     8 │ a === Math.pow(b, c);
+     9 │ a ? Math.pow(b, c) : d;
+  > 10 │ a = Math.pow(b, c);
        │     ^^^^^^^^^^^^^^
-    19 │ 
-    20 │ a += Math.pow(b, c);
+    11 │ a += Math.pow(b, c);
+    12 │ function *f() { yield Math.pow(a, b) }
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    16 16 │   a ? Math.pow(b, c) : d;
-    17 17 │   
-    18    │ - a·=·Math.pow(b,·c);
-       18 │ + a·=·b**c;
-    19 19 │   
-    20 20 │   a += Math.pow(b, c);
+     8  8 │   a === Math.pow(b, c);
+     9  9 │   a ? Math.pow(b, c) : d;
+    10    │ - a·=·Math.pow(b,·c);
+       10 │ + a·=·b**c;
+    11 11 │   a += Math.pow(b, c);
+    12 12 │   function *f() { yield Math.pow(a, b) }
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:20:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:11:6 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    18 │ a = Math.pow(b, c);
-    19 │ 
-  > 20 │ a += Math.pow(b, c);
+     9 │ a ? Math.pow(b, c) : d;
+    10 │ a = Math.pow(b, c);
+  > 11 │ a += Math.pow(b, c);
        │      ^^^^^^^^^^^^^^
-    21 │ 
-    22 │ function *f() { yield Math.pow(a, b) }
+    12 │ function *f() { yield Math.pow(a, b) }
+    13 │ a, Math.pow(b, c), d
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    18 18 │   a = Math.pow(b, c);
-    19 19 │   
-    20    │ - a·+=·Math.pow(b,·c);
-       20 │ + a·+=·b**c;
-    21 21 │   
-    22 22 │   function *f() { yield Math.pow(a, b) }
+     9  9 │   a ? Math.pow(b, c) : d;
+    10 10 │   a = Math.pow(b, c);
+    11    │ - a·+=·Math.pow(b,·c);
+       11 │ + a·+=·b**c;
+    12 12 │   function *f() { yield Math.pow(a, b) }
+    13 13 │   a, Math.pow(b, c), d
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:22:23 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:12:23 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    20 │ a += Math.pow(b, c);
-    21 │ 
-  > 22 │ function *f() { yield Math.pow(a, b) }
+    10 │ a = Math.pow(b, c);
+    11 │ a += Math.pow(b, c);
+  > 12 │ function *f() { yield Math.pow(a, b) }
        │                       ^^^^^^^^^^^^^^
-    23 │ 
-    24 │ a, Math.pow(b, c), d
+    13 │ a, Math.pow(b, c), d
+    14 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    20 20 │   a += Math.pow(b, c);
-    21 21 │   
-    22    │ - function·*f()·{·yield·Math.pow(a,·b)·}
-       22 │ + function·*f()·{·yield·a**b·}
-    23 23 │   
-    24 24 │   a, Math.pow(b, c), d
+    10 10 │   a = Math.pow(b, c);
+    11 11 │   a += Math.pow(b, c);
+    12    │ - function·*f()·{·yield·Math.pow(a,·b)·}
+       12 │ + function·*f()·{·yield·a**b·}
+    13 13 │   a, Math.pow(b, c), d
+    14 14 │   
   
 
 ```
 
 ```
-invalidParentsWithLowerPrecedence.js:24:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
+invalidParentsWithLowerPrecedence.js:13:4 lint/nursery/useExponentiationOperator  FIXABLE  ━━━━━━━━━━
 
   ! Use the '**' operator instead of 'Math.pow'.
   
-    22 │ function *f() { yield Math.pow(a, b) }
-    23 │ 
-  > 24 │ a, Math.pow(b, c), d
+    11 │ a += Math.pow(b, c);
+    12 │ function *f() { yield Math.pow(a, b) }
+  > 13 │ a, Math.pow(b, c), d
        │    ^^^^^^^^^^^^^^
-    25 │ 
+    14 │ 
   
   i Suggested fix: Use the '**' operator instead of 'Math.pow'.
   
-    22 22 │   function *f() { yield Math.pow(a, b) }
-    23 23 │   
-    24    │ - a,·Math.pow(b,·c),·d
-       24 │ + a,·b**c,·d
-    25 25 │   
+    11 11 │   a += Math.pow(b, c);
+    12 12 │   function *f() { yield Math.pow(a, b) }
+    13    │ - a,·Math.pow(b,·c),·d
+       13 │ + a,·b**c,·d
+    14 14 │   
   
 
 ```
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js
index 0bd3251be7d..682ff4dbb62 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js
@@ -1,28 +1,16 @@
-
+// not Math.pow()
 Object.pow(a, b)
-
 Math.max(a, b)
-
 Math
-
 Math(a, b)
-
 pow
-
 pow(a, b)
-
 Math.pow
-
 Math.Pow(a, b)
-
 math.pow(a, b)
-
 foo.Math.pow(a, b)
-
 new Math.pow(a, b)
-
 Math[pow](a, b)
-
 globalThis.Object.pow(a, b)
-
 globalThis.Math.max(a, b)
+class C { #pow; foo() { Math.#pow(a, b); } }
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap
index 075ae9595fd..954fc4feaf2 100644
--- a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/valid.js.snap
@@ -1,38 +1,26 @@
 ---
 source: crates/rome_js_analyze/tests/spec_tests.rs
-assertion_line: 74
+assertion_line: 73
 expression: valid.js
 ---
 # Input
 ```js
-
+// not Math.pow()
 Object.pow(a, b)
-
 Math.max(a, b)
-
 Math
-
 Math(a, b)
-
 pow
-
 pow(a, b)
-
 Math.pow
-
 Math.Pow(a, b)
-
 math.pow(a, b)
-
 foo.Math.pow(a, b)
-
 new Math.pow(a, b)
-
 Math[pow](a, b)
-
 globalThis.Object.pow(a, b)
-
 globalThis.Math.max(a, b)
+class C { #pow; foo() { Math.#pow(a, b); } }
 
 ```
 

From 3dad256385ebc538ab297c6be0b13415c3eb9815 Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Thu, 1 Dec 2022 21:01:03 +0000
Subject: [PATCH 09/11] chore: check Math is not a local reference

---
 .../nursery/use_exponentiation_operator.rs    | 32 +++++++++++------
 .../validLocalMath.js                         | 25 +++++++++++++
 .../validLocalMath.js.snap                    | 36 +++++++++++++++++++
 3 files changed, 83 insertions(+), 10 deletions(-)
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js
 create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js.snap

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 718f7652c1d..9a49c37b9e4 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -1,6 +1,7 @@
+use crate::semantic_services::Semantic;
 use crate::JsRuleAction;
 use rome_analyze::context::RuleContext;
-use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
+use rome_analyze::{declare_rule, ActionCategory, Rule, RuleDiagnostic};
 use rome_console::markup;
 use rome_diagnostics::Applicability;
 use rome_js_factory::{make, syntax::T};
@@ -97,22 +98,22 @@ impl MathPowCall {
 }
 
 impl Rule for UseExponentiationOperator {
-    type Query = Ast;
+    type Query = Semantic;
     type State = ();
     type Signals = Option;
     type Options = ();
 
     fn run(ctx: &RuleContext) -> Self::Signals {
         let node = ctx.query();
+        let model = ctx.model();
 
         let has_math_pow = match node.callee().ok()?.omit_parentheses() {
             AnyJsExpression::JsStaticMemberExpression(static_member_expr) => {
-                let has_math = static_member_expr
+                let reference = static_member_expr
                     .object()
                     .ok()?
                     .omit_parentheses()
-                    .as_reference_identifier()?
-                    .has_name("Math");
+                    .as_reference_identifier()?;
                 let has_pow = static_member_expr
                     .member()
                     .ok()?
@@ -122,21 +123,32 @@ impl Rule for UseExponentiationOperator {
                     .token_text_trimmed()
                     == "pow";
 
-                has_math && has_pow
+                if reference.has_name("Math") {
+                    // verifies that the Math reference is not a local variable
+                    let declaration = model.binding(&reference);
+                    declaration.is_none() && has_pow
+                } else {
+                    false
+                }
             }
             AnyJsExpression::JsComputedMemberExpression(computed_member_expr) => {
-                let has_math = computed_member_expr
+                let reference = computed_member_expr
                     .object()
                     .ok()?
                     .omit_parentheses()
-                    .as_reference_identifier()?
-                    .has_name("Math");
+                    .as_reference_identifier()?;
                 let has_pow = computed_member_expr
                     .member()
                     .ok()?
                     .is_string_constant("pow");
 
-                has_math && has_pow
+                if reference.has_name("Math") {
+                    // verifies that the Math reference is not a local variable
+                    let declaration = model.binding(&reference);
+                    declaration.is_none() && has_pow
+                } else {
+                    false
+                }
             }
             _ => false,
         };
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js
new file mode 100644
index 00000000000..88aaac7022c
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js
@@ -0,0 +1,25 @@
+// not the global Math
+function case1() {
+	let Math;
+	Math.pow(a, b);
+}
+
+function case2(Math) {
+	Math.pow(a, b);
+}
+
+var case3 = function Math() {
+	Math.pow(a, b);
+}
+
+function case4() {
+	Math.pow(a, b);
+	var Math;
+}
+
+function case5() {
+	if (foo) {
+		const Math = 1;
+		Math.pow(a, b);
+	}
+}
diff --git a/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js.snap
new file mode 100644
index 00000000000..165d3561297
--- /dev/null
+++ b/crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/validLocalMath.js.snap
@@ -0,0 +1,36 @@
+---
+source: crates/rome_js_analyze/tests/spec_tests.rs
+assertion_line: 83
+expression: validLocalMath.js
+---
+# Input
+```js
+// not the global Math
+function case1() {
+	let Math;
+	Math.pow(a, b);
+}
+
+function case2(Math) {
+	Math.pow(a, b);
+}
+
+var case3 = function Math() {
+	Math.pow(a, b);
+}
+
+function case4() {
+	Math.pow(a, b);
+	var Math;
+}
+
+function case5() {
+	if (foo) {
+		const Math = 1;
+		Math.pow(a, b);
+	}
+}
+
+```
+
+

From 0005ec7d5146f9d6a4d1fcd60440efda3b86d618 Mon Sep 17 00:00:00 2001
From: kaioduarte 
Date: Fri, 2 Dec 2022 09:40:06 +0000
Subject: [PATCH 10/11] chore: address PR comments

---
 .../nursery/use_exponentiation_operator.rs    | 64 +++++++------------
 1 file changed, 23 insertions(+), 41 deletions(-)

diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
index 9a49c37b9e4..ab5c3162363 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery/use_exponentiation_operator.rs
@@ -64,7 +64,7 @@ pub struct MathPowCall {
 }
 
 impl MathPowCall {
-    fn get_base(&self) -> Option {
+    fn make_base(&self) -> Option {
         Some(if self.does_base_need_parens()? {
             parenthesize_any_js_expression(&self.base)
         } else {
@@ -72,7 +72,7 @@ impl MathPowCall {
         })
     }
 
-    fn get_exponent(&self) -> Option {
+    fn make_exponent(&self) -> Option {
         Some(if self.does_exponent_need_parens()? {
             parenthesize_any_js_expression(&self.exponent)
         } else {
@@ -107,57 +107,41 @@ impl Rule for UseExponentiationOperator {
         let node = ctx.query();
         let model = ctx.model();
 
-        let has_math_pow = match node.callee().ok()?.omit_parentheses() {
+        let object = match node.callee().ok()?.omit_parentheses() {
             AnyJsExpression::JsStaticMemberExpression(static_member_expr) => {
-                let reference = static_member_expr
-                    .object()
-                    .ok()?
-                    .omit_parentheses()
-                    .as_reference_identifier()?;
-                let has_pow = static_member_expr
+                if static_member_expr
                     .member()
                     .ok()?
                     .as_js_name()?
                     .value_token()
                     .ok()?
                     .token_text_trimmed()
-                    == "pow";
-
-                if reference.has_name("Math") {
-                    // verifies that the Math reference is not a local variable
-                    let declaration = model.binding(&reference);
-                    declaration.is_none() && has_pow
-                } else {
-                    false
+                    != "pow"
+                {
+                    return None;
                 }
+
+                static_member_expr.object()
             }
             AnyJsExpression::JsComputedMemberExpression(computed_member_expr) => {
-                let reference = computed_member_expr
-                    .object()
-                    .ok()?
-                    .omit_parentheses()
-                    .as_reference_identifier()?;
-                let has_pow = computed_member_expr
+                if !computed_member_expr
                     .member()
                     .ok()?
-                    .is_string_constant("pow");
-
-                if reference.has_name("Math") {
-                    // verifies that the Math reference is not a local variable
-                    let declaration = model.binding(&reference);
-                    declaration.is_none() && has_pow
-                } else {
-                    false
+                    .is_string_constant("pow")
+                {
+                    return None;
                 }
+
+                computed_member_expr.object()
             }
-            _ => false,
+            _ => return None,
         };
 
-        if has_math_pow {
-            return Some(());
-        }
+        let reference = object.ok()?.omit_parentheses().as_reference_identifier()?;
 
-        None
+        // verifies that the Math reference is not a local variable
+        let has_math_pow = reference.has_name("Math") && model.binding(&reference).is_none();
+        has_math_pow.then_some(())
     }
 
     fn diagnostic(ctx: &RuleContext, _: &Self::State) -> Option {
@@ -186,9 +170,9 @@ impl Rule for UseExponentiationOperator {
         };
 
         let new_node = make::js_binary_expression(
-            math_pow_call.get_base()?,
+            math_pow_call.make_base()?,
             make::token(T![**]),
-            math_pow_call.get_exponent()?,
+            math_pow_call.make_exponent()?,
         );
 
         if let Some((needs_parens, parent)) = does_exponentiation_expression_need_parens(node) {
@@ -253,9 +237,7 @@ fn does_exponentiation_expression_need_parens(
         if does_expression_need_parens(node, &parent)? {
             return Some((true, Some(parent)));
         }
-    }
-
-    if let Some(extends_clause) = node.parent::() {
+    } else if let Some(extends_clause) = node.parent::() {
         if extends_clause.parent::().is_some() {
             return Some((true, None));
         }

From 264e539693468559deae22431b3d024d0319cea7 Mon Sep 17 00:00:00 2001
From: Micha Reiser 
Date: Mon, 5 Dec 2022 11:17:31 +0100
Subject: [PATCH 11/11] Update codegen files

---
 crates/rome_js_analyze/src/analyzers/nursery.rs       | 3 ++-
 crates/rome_service/src/configuration/linter/rules.rs | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs
index 45abdc87ed7..e438714d3f3 100644
--- a/crates/rome_js_analyze/src/analyzers/nursery.rs
+++ b/crates/rome_js_analyze/src/analyzers/nursery.rs
@@ -22,7 +22,8 @@ mod no_unsafe_finally;
 mod no_void_type_return;
 mod use_default_switch_clause_last;
 mod use_enum_initializers;
+mod use_exponentiation_operator;
 mod use_flat_map;
 mod use_numeric_literals;
 mod use_valid_for_direction;
-declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } }
+declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_banned_types :: NoBannedTypes , self :: no_conditional_assignment :: NoConditionalAssignment , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_dupe_keys :: NoDupeKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_explicit_any :: NoExplicitAny , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_void_type_return :: NoVoidTypeReturn , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_flat_map :: UseFlatMap , self :: use_numeric_literals :: UseNumericLiterals , self :: use_valid_for_direction :: UseValidForDirection ,] } }
diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs
index 0f4b1adae8b..70b83d3dabe 100644
--- a/crates/rome_service/src/configuration/linter/rules.rs
+++ b/crates/rome_service/src/configuration/linter/rules.rs
@@ -796,7 +796,7 @@ struct NurserySchema {
 }
 impl Nursery {
     const CATEGORY_NAME: &'static str = "nursery";
-    pub(crate) const CATEGORY_RULES: [&'static str; 31] = [
+    pub(crate) const CATEGORY_RULES: [&'static str; 32] = [
         "noAccessKey",
         "noBannedTypes",
         "noConditionalAssignment",
@@ -882,9 +882,9 @@ impl Nursery {
         RuleFilter::Rule("nursery", Self::CATEGORY_RULES[25]),
         RuleFilter::Rule("nursery", Self::CATEGORY_RULES[26]),
         RuleFilter::Rule("nursery", Self::CATEGORY_RULES[27]),
-        RuleFilter::Rule("nursery", Self::CATEGORY_RULES[28]),
         RuleFilter::Rule("nursery", Self::CATEGORY_RULES[29]),
         RuleFilter::Rule("nursery", Self::CATEGORY_RULES[30]),
+        RuleFilter::Rule("nursery", Self::CATEGORY_RULES[31]),
     ];
     pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) }
     pub(crate) fn get_enabled_rules(&self) -> IndexSet {