-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-unused-vars] SelfReferenced should see varsIgnorePattern #2679
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
Conversation
…norePattern Signed-off-by: Moulik Aggarwal <qwertymoulik@gmail.com>
Thanks for the PR, @aggmoulik! 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 #2679 +/- ##
==========================================
- Coverage 92.82% 92.79% -0.03%
==========================================
Files 294 294
Lines 9670 9674 +4
Branches 2712 2715 +3
==========================================
+ Hits 8976 8977 +1
- Misses 328 329 +1
- Partials 366 368 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
}); | ||
if ( | ||
varsIgnorePattern && | ||
varsIgnorePattern.toString() !== variable.name |
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.
varsIgnorePattern
is a regexp (or perhaps still a regexp string).
See usage in eslint:
if (config.varsIgnorePattern && config.varsIgnorePattern.test(def.name.name)) {
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.
And this error should be reported also when no varsIgnorePattern
is given.
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.
Do we need a similar change in line 148?
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.
Initially, I was confused on the same thing.
But, I found this as my reference to go for this method:
var varIgnorePattern: "all" | "local" | {
vars?: "all" | "local" | undefined;
varIgnorePattern:?: string | undefined;
args: "all" | "after-used" | "none" | undefined;
.........
caughtErrorsIgnorePattern?: string | undefined;
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.
Doing the regex, I am having an error
varIgnorePattern.test(variable.name)
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.
Hy @HolgerJeromin, Can you guide me ?
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.
No, sorry. I never hacked around around eslint.
I can try to help after my vacation in one week
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.
So here you'll need to convert the string to a regexp:
const varIgnorePattern =
typeof options === 'object' && options.varIgnorePattern != null
? new RegExp(options.varsIgnorePattern, "u")
: null;
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.
I have worked with the regex but how can I improve codecov ? @bradzacher
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.
you'll need some tests! right now you have none at all.
Signed-off-by: Moulik Aggarwal <qwertymoulik@gmail.com>
Signed-off-by: Moulik Aggarwal <qwertymoulik@gmail.com>
Closing in favour of #2768 |
Fix: #2648
Signed-off-by: Moulik Aggarwal qwertymoulik@gmail.com