feat: support TypeScript syntax in no-empty-function rule#19551
feat: support TypeScript syntax in no-empty-function rule#19551snitin315 merged 6 commits intoeslint:mainfrom
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
snitin315
left a comment
There was a problem hiding this comment.
LGTM.
I'll leave it open for others to review.
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Looks really close to me, just a couple touchups. 🙌
mdjermanovic
left a comment
There was a problem hiding this comment.
The behavior of new options would be different than the options of the @typescript-eslint/no-empty-function rule.
For example, this code is currently valid for both core no-empty-function and @typescript-eslint/no-empty-function rules:
/* eslint @typescript-eslint/no-empty-function: ["error", { "allow": ["constructors", "methods"] }] */
/* eslint no-empty-function: ["error", { "allow": ["constructors", "methods"] }] */
class A {
private constructor() { }
}
class B {
protected constructor() { }
}
class C {
@decorator
foo() { }
}
class D extends C {
override foo() { }
}But after this change, all 4 functions would be invalid because they're no longer considered to be of constructors/methods kind, which I'm not sure is desirable and might be considered a breaking change.
|
@mdjermanovic That was definitely an oversight. I've fixed it and added tests. |
mdjermanovic
left a comment
There was a problem hiding this comment.
LGTM, thanks! Leaving open for @snitin315 and @JoshuaKGoldberg to re-review.
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
The source code looks very good and reasonable to me, nice! Requesting information from the team on what the stance on the >2k newly generated tests are, not blocking.
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
If everybody else is happy, then I'm happy too
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] 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)
Added support for handling TypeScript specific code that would otherwise trigger the rule.
One example of valid TypeScript specific code that would otherwise trigger the no-empty-function rule is the use of parameter properties in constructor functions.
This PR also adds four new options to the allow list:
"privateConstructors""protectedConstructors""decoratedFunctions""overrideMethods"Is there anything you'd like reviewers to focus on?
Refs #19173.