-
Notifications
You must be signed in to change notification settings - Fork 96
feat: add rule consistent-each-for #826
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: add rule consistent-each-for #826
Conversation
src/rules/consistent-each-for.ts
Outdated
| export type EachOrFor = 'each' | 'for' | ||
| export type BaseFnName = 'test' | 'it' | 'describe' | 'suite' |
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 you have any reason to why these are exported?
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're right - these are only used internally. I've removed the exports to match the pattern I see in consistent-test-it and other rules. Thanks for pointing that out!
tests/consistent-each-for.test.ts
Outdated
| { | ||
| name: 'test.only.each when configured to prefer each', | ||
| code: 'test.only.each([1, 2, 3])("test", (n) => { expect(n).toBeDefined() })', | ||
| options: [{ test: 'each' as const }], |
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.
why are these marked const? I'm curious?
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 realized it's unnecessary here - TypeScript already infers the literal types correctly since the values match the union type. Removed all instances.
veritem
left a comment
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
Closes #702
Add
vitest/consistent-each-forrule to enforce consistent usage of.eachor.forfor parameterized tests acrosstest,it,describe, andsuitefunctions.