ESLint:防止非标准文件扩展名被检查

Gur*_*ofu 5 javascript typescript eslint

我的.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"
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

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

Dav*_*haw 2

当您调用 eslint 时,您可以使用该\xe2\x80\x94ext标志来告诉它要检查哪些文件类型。要限制配置文件中的文件类型,您必须将所有规则和扩展配置包装在override.

\n

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

\n