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

Don't capture false positives #744

Merged
merged 1 commit into from
Mar 2, 2021
Merged

Conversation

adamvonbaron
Copy link

@adamvonbaron adamvonbaron commented Feb 21, 2021

this is a pr to resolve #743. upon thinking about the cause of this problem more i realized that the output causing the false positive was output emitted by yarn. my initial thought was to write a regex that would capture output that was yarn specific and ignore it, however this makes several assumptions about how other people may be using overcommit. i think it can be much more simple than that. the regex used to capture eslint messages here:

/^(?<file>(?:\w:)?[^:]+):[^\d]+(?<line>\d+).*?(?<type>Error|Warning)/,

actually does a really good job at capturing the data needed for overcommit to output information and adding a small tweak to that rule fixes the issue at hand. eslint messages have no whitespace before a file or filepath that has a linting issue, but something like

$ yarn eslint --quiet --format=compact /app/project/Error.ts

does. if we can just simply ignore any lines that DO have whitespace before the <file> capture group we can presume that line is not an eslint error or warning message, but some output emitted by some other program (such as yarn).

@sds sds added the bug label Mar 2, 2021
@sds sds merged commit 3d5c5db into sds:master Mar 2, 2021
@sds
Copy link
Owner

sds commented Mar 2, 2021

Thank you!

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

Successfully merging this pull request may close these issues.

eslint rule will fail due to filepaths that contain either "Warning" or "Error"
2 participants