-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: support TS syntax in no-loop-func
#19559
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
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
tests/lib/rules/no-loop-func.js
Outdated
`, | ||
], | ||
invalid: [ | ||
// Invalid TS code |
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.
@snitin315 did you mean to push a commit with tests here?
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.
Yeah added in 6337f87
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.
Also, I just noticed that in error message, we repeat the same variable name in few cases - Function declared in a loop contains unsafe references to variable(s) 'i', 'i'.
Is this expected, or should we print i
just once?
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.
Ha, nice catch. I don't know if it's expected but my personal intuition is that it's a bug.
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.
lib/rules/no-loop-func.js
Outdated
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.
Are there really no changes needed in the code? Asking because @typescript-eslint/no-loop-func
isn't marked as deprecated, and the implementation additionally checks isTypeReference
attribute.
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.
Hmm, there might be some missing test cases in typescrip-eslint. Let me check on this.
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 removed this check and still all tests passed in typescript-eslint
codebase, @JoshuaKGoldberg This might be dead code. Also I have tests all test cases from the typescript-eslint repo all are passing with this rule's current implementation in js.
Added few more test cases in d1c3bd5
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.
Indeed, it does look like nothing is necessary. I filed typescript-eslint/typescript-eslint#11015 to double-check on the typescript-eslint side.
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.
Looks like the problem for which the extension rule was added (typescript-eslint/typescript-eslint#2448 - false positives on unresolved type references) has been fixed by 42faa17 in the core rule.
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.
LGTM, thanks! Leaving open for @JoshuaKGoldberg to verify.
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.
Nice, glad this really didn't need any source logic changes! 👏
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Refs #19173
It adds support for TypeScript types in
no-loop-func
.Is there anything you'd like reviewers to focus on?