Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: add class fields (refs eslint/eslint#14343) (#486)
* Update: add ES2022 class features support (refs eslint/eslint#14343) * update README.md * update tools and add docs for adding new syntax * add dist * upgrade eslint-visitor-keys * Revert "add dist" This reverts commit 3e9caa7. * add npm prepare script * Update CONTRIBUTING.md Co-authored-by: 薛定谔的猫 <weiran.zsd@outlook.com> * update CONTRIBUTING.md * fix for JSON incompatible values * Apply suggestions from code review Co-authored-by: 薛定谔的猫 <weiran.zsd@outlook.com> Co-authored-by: Nicholas C. Zakas <nicholas@nczconsulting.com>
- Loading branch information
1 parent
b068cea
commit e71162c
Showing
121 changed files
with
21,028 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/node_modules | ||
/tests/fixtures | ||
/tools | ||
/tools/* | ||
!/tools/update-ecma-version-tests.js | ||
/dist |
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
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
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
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 |
---|---|---|
|
@@ -16,7 +16,8 @@ const SUPPORTED_VERSIONS = [ | |
9, | ||
10, | ||
11, | ||
12 | ||
12, | ||
13 | ||
]; | ||
|
||
/** | ||
|
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
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
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.result.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,6 @@ | ||
export default { | ||
"index": 28, | ||
"lineNumber": 3, | ||
"column": 11, | ||
"message": "Private fields can not be deleted" | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/fixtures/ecma-version/13/class-fields/invalid-delete-private-optional.src.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 { | ||
#a; | ||
f() { delete this?.#a } | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.result.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,6 @@ | ||
export default { | ||
"index": 28, | ||
"lineNumber": 3, | ||
"column": 11, | ||
"message": "Private fields can not be deleted" | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/fixtures/ecma-version/13/class-fields/invalid-delete-private.src.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 { | ||
#a; | ||
f() { delete this.#a } | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.result.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,6 @@ | ||
export default { | ||
"index": 43, | ||
"lineNumber": 3, | ||
"column": 15, | ||
"message": "Cannot use 'arguments' in class field initializer" | ||
}; |
5 changes: 5 additions & 0 deletions
5
tests/fixtures/ecma-version/13/class-fields/invalid-init-arguments.src.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,5 @@ | ||
function f() { | ||
class C { | ||
aaa = arguments | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.result.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,6 @@ | ||
export default { | ||
"index": 49, | ||
"lineNumber": 3, | ||
"column": 21, | ||
"message": "Cannot use 'arguments' in class field initializer" | ||
}; |
5 changes: 5 additions & 0 deletions
5
tests/fixtures/ecma-version/13/class-fields/invalid-init-arrow-arguments.src.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,5 @@ | ||
function f() { | ||
class C { | ||
aaa = () => arguments | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.result.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,6 @@ | ||
export default { | ||
"index": 333, | ||
"lineNumber": 7, | ||
"column": 15, | ||
"message": "The keyword 'yield' is reserved" | ||
}; |
9 changes: 9 additions & 0 deletions
9
tests/fixtures/ecma-version/13/class-fields/invalid-init-yield.src.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,9 @@ | ||
function* f() { | ||
class C { | ||
// `yield` is an identifier reference in field initializers even if it's in a generator function. | ||
// But `yield` as identifier references is disallowed in strict mode. | ||
// And the inside of classes is always strict mode. | ||
// Therefore this is a syntax error. | ||
aaa = yield | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.result.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,6 @@ | ||
export default { | ||
"index": 41, | ||
"lineNumber": 4, | ||
"column": 14, | ||
"message": "Private field '#b' must be declared in an enclosing class" | ||
}; |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-member-private-undef.src.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,6 @@ | ||
class C { | ||
#a; | ||
f() { | ||
this.#b | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.result.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,6 @@ | ||
export default { | ||
"index": 49, | ||
"lineNumber": 3, | ||
"column": 17, | ||
"message": "Unexpected token #foo" | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/fixtures/ecma-version/13/class-fields/invalid-member-super-private.src.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 Base { | ||
#foo; | ||
f() { super.#foo } | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.result.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,6 @@ | ||
export default { | ||
"index": 14, | ||
"lineNumber": 2, | ||
"column": 5, | ||
"message": "Classes can't have an element named '#constructor'" | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/ecma-version/13/class-fields/invalid-private-constructor.src.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,3 @@ | ||
class C { | ||
#constructor = () => {} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.result.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,6 @@ | ||
export default { | ||
"index": 22, | ||
"lineNumber": 3, | ||
"column": 5, | ||
"message": "Identifier '#a' has already been declared" | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/fixtures/ecma-version/13/class-fields/invalid-private-dupelicate.src.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 { | ||
#a; | ||
#a; | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.result.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,6 @@ | ||
export default { | ||
"index": 14, | ||
"lineNumber": 2, | ||
"column": 5, | ||
"message": "Classes can't have a field named 'constructor'" | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/ecma-version/13/class-fields/invalid-public-constructor.src.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,3 @@ | ||
class C { | ||
constructor = () => {} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures/ecma-version/13/class-fields/mixed-init-await.module-result.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,6 @@ | ||
export default { | ||
"index": 304, | ||
"lineNumber": 6, | ||
"column": 15, | ||
"message": "Cannot use keyword 'await' outside an async function" | ||
}; |
Oops, something went wrong.