-
Notifications
You must be signed in to change notification settings - Fork 234
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(require-typed-module-mocks): add rule to use strict module mock factory types #1314
feat(require-typed-module-mocks): add rule to use strict module mock factory types #1314
Conversation
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.
Thanks, I'll do a proper review when I'm back at my laptop, but giving it a quick look over I've already got two main comments:
- You don't need type checking becuase you're not using the TypeScript service
- I feel like ideally we should have "factory" in the rule name, and maybe "generic" too, since this rule is pretty specific to those things - what do you think about
no-untyped-mock-factory
orrequire-generic-type-with-mock-factory
?
Also you need to use |
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 a good start, but need to address my comments so far + ensure CI is passing; let me know if you need any help :)
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 good - have a few tweaks I'd like to see, but they should be pretty straightforward.
Thank you for pointing me at some useful utilities! Updated the PR to address comments. |
Added an extra test to check for spots where the rule shouldn't match, in order to reach full code coverage. |
} from './utils'; | ||
|
||
const findModuleName = ( | ||
node: TSESTree.Literal | TSESTree.Node, |
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: iirc TSESTree.Literal
is a subset of TSESTree.Node
, so you shouldn't need it 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.
Looks good, just need to re-generate the docs :)
# [27.2.0](v27.1.7...v27.2.0) (2022-12-31) ### Features * create `require-typed-module-mocks` rule ([#1314](#1314)) ([ee43c3f](ee43c3f))
🎉 This PR is included in version 27.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thank you, @NotWoods, for this PR. To clarify for anybody looking for this rule, it was ultimately named no-untyped-mock-factory. |
Closes #1313
While the rule itself doesn't need type-checking, the auto-fix does. It it possible to disable the auto-fix based on the parser & source file? If not, the rule could be switched to use editor suggestions.