feat(eslint-plugin): [no-shadow] ignoreOnInitialization option#4603
feat(eslint-plugin): [no-shadow] ignoreOnInitialization option#4603bradzacher merged 7 commits intotypescript-eslint:mainfrom
Conversation
|
Thanks for the PR, @Josh-Cena! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
Not sure if any code should be updated to cope with this option. Seems our scope analyzer is already able to allow this: type test = (test: string) => typeof test;Even when |
Codecov Report
@@ Coverage Diff @@
## main #4603 +/- ##
==========================================
+ Coverage 92.06% 94.28% +2.22%
==========================================
Files 355 151 -204
Lines 12097 8208 -3889
Branches 3455 2670 -785
==========================================
- Hits 11137 7739 -3398
+ Misses 630 261 -369
+ Partials 330 208 -122
Flags with carried forward coverage won't be shown. Click here to find out more.
|
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Super, thanks!
@Josh-Cena do you think you have time to add unit tests for this? If not no worries, since it's just a pipe-through of the base rule's config.
|
Hmmm... No! This rule does not pipe to the base rule but is a re-implementation. We do need to backport the upstream changes and add a test. My bad for not noticing it beforehand |
|
Any reason why this rule does not delegate to the base rule? Should I refactor that in this PR? I mean... eslint/eslint#14963 has about 100 lines to add this feature, not sure if we want to duplicate all of that |
At the end of the AST the base rule iterates over every single scope and variable using the scope analysis APIs and then individually reports on variables that match its internal logic. We unfortunately can't pick-and-choose which variables the base rule might report on unless we hackily override the scope analysis APIs - which means we can't delegate! Thus we have to maintain a complete fork, sadly. If you can figure out a clean way to refactor this to reuse the logic - feel free! I don't think that it's possible to do though. |
|
Ugh, I see. That's unfortunate. I'll incorporate upstream changes later today. |
|
The unit tests seem to indicate that our extension rule is reporting more errors than the base rule on the same case. Is that because of test setup, or because of our scope manager having different logics? |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@lopezjurip - please don't comment on issues and prs asking for progress. This guideline is explicitly mentioned in our contributing guide |
|
Still quite clueless. If I copied the test cases from upstream, but our rule testers report 3 errors while the original test case only expects one, how could I get the data about the extra errors? How do people usually debug this? I tried logging the variable name before |
you can use the vscode debugger to debug the tests - we have it configured so you just need to open the file and select the lint rule debugger. also you can set |
|
I finally got time to look at this. I had to hack into eslint's rule tester so I can let it log the actual line/column of the report. Turns out that the tests on their repo would turn all source code into one line, so the line/column numbers are different from ours. |
bradzacher
left a comment
There was a problem hiding this comment.
LGTM - thanks so much for adding this!
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.17.0` -> `5.18.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.17.0/5.18.0) | | [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.17.0` -> `5.18.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.17.0/5.18.0) | --- ### Release Notes <details> <summary>typescript-eslint/typescript-eslint (@​typescript-eslint/eslint-plugin)</summary> ### [`v5.18.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#​5180-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5170v5180-2022-04-04) [Compare Source](typescript-eslint/typescript-eslint@v5.17.0...v5.18.0) ##### Bug Fixes - **eslint-plugin:** method-signature-style respect getter signature ([#​4777](typescript-eslint/typescript-eslint#4777)) ([12dd670](typescript-eslint/typescript-eslint@12dd670)) ##### Features - **eslint-plugin:** \[no-shadow] ignoreOnInitialization option ([#​4603](typescript-eslint/typescript-eslint#4603)) ([068ea9b](typescript-eslint/typescript-eslint@068ea9b)) - **eslint-plugin:** \[no-this-alias] report on assignment expressions ([#​4718](typescript-eslint/typescript-eslint#4718)) ([8329498](typescript-eslint/typescript-eslint@8329498)) </details> <details> <summary>typescript-eslint/typescript-eslint (@​typescript-eslint/parser)</summary> ### [`v5.18.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#​5180-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5170v5180-2022-04-04) [Compare Source](typescript-eslint/typescript-eslint@v5.17.0...v5.18.0) **Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser) </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1282 Reviewed-by: 6543 <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
PR Checklist
ignoreOnInitializationoption to match the ESLint rule #4601Overview
Added an option to line up with base rule