Chicky
Chicky

Reputation: 1257

eslint ignore pattern not works

I want to run lint check all the file *.js without node_modules

Here my command: "lint": "eslint **/*.js",, My folder structure look like: app > module_name > module.js but in the app folder still having some files common like helpers.js server.js and I also want to check them.

In .eslint config I added "ignorePatterns": "node_modules" and tried added a file .eslintignore and add node_modules but it's not working.

When I run npm run lint it always throw error:


Oops! Something went wrong! :(

ESLint: 7.32.0

You are linting "node_modules/bignumber.js", but all of the files matching the glob pattern "node_modules/bignumber.js" are ignored.

If you don't want to lint these files, remove the pattern "node_modules/bignumber.js" from the list of arguments passed to ESLint.

If you do want to lint these files, try the following solutions:

* Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
* Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.

Upvotes: 6

Views: 11388

Answers (2)

balu ekkaldevi
balu ekkaldevi

Reputation: 21

You could add node_modules/ in your .eslintignore file, and update the package.json file with script: if u r using ubuntu/linux

"lint": "eslint '**/*.js'"

if project structure like these folder/file.js

if u r using windows

"lint": "eslint **/*.js"

if project structure like these folder/file.js

Upvotes: 2

alwaysherewithme
alwaysherewithme

Reputation: 21

You could add node_modules/ in your .eslintignore file, and update the package.json file with script: "lint": "eslint --ext .js app/", before running npm run lint.

Upvotes: 2

Related Questions