6

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.
Vũ Anh Dũng
  • 980
  • 3
  • 13
  • 32

2 Answers2

2

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.

  • If I change only script, it works. But If I change only .eslintignore, it doesn't work. Because if script is correct, eslint checks only in /app folder and node_modules is not inside /app folder, no need to add node_modules to .eslintignore. If my script is not correct, It checks all filter from root folder, and I add node_modules to .eslint ignore, why it doesn't work ? – Vũ Anh Dũng Aug 20 '21 at 01:40
2

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

Eggcellentos
  • 1,570
  • 1
  • 18
  • 25