-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(eslint-plugin): add global modifier to naming-convention #2691
feat(eslint-plugin): add global modifier to naming-convention #2691
Conversation
Thanks for the PR, @jharwig! 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 Report
@@ Coverage Diff @@
## master #2691 +/- ##
==========================================
+ Coverage 92.79% 92.81% +0.02%
==========================================
Files 294 294
Lines 9682 9686 +4
Branches 2717 2718 +1
==========================================
+ Hits 8984 8990 +6
+ Misses 330 329 -1
+ Partials 368 367 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
code itself LGTM - just two comments on the tests - thanks for your work!
const localConstant = 2; | ||
} | ||
`, | ||
parserOptions, |
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.
nit - you don't need to use the parserOptions
here, and instead should do:
parserOptions, | |
parserOptions: { | |
sourceType: 'script', | |
}, |
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.
Additionally, please duplicate this test case and additionally use sourceType: 'module'
to ensure both scripts and modules work as expected.
Closing in favour of #2802 |
Fixes #2318
Added a new
global
modifier to thenaming-convention
rule. This is only valid for variable selectors with theconst
modifier. It allows for configuring top-level/global constants differently than constants defined inside nested function scopes.Something to look at is the naming of
global
. The issue describestopLevel
as another possible name. Another is whether this global modifier should be valid for function selectors (it is not in this PR.)The implementation was based on the description of this comment in the issue