簡體   English   中英

ESLint:防止被 lint 非標准文件擴展名

[英]ESLint: prevent from being linted non-standard files extensions

我的.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文件被檢查。 我錯過了哪個設置?

當您調用 eslint 時,您可以使用—ext標志告訴它要檢查的文件類型。 要限制配置文件中的文件類型,您必須將所有規則和擴展配置包裝在override中。

但是,我也會推薦eslint-plugin-json作為替代解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM