eslint 忽略模式不起作用

Vũ *_*ũng 6 lint node.js eslint

我想运行 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.
Run Code Online (Sandbox Code Playgroud)

小智 2

您可以添加.eslintignore 文件,并在运行之前node_modules/使用 script: 更新 package.json 文件。"lint": "eslint --ext .js app/",npm run lint