-
Notifications
You must be signed in to change notification settings - Fork 280
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
ESLint pre-commit hook fails if there are problems #475
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.
Hey @domcorvasce, thanks for the pull request!
Can you help me understand why this is necessary? Also, did you mean for the name to be blindly_pass
? (I'm not familiar with what bindly
refers to in this context)
In general, this has me slightly skeptical due to the naming. I would like some concrete examples so we can come up with a better name.
Or even better: it seems like it would make more sense for the hook to warn
when there is a problem parsing a file with eslint
, rather than having the user explicitly specify an option to override this behavior (but since I don't write JavaScript I perhaps I don't understand the situations where this comes up).
I'm also concerned with the multiple typos in this PR. It suggests you haven't explicitly tested it yourself, which has me concerned about merging.
If you can address those issues I think we'll be in a much better place to merge here. Thanks!
@@ -12,19 +12,30 @@ module Overcommit::Hook::PreCommit | |||
# enabled: true | |||
# command: ['npm', 'run', 'lint', '--', '-f', 'compact'] | |||
# | |||
# If ESLint returns some errors, you can bindly pass by | |||
# setting `bindly_pass` option to true. |
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 we elaborate on the conditions where this is useful? (concrete examples are very helpful 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.
Honestly, I don't think it can be useful.
But I thought that some people might want to pass ahead if something goes wrong with ESLint (I won't do it).
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.
In that case, I think it's better to remove it completely. If not having the configuration option turns out to be an issue for people, we can always add it at that point.
|
||
# Fail for issues relative to the tool used. | ||
if !config['bindly_pass'] && messages.empty? && !result.success? | ||
$stderr.puts result.stderrs |
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.
Using $stderr.puts
will break the formatting of the hook run. Output should be returned along with the return
line below, e.g.:
return [:fail, result.stderr]
Also, stderrs
is a typo (should be stderr
).
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 am very sorry for this.
I returned the stderrs instance variable.
let(:result) { double('result') } | ||
|
||
before do | ||
result.stub(:stderrs).and_return('SyntaxError: Use of const in strict mode.') |
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.
stderrs
-> stderr
Hello @sds! First, thanks for the time you dedicate to this project and to me. I am sorry 'cause I've not studied the code enough to avoid the typo I did. |
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 remove the configuration option, I think this is good to go. However, it would still be useful to understand when this can happen. Perhaps you can provide some javascript file content and the result of running eslint
on it? That could help better understand your change.
@@ -12,19 +12,30 @@ module Overcommit::Hook::PreCommit | |||
# enabled: true | |||
# command: ['npm', 'run', 'lint', '--', '-f', 'compact'] | |||
# | |||
# If ESLint returns some errors, you can bindly pass by | |||
# setting `bindly_pass` option to true. |
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.
In that case, I think it's better to remove it completely. If not having the configuration option turns out to be an issue for people, we can always add it at that point.
Thanks for following up @domcorvasce! The build failures weren't introduced by you so I went ahead and merged your changes. |
A user can choose to ignore this behavior by specifying
bindly_pass
option: