-
-
Notifications
You must be signed in to change notification settings - Fork 406
Add prefer-class-fields
rule
#2512
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
#2512
Conversation
What should we do if the assignment is unreachable? class Foo {
constructor(x) {
if (x) {return}
this.foo = 'foo';
}
} |
It's dynamically set, so it cannot be statically defined. It should not be reported by this rule. |
Hey @fregante! Or maybe we can just agree that once the work in this PR is done you'll maybe just run your linter on it once? |
06d643a
to
3a9c5f8
Compare
Handled stopping of the static analysis on unsupported case: 3376845 |
d907827
to
77f4954
Compare
Okay, I fixed all test/linting errors connected with my rule - should I fix other as well? They seems to be connected with some default options missing in already existing rules? |
275195a
to
77f4954
Compare
Hey! I've merged last changes from main to the branch of this PR - now it's ready to be reviewed again |
Change the test file extension from |
@sindresorhus done: 8358a43 I'm not sure yet why the tests are failing - locally they're working just fine. |
c7632d9
to
8358a43
Compare
fa07ec0
to
ca160be
Compare
Okay, got it working and all of the requested changes are applied. BTW it's weird, but for me the |
43b7828
to
cbdaae6
Compare
Fixed the fix logic for some edge cases, especially class Foo {
constructor() {
this.bar = 1;
}
static} |
Adds
prefer-class-fields
rule which turns:into:
Fixes #314
IssueHunt Summary
Referenced issues
This pull request has been submitted to:
prefer-class-fields