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.
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
Add
prefer-class-fields
rule #2512base: main
Are you sure you want to change the base?
Add
prefer-class-fields
rule #2512Changes from all commits
468a9c2
8c28503
8bc2304
452dcf7
5d88a08
acb5680
9cb0fc9
11a3621
6758bae
40bfb3c
62c82d6
097f673
3b4d399
73d47e2
60983c3
14e4676
425f00f
ea96a91
a849f2b
a9c9f4b
b4f5349
3a520cb
ca160be
1ef1a3f
f9ede71
d27356b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 80 in rules/prefer-class-fields.js
Check warning on line 80 in rules/prefer-class-fields.js
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.
Please help me understand this, are you assuming assignments before non-
ExpressionStatement
s are reachable? And it's addressing #2512 (comment) ?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.
Yes, exactly - that's the assumption. I'm not an expert on node types in this ESTree AST, but my thinking was: it's better to whitelist (allow only
ExpressionStatement
s) than to try writing down all node types that might make rest of the code unreachable. Just to be on the safe sideThere 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.
Let's not remove code, especially there can be side effects. We can use suggestions or simply just report error, if property already exists.
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.
My thinking was: property in the constructor always takes priority over class field declaration, so there are no side-effects. IMO it's a safe assumption.
WDYT?
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.