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 an option to not throw an error on an unmatched pattern #10587
Add an option to not throw an error on an unmatched pattern #10587
Comments
This seems reasonable to me as long as the default behavior remains unchanged. Let's see what others say. Edit: typo |
Agreed, it would be better to opt-in to this so that by default we are helping users avoid typos in their patterns. |
Ignore my comment. Thanks @not-an-aardvark , I was doing |
I don't think an error is thrown for nonexistent paths in |
I think there are relatively few use cases for this option (one of which might be running eslint in an integration), but I don't object to adding it. That said, if you're encountering an error like this when running ESLint from the command line, the solution should usually be to stop trying to lint non-existing files, not to add a flag to make ESLint ignore your errors. This issue has a lot of 👍s in comparison with the narrowness of the use case, which makes me suspect that some people are misunderstanding what the error message is saying. |
Any update on this? I would like to describe my case:
My |
@isnifer Thanks for explaining your use case. I'm a bit confused -- if you don't have any |
@not-an-aardvark no, I have a code. But
Actually, I have found a solution for this:
It works little bit longer when cold start, but then there is no problem. |
@isnifer I'm still not sure I understand -- what is the error message when you use your "v4 command" with ESLint v5? Is there a particular pattern that ESLint says isn't matching any files? |
Because I don't need my RN |
So to make sure I understand, you want to use the same lint script in multiple environments, but in certain environments some of the files are absent? |
@not-an-aardvark correct. And I did it before v5. |
I've just upgraded to latest eslint@5.*, and this check is causing troubles to me as well. I usually use eslint as: In this case I get the following error:
IMHO eslint shouldn't trigger the error for folders which are explicitly ignored. What do you think about this? |
Sorry for the double post. I've also tried to run eslint as That's not optimal cause if I add a folder, or file I've to update the build script as well, but I need a workaround for now. However the above causes troubles as well, because I've some folders (eg. in app/folder2) which don't contain javascript file, but only json (eg. app/folder2/data/foo.json). So I would really need a way to opt-out from this stricter check. |
Hi @brunoscopelliti, have you tried quoting the globs like |
Hi @not-an-aardvark, I didn't know that was possible; quoting the globs worked for me. Thank you for the help. |
I've created a bash script as a workaround for this issue: #!/bin/bash
GLOB_PATTERN=${1:-"."}
OUTPUT="$(script --quiet --return --command "eslint ${GLOB_PATTERN}" /dev/null)"
EXIT_CODE=${?}
if [[ "${EXIT_CODE}" == "2" ]]; then
exit 0
fi
echo "${OUTPUT}"
exit "${EXIT_CODE}" Just call it passing the desired pattern as an argument. |
N.b. needs to manually run patterns to lint through the glob module before linting until eslint/eslint#10587 is resolved. Which might not be.
N.b. needs to manually run patterns to lint through the glob module before linting until eslint/eslint#10587 is resolved.
* fix: upgrade eslint to v5 N.b. needs to manually run patterns to lint through the glob module before linting until eslint/eslint#10587 is resolved. * chore: swap glob for globby
This proposal has been accepted. PRs welcome! |
I'm gonna take a look at this over the weekend and see if it's something I can tackle |
Add flag to prevent errors when a pattern or --ext is not matched
Add flag to prevent errors when a pattern or --ext is not matched
Add flag to prevent errors when a pattern or --ext is not matched
The version of ESLint you are using.
The problem you want to solve.
Since breaking behaviour change 8b7c6ea #7390 #10143 bundled in ESLint 5, a fatal error is thrown if any file pattern return no files.
My company is using a generic ESLint configuration/runner for all our projects, and we are pretty happy with that:
The problem is that not ALL of our projects matches the same patterns, and we got this error since we upgraded to
eslint@5
We don't want to implement custom code to check for pattern existence before appending them to eslint CLI parameters (and we where really happy with eslint@4 behaviour on this particular case).
NOTE: This issue is a bit related to #9977
Your take on the correct solution to problem.
Add a CLI option (exactly like how proposed here) not to throw errors on unmatched patterns.
Something like
--no-error-on-missing-files
or--no-error-on-unmatched-pattern
The text was updated successfully, but these errors were encountered: