Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config

Viewed 21

first of all: I already read a lot here on stackoverflow and I tried a lot, but I couldn't solve my problem yet.

I am trying to set up a jest environment for typescript files. When I run the test, I get the following error:

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: foo.tsx.
The file must be included in at least one of the projects provided

tsconfig.json

{
  "compilerOptions": {
    ...
  },
  "include": [
    "src/**/*.tsx",
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

.eslintrc.js

module.exports = {
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@stencil/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 13,
    "sourceType": "module",
    "project": "./tsconfig.json"
  },
  "ignorePatterns": [
    "temp.js",
    "**/*.stories.ts",
    // "**/*.ts",
    // "**/*.tsx"
  ],
  ....
}

jest.config.ts

const config = {
  verbose: true,
  testMatch: ['**/*.tsx'],
  transform: {
    '^.+\\.tsx?$': 'ts-jest',
  },
  globals: {
    'ts-jest': {
      isolatedModules: true,
    },
  },
};

export default config;

It works perfectly fine when I just parse *.ts OR *.tsx files (remove the include in tsconfig.json and add the ignore pattern in .eslintrc from the other file type), but I get the error when I try to parse both file types.

Any ideas? Thanks.

0 Answers
Related