New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: add class fields (refs eslint/eslint#14343) #486
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0cd4d9
Update: add ES2022 class features support (refs eslint/eslint#14343)
mysticatea 81bdee7
update README.md
mysticatea d7673b3
update tools and add docs for adding new syntax
mysticatea 3e9caa7
add dist
mysticatea 2deee8a
upgrade eslint-visitor-keys
mysticatea aa07bbe
Revert "add dist"
mysticatea a272efc
add npm prepare script
mysticatea efc6258
Update CONTRIBUTING.md
mysticatea 0ec1580
update CONTRIBUTING.md
mysticatea 0c620cd
fix for JSON incompatible values
mysticatea 1c744b3
Merge remote-tracking branch 'origin/main' into class-fields
mysticatea c2f84d6
Apply suggestions from code review
aladdin-add 65a3fe4
Merge branch 'main' into class-fields
nzakas File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -17,7 +17,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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mysticatea doesn't
plugin:node/recommended
already handle this?