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(eslint-plugin): [brace-style] handle enum declarations #1281

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #1274

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @a-tarasyuk!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Nov 28, 2019

Codecov Report

Merging #1281 into master will increase coverage by 0.13%.
The diff coverage is 95.12%.

@@            Coverage Diff             @@
##           master    #1281      +/-   ##
==========================================
+ Coverage   93.93%   94.06%   +0.13%     
==========================================
  Files         131      131              
  Lines        5804     5781      -23     
  Branches     1639     1630       -9     
==========================================
- Hits         5452     5438      -14     
+ Misses        188      184       -4     
+ Partials      164      159       -5
Impacted Files Coverage Δ
packages/eslint-plugin/src/util/astUtils.ts 100% <100%> (+7.14%) ⬆️
packages/eslint-plugin/src/rules/brace-style.ts 95.23% <94.87%> (-4.77%) ⬇️
...slint-plugin/src/rules/no-unnecessary-condition.ts 100% <0%> (ø) ⬆️
...s/eslint-plugin/src/rules/no-unused-expressions.ts 100% <0%> (ø) ⬆️
...lint-plugin/src/rules/prefer-nullish-coalescing.ts 93.61% <0%> (ø) ⬆️
packages/eslint-plugin/src/util/misc.ts 88% <0%> (+1.79%) ⬆️
...ackages/eslint-plugin/src/rules/member-ordering.ts 97.33% <0%> (+5.02%) ⬆️
...s/eslint-plugin/src/rules/no-non-null-assertion.ts 100% <0%> (+15.62%) ⬆️

@bradzacher bradzacher added the bug Something isn't working label Nov 28, 2019
@bradzacher
Copy link
Member

How come you chose to reimplement the rule logic instead of using the old monkey patch?

@a-tarasyuk
Copy link
Contributor Author

a-tarasyuk commented Dec 4, 2019

@bradzacher monkey patching is good., validateCurlyPair is not a public method, it is located inside .create. TSEnumDeclaration doesn't have Block and we cannot use public hooks like BlockStatement, (sourceCode.getLastToken(node) returns wrong token for TSEnumDeclaration }). So, we need to get the correct last token (}) for TSEnumDeclaration and then check curly pairs.

If this PR doesn't make sense I'm OK to close it.

@bradzacher
Copy link
Member

bradzacher commented Dec 4, 2019

No, it's all good - I didn't realise that the enum ast node didn't have a body, sorry.
I'm not quite sure why we don't have a body for enums (I've raised #1305 - it seems like an oversight when the enum node was created, but that won't help you right now).

Your approach is correct, given the lack of a body.

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for this

@bradzacher bradzacher merged commit 3ddf1a2 into typescript-eslint:master Dec 4, 2019
@nolazybits
Copy link

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[brace-style] doesn't check enum
3 participants