17

I have .eslintignore right next to eslintrc.js

The ignore is simply this:

.eslintrc.js
dist/*
node_modules/*
out-tsc/*

However when I go into eslintrc.js I get this error:

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/.eslintrc.js` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/dstein/repositories/social-experiment/packages/site/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: 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 article it links to unsurprisingly says to use .eslintignore if you don't want to lint the file the error is on. Meanwhile, my TS config does not say to include any 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"],
}

Really bewildered why TS Config saying to only include ts files would have ESLint it was configured to run using parserOptions.project

The ESLint config is fairly straightforward (I will remove all the rules to save some reading here):

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: {},
};

5
  • 1
    Haha, I am just facing the exact same problem. Commented Jan 25, 2023 at 12:49
  • The solution is here. stackoverflow.com/questions/58510287/… Commented Jan 25, 2023 at 12:53
  • You need to declare the parserOptions only for ts files. Commented Jan 25, 2023 at 12:54
  • @wasserholz I don't understand. My parserOptions points to tsconfig.json and that config says to only use .ts files? Commented Jan 31, 2023 at 2:00
  • you also need to declare that for .eslintrc.js like here: stackoverflow.com/a/64488474/4541731 Commented Jan 31, 2023 at 7:36

1 Answer 1

6

Add your eslint config file to the list of files to be ignored in the config itself.

Something like this:

ignorePatterns: ['dist', '.eslintrc.js', 'postcss.config.js'],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.