node.js - eslint 忽略模式不起作用

标签 node.js eslint lint

我想运行 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/

相关文章:

javascript - 在编译之前如何在多个文件之间共享全局 javascript 变量?

reactjs - 我在哪里可以找到 CRA 中的 .eslintrc?

android - 使用 gradle build android app 时 Lint 失败

javascript - 使用适用于 Node.js 的 AWS 开发工具包将项目放在 DynamoDB 表中

node.js - Passport : Authenticating the whole app instead of some requests

javascript - 在类型声明中将函数声明为参数

F#:减少此功能

node.js - 如何使新的elasticsearch node.js客户端仅在promise中返回主体?

node.js - OpenSSL 错误 - 无法获取本地颁发者证书

javascript - Lint 错误 - 意外的字符串连接