Skip to content
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

Merged
merged 5 commits into from Mar 13, 2017
Merged

ESLint pre-commit hook fails if there are problems #475

merged 5 commits into from Mar 13, 2017

Conversation

ghost
Copy link

@ghost ghost commented Mar 10, 2017

A user can choose to ignore this behavior by specifying bindly_pass option:

PreCommit:
  EsLint:
    enabled: true
    on_warn: fail
    bindly_pass: true

@ghost ghost changed the title Fix issue #458 so ESLint fail if there are some problems ESLint pre-commit hook fails if there are problems with ESLint Mar 10, 2017
@ghost ghost changed the title ESLint pre-commit hook fails if there are problems with ESLint ESLint pre-commit hook fails if there are problems Mar 10, 2017
Copy link
Owner

@sds sds left a 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.
Copy link
Owner

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)

Copy link
Author

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).

Copy link
Contributor

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
Copy link
Owner

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).

Copy link
Author

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.')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderrs -> stderr

@ghost
Copy link
Author

ghost commented Mar 11, 2017

Hello @sds!

First, thanks for the time you dedicate to this project and to me.
For the testing issue: I tested the changes locally and it works correctly, I tried multiple times before to open a pull request.

I am sorry 'cause I've not studied the code enough to avoid the typo I did.
I am going to fix everything during the day.

Copy link
Contributor

@trotzig trotzig left a 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.
Copy link
Contributor

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.

@trotzig trotzig merged commit f8cd206 into sds:master Mar 13, 2017
@trotzig
Copy link
Contributor

trotzig commented Mar 13, 2017

Thanks for following up @domcorvasce! The build failures weren't introduced by you so I went ahead and merged your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants