ESLint: prevent from being linted non-standard files extensions

Viewed 3504

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?

1 Answers

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.

Related