This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support class expressions and declaration
- Loading branch information
1 parent
6d1eec1
commit fd8f47c
Showing
5 changed files
with
264 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) {} |
104 changes: 104 additions & 0 deletions
104
crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 │ | ||
``` | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @ts-nocheck | ||
class C<T> extends Math.pow(a, b) implements Foo<T> {} | ||
(class A extends Math.pow(a, b) implements Foo {}) | ||
(class A<T> extends (Math.pow(a, b)) {}) | ||
class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} |
109 changes: 109 additions & 0 deletions
109
crates/rome_js_analyze/tests/specs/nursery/useExponentiationOperator/invalidClass.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T> extends Math.pow(a, b) implements Foo<T> {} | ||
(class A extends Math.pow(a, b) implements Foo {}) | ||
(class A<T> extends (Math.pow(a, b)) {}) | ||
class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalidClass.ts:2:20 lint/nursery/useExponentiationOperator FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Use the '**' operator instead of 'Math.pow'. | ||
1 │ // @ts-nocheck | ||
> 2 │ class C<T> extends Math.pow(a, b) implements Foo<T> {} | ||
│ ^^^^^^^^^^^^^^ | ||
3 │ (class A extends Math.pow(a, b) implements Foo {}) | ||
4 │ (class A<T> extends (Math.pow(a, b)) {}) | ||
i Suggested fix: Use the '**' operator instead of 'Math.pow'. | ||
1 1 │ // @ts-nocheck | ||
2 │ - class·C<T>·extends·Math.pow(a,·b)·implements·Foo<T>·{} | ||
2 │ + class·C<T>·extends·(a**b)·implements·Foo<T>·{} | ||
3 3 │ (class A extends Math.pow(a, b) implements Foo {}) | ||
4 4 │ (class A<T> 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<T> extends Math.pow(a, b) implements Foo<T> {} | ||
> 3 │ (class A extends Math.pow(a, b) implements Foo {}) | ||
│ ^^^^^^^^^^^^^^ | ||
4 │ (class A<T> extends (Math.pow(a, b)) {}) | ||
5 │ class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
i Suggested fix: Use the '**' operator instead of 'Math.pow'. | ||
1 1 │ // @ts-nocheck | ||
2 2 │ class C<T> extends Math.pow(a, b) implements Foo<T> {} | ||
3 │ - (class·A·extends·Math.pow(a,·b)·implements·Foo·{}) | ||
3 │ + (class·A·extends·(a**b)·implements·Foo·{}) | ||
4 4 │ (class A<T> extends (Math.pow(a, b)) {}) | ||
5 5 │ class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
``` | ||
|
||
``` | ||
invalidClass.ts:4:22 lint/nursery/useExponentiationOperator FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Use the '**' operator instead of 'Math.pow'. | ||
2 │ class C<T> extends Math.pow(a, b) implements Foo<T> {} | ||
3 │ (class A extends Math.pow(a, b) implements Foo {}) | ||
> 4 │ (class A<T> extends (Math.pow(a, b)) {}) | ||
│ ^^^^^^^^^^^^^^ | ||
5 │ class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
6 │ | ||
i Suggested fix: Use the '**' operator instead of 'Math.pow'. | ||
2 2 │ class C<T> extends Math.pow(a, b) implements Foo<T> {} | ||
3 3 │ (class A extends Math.pow(a, b) implements Foo {}) | ||
4 │ - (class·A<T>·extends·(Math.pow(a,·b))·{}) | ||
4 │ + (class·A<T>·extends·(a**b)·{}) | ||
5 5 │ class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
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<T> extends (Math.pow(a, b)) {}) | ||
> 5 │ class C<T> extends (Math.pow(a, b)) implements Foo, Bar<T> {} | ||
│ ^^^^^^^^^^^^^^ | ||
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<T> extends (Math.pow(a, b)) {}) | ||
5 │ - class·C<T>·extends·(Math.pow(a,·b))·implements·Foo,·Bar<T>·{} | ||
5 │ + class·C<T>·extends·(a**b)·implements·Foo,·Bar<T>·{} | ||
6 6 │ | ||
``` | ||
|
||
|