-
-
Notifications
You must be signed in to change notification settings - Fork 30
add --fix to no-identical-tests. #13
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
add --fix to no-identical-tests. #13
Conversation
Thanks for working on these issues! Sorry about the delay, I'm planning to review your PRs in the next day or two.
I think that's fine and we don't have to worry about it here -- if the |
{ code: 'foo', errors: ['bar'] }, | ||
] | ||
}); | ||
`, |
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.
Can you add a test where there is no trailing comma?
valid: [
{ code: 'foo' }
]
lib/rules/no-identical-tests.js
Outdated
const end = sourceCode.getTokenAfter(test); | ||
return fixer.replaceTextRange( | ||
// should remove test's trailing comma | ||
[start.range[1], end.range[end.value === ',' ? 1 : 0]] |
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 think this will handle whitespace differently depending on whether there is a comma. If there is no comma, then all the whitespace up to the next test will be removed. If there is a comma, the whitespace up to the next test will be preserved.
Maybe it would be better to be consistent about handling whitespace.
ping @not-an-aardvark |
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!
I just have one nitpick, but feel free to merge it afterwards.
lib/rules/no-identical-tests.js
Outdated
fix (fixer) { | ||
const start = sourceCode.getTokenBefore(test); | ||
const end = sourceCode.getTokenAfter(test); | ||
return fixer.replaceTextRange( |
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.
Nitpick: This can be fixer.removeRange
instead of fixer.replaceTextRange
.
Actually, maybe that would be a good rule to add to this plugin. 😄
this is WIP, as the trailing commas have not been handled.it simply remove the identical tests, so may cause incorrect indent. any suggestions? @not-an-aardvark