我想运行 lint 检查所有没有 node_modules 的文件 *.js
这是我的命令:"lint": "eslint **/*.js",
,我的文件夹结构如下:app > module_name > module.js
但是在应用程序文件夹中仍然有一些常见的文件,如 helpers.js
server.js
我也想检查它们。
在 .eslint 配置中,我添加了 "ignorePatterns": "node_modules"
并尝试添加一个文件 .eslintignore 并添加 node_modules
但它不起作用。
当我运行 npm run lint
时,它总是抛出错误:
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.
最佳答案
您可以在 .eslintignore 文件中添加 node_modules/
,并使用脚本更新 package.json 文件:"lint": "eslint --ext .js app/",
在运行 npm run lint
之前。
关于node.js - eslint 忽略模式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68841841/