I have files named .eslintignore
and eslintrc.js
in close proximity.
The contents of my ignore file are as follows:
.eslintrc.js
dist/*
node_modules/*
out-tsc/*
However, when I access the eslintrc.js
file, an error is triggered:
Parsing error: ESLint was set up to run on `<tsconfigRootDir>/.eslintrc.js` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/dstein/repositories/social-experiment/packages/site/tsconfig.json
The TSConfig mentioned does not encompass this file. Here are your options:
- Modify ESLint's list of files to exclude this one
- Update the TSConfig to include this file
- Create a new TSConfig that includes this file and reference it in parserOptions.project
For more details, refer to the typescript-eslint documentation: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
The link provided in the guidance advises utilizing .eslintignore
if you wish to skip linting the problematic file. Despite that, my TS config specifies no inclusion of js
files.
{
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"lib": ["es2017", "dom"],
"strict": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"importHelpers": true,
"outDir": "out-tsc",
"sourceMap": true,
"inlineSources": true,
"rootDir": "./",
"incremental": true
},
"include": ["**/*.ts"],
}
It's quite puzzling why the TS Config, which explicitly states to only include ts
files, would engage ESLint through parserOptions.project
.
The ESLint configuration is kept simple (rules omitted for brevity):
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: ['@typescript-eslint'],
env: {
es6: true,
browser: true,
},
extends: [
'@open-wc',
'eslint:recommended',
'plugin:import/recommended',
'prettier',
],
rules: {},
};