【问题标题】:ESLint: prevent from being linted non-standard files extensionsESLint:防止被 lint 非标准文件扩展名
【发布时间】:2020-07-09 01:37:27
【问题描述】:

我的.estintrc.yaml

parser: "@typescript-eslint/parser"
parserOptions:
  sourceType: module
  project: tsconfig.json
  tsconfigRootDir: ./

env:
  es6: true
  browser: true
  node: true
  mocha: true

plugins:
  - "@typescript-eslint"

有了它,我有很多错误,例如:

D:\*****\project\package.json
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: package.json.
The extension for the file (.json) is non-standard. You should add "parserOptions.extraFileExtensions" to your config

我没有要求检查.json 文件。 我只希望 .ts.vue 文件会被检查。 我错过了哪个设置?

【问题讨论】:

  • 你能解决这个问题吗?

标签: javascript typescript eslint


【解决方案1】:

当您调用 eslint 时,您可以使用 —ext 标志告诉它要检查的文件类型。要限制配置文件中的文件类型,您必须将所有规则和扩展配置包装在 override 中。

不过,我也会推荐 eslint-plugin-json 作为替代解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-20
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    相关资源
    最近更新 更多