-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix(exit-code): Exit with status 1 when there are deprecated rules #287
fix(exit-code): Exit with status 1 when there are deprecated rules #287
Conversation
c14cf30
to
8f052c9
Compare
@@ -12,6 +12,7 @@ const options = { | |||
core: ['core'], | |||
verbose: ['verbose', 'v'] | |||
}; | |||
const optionsThatError = ['getUnusedRules', 'getDeprecatedRules']; |
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 guess I’m confused by this line - why do we need this list? Any option could error and should exit nonzero in that case, no?
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.
If I understand correctly, the other options are informative only: show me my current rules, rules exposed by a plugin, etc. In those cases, having rules to output isn't really an error.
The way the code was before I fixed this bug, only getUnusedRules
would fail with an exit code of 1.
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. I guess I’d assume that each option should be able to determine its own success or failure state; but here it seems like the overarching runner is doing that?
In that case, maybe this is fine for now, but it should probably be rearchitechted later.
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'd argue that there should be process.exit(1)
on this line as well: https://github.com/sarbbottam/eslint-find-rules/blob/master/src/bin/find.js#L44
but I thought that might be out-of-scope for this PR.
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.
@ljharb Yeah, that does make more sense. I think we'd have to change what the various rule finder methods return, which would be a breaking change if anyone is using the rule finder methods programmatically.
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.
Hey there,
is there anything left that stops this review from being approved? It looks good to me.
I totally agree that the determination about success or failure of the options' runners should be thought over and eventually reworked (as well as exiting with an exit code of 1 when no option has been provided), but I also agree that this is out of scope for this PR that should only fix the result of looking for deprecated rules.
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.
If you want to approve it, please do; I intentionally opened this as a non-blocking review :-)
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 didn't realize that 🙈
Hmm ... @randycoulman could you please rebase on master? I am not able to push the merged master after rebasing the pr on it. Unless @ljharb has another idea — I basically wanted to ff merge the pr-branch, but of course the rebase altered the commit's hash, so it's unknown to github, thus being rejected. |
I feel dumb now ... may as well just press »rebase and merge« on the web ui. |
@ta2edchimp you can rebase and force push onto the fork. i'll take care of it. |
8f052c9
to
98782f4
Compare
done |
Thanks a lot! |
Did you clone using https or ssh? I’ve found that only using ssh solves lots of issues. |
SSH. I have to admit, I never even tried to push to a fork / to a branch over at a fork during a PR because I would have assumed write permissions to be optionally per default. |
In #286, I added support for reporting on deprecated rules. According to the documentation and tests I wrote, eslint-find-rules is supposed to exit with code 1 when there are deprecated rules (unless the
--no-error
flag is also provided). However, in real usage, this didn't happen.I discovered that the exit status assertions in the tests were not actually being called in all cases, resulting in the tests passing incorrectly. Looks like I forgot to make sure that the test failed for the right reason in this case. Mea culpa :-(.
I made the following changes:
processExitCode
is managed in the code