Skip to content
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

Fix: Update semi for class-fields (refs #14857) #14945

Merged
merged 5 commits into from Sep 5, 2021
Merged

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Aug 18, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Fixed the semi false positives described in:

- https://github.com/eslint/eslint/pull/14591#issuecomment-866328829
- https://github.com/eslint/eslint/pull/14591#issuecomment-874716539
- https://github.com/eslint/eslint/pull/14591#issuecomment-876244868

Is there anything you'd like reviewers to focus on?

Did I miss anything?

@nzakas nzakas added bug ESLint is working incorrectly accepted There is consensus among the team that this change meets the criteria for inclusion labels Aug 18, 2021
@nzakas nzakas changed the title Fix: Update semi for class-fields (refs #14591) Fix: Update semi for class-fields (refs #14857) Aug 18, 2021
@nzakas nzakas added the rule Relates to ESLint's core rules label Aug 18, 2021
lib/rules/semi.js Outdated Show resolved Hide resolved
lib/rules/semi.js Show resolved Hide resolved
lib/rules/semi.js Outdated Show resolved Hide resolved
@mdjermanovic
Copy link
Member

In the case that we want "beforeStatementContinuationChars" to apply to class fields, there is a bug on line 234 - it should be node.value instead of t.value.

/* eslint semi: ["error", "never", { beforeStatementContinuationChars: "never" }] */

class A {
  x = y; // false positive
  [foo]
}

@nzakas
Copy link
Member Author

nzakas commented Aug 25, 2021

Okay, I think I've got the outstanding cases covered.

lib/rules/semi.js Outdated Show resolved Hide resolved
lib/rules/semi.js Outdated Show resolved Hide resolved
@mdjermanovic
Copy link
Member

We can now remove this:

eslint/lib/rules/semi.js

Lines 257 to 259 in d0d46a8

if (t === "PropertyDefinition") {
return Boolean(t.value);
}

This function is now never used with PropertyDefinition nodes, and this code is wrong (it should have been node.value), so it might be best to just delete these lines to avoid confusion.

@nzakas
Copy link
Member Author

nzakas commented Aug 31, 2021

Okay, I think I got everything. Thanks for the eagle-eyed reviews.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@mdjermanovic mdjermanovic merged commit f966fe6 into master Sep 5, 2021
@mdjermanovic mdjermanovic deleted the class-fields-semi branch September 5, 2021 20:09
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 5, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants