简体   繁体   中英

ESLint: prevent from being linted non-standard files extensions

My .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"

With it, I have many errors like:

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

I did not ask to check .json files. I want .ts and .vue files only will be being linted. Which setting I missed?

When you call eslint you can use the —ext flag to tell it what file types to check. To limit file types in the config file, you would have to wrap all rules and extended configs within an override .

I would however also recommend eslint-plugin-json as alternate solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM