【问题标题】:eslint: ignore-pattern rule is not workingeslint:忽略模式规则不起作用
【发布时间】:2020-03-23 21:41:46
【问题描述】:

我有以下结构

myproject
    src
        indxe.js

在我的 package.json 中我也有:

"scripts": {
    "build": "babel src -d dist --source-maps",
    "serve": "node dist/index.js",
    "start": "babel-node src/index.js",
    "start:dev": "nodemon src/index.js --exec babel-node",
    "test": "jest --runInBand --verbose",
    "coverage": "jest --coverage --runInBand --verbose",
    "eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""
  },

但正在运行

yarn eslint

我收到一个错误

"eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""

$ eslint src/**/.js --ignore-pattern "node_modules/"

Oops! Something went wrong! :(

ESLint: 5.10.0.
No files matching the pattern "src/**/.js" were found.
Please check for typing mistakes in the pattern.

error Command failed with exit code 2.

我不明白为什么应该没问题...

欢迎反馈

【问题讨论】:

    标签: node.js eslint


    【解决方案1】:

    您错误地指定了 glob 模式:

    eslint src/**/.js
    

    这样,您指定:“在 src 下的任何目录中,找到具有 确切名称 .js 的所有文件”

    你真正想要的是:“在src下面的任何目录中,找到所有名称以结尾的文件.js

    您可以通过添加另一个星号来实现此目的,该星号用作每个 JS 文件名开头的占位符,如下所示:

    eslint src/**/*.js
    

    您可以在此处找到有关如何使用 glob 模式的更多信息:https://github.com/isaacs/node-glob#readme

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 1970-01-01
      • 2021-01-15
      • 2018-01-08
      • 1970-01-01
      • 2018-05-27
      • 2017-07-24
      • 1970-01-01
      • 2022-01-13
      相关资源
      最近更新 更多