JacobTheDev
JacobTheDev

Reputation: 18550

How can I suppress the "No files matching the pattern" message in ESLint?

In my CI setup, I have a test that runs eslint against all JS files. If no JS files exist, it's currently throwing an error. I'd prefer if it'd succeeded when no JS files exist. Is this possible?

$ eslint "./src/assets/scripts/**/*.js"

Oops! Something went wrong! :(

ESLint: 5.7.0.
No files matching the pattern "./src/assets/scripts/**/*.js" were found.
Please check for typing mistakes in the pattern.

ERROR: Job failed: exit code 1

Upvotes: 105

Views: 123152

Answers (6)

Bimol DAs
Bimol DAs

Reputation: 1

Step 1: Add this command to your package.json file "scripts": { "eslint": "eslint" }

Step 2: Run below command to clear cache npm run eslint -- --clearCache

Upvotes: -1

Mr.7
Mr.7

Reputation: 2713

In my case, I had to change from

"lint": "eslint \"**/*.{ts, tsx}\""

to

"lint": "eslint \"**/*.{ts,tsx}\""

which is literally a space between ts & tsx / js & jsx

Upvotes: 5

Randall
Randall

Reputation: 2858

I have the same error

No files matching the pattern ".ts," were found

I just removed spaces between types .js, .ts, .tsx in config and it works.

From:

"lint": "eslint --ignore-path .gitignore --ext .js, .ts, .tsx .",

To

 "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",

Upvotes: 5

Sebastian Vorac
Sebastian Vorac

Reputation: 4693

What worked for me was changing single quotes to escaped double quotes

So from:

"lint": "eslint '**/*.{ts,tsx}'"

To:

"lint": "eslint \"**/*.{ts,tsx}\""

The reason is because it depends on the console you are using - possibly the operation system (that's why it can work for you while it's not working for others and via versa) Source: https://dev.to/gruckion/comment/b65c

Upvotes: 169

ncraley
ncraley

Reputation: 894

The --no-error-on-unmatched-pattern flag was added in v6.8.0 of ESLint.

https://eslint.org/docs/user-guide/command-line-interface#no-error-on-unmatched-pattern

Upvotes: 87

JacobTheDev
JacobTheDev

Reputation: 18550

Was able to dig up this closed issue on ESLint's GitHub. Sounds like this is a common problem, and has no good workaround, other than manually checking for the files existence before attempting to lint, as suggested by @user2864740

Upvotes: 6

Related Questions