ESLint:防止掉落非标准文件扩展名

时间:2020-07-07 03:16:33

标签: 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"

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

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文件被掉毛。 我错过了哪个设置?

1 个答案:

答案 0 :(得分:0)

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

不过,我也建议使用eslint-plugin-json作为替代解决方案。