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 8b3819cc2cfc..456fa7714caf 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 e9ba6f26f703..c2b32cfe9de3 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 06f52066619b..aa3279d66ed1 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 709199a9faf3..d390782ed032 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 c29128dbd1b6..000000000000 --- 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 e537b3455a56..000000000000 --- 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 37e7748f9ed0..6aa6b6f80fa3 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 4369d8cd28c3..d2909c6a7f3a 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 2733719fee6f..6a2a55675558 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 8d8ad59a9d41..806af270d674 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 0bd3251be7d3..682ff4dbb621 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 075ae9595fd7..954fc4feaf24 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); } } ```