Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

ESLint was configured to run using parserOptions.project, but the file is not in the TSConfig

ErrorParsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project`

Short answer

Type-aware linting needs every linted file to belong to a TypeScript project. The error means the file, often a Cypress spec or an eslint config, is not matched by any tsconfig listed in parserOptions. Add it to include, switch to projectService with allowDefaultProject, or lint it without type information.

  • Applies to typescript-eslint 8, ESLint 9, TypeScript 5, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the tsconfig that parserOptions points to and compare its include and exclude lists with the path in the error message.

    cat tsconfig.json
  2. 2Match what you see, then jump to its fix

    1. 1The file named in the error sits in a folder such as cypress, component or tests that tsconfig.json leaves out.The tsconfig include globs do not match the fileFix
    2. 2Adding the folder to tsconfig.json would change what gets built.The tsconfig used for the build must stay as it isFix
    3. 3The failing file is eslint.config.mjs, .eslintrc.cjs or a similar file in the project root.One or two config files are outside every projectFix
    4. 4The file is plain JavaScript, or a generated file.The file does not need type-aware rules at allFix

What does the error look like?

  • Parsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project`
  • However, that TSConfig does not include this file
  • The file must be included in at least one of the projects provided

Cause 1 of 4

The tsconfig include globs do not match the file

1Check

Open tsconfig.json and compare its include and exclude lists with the path in the error.

cat tsconfig.json

2Fix

Add the folder to include. For .js, .cjs or .mjs files also turn on allowJs.

{
  "include": ["src", "component", "cypress"]
}

3Verify

Run ESLint on the file again.

npx eslint component/TestComponent.cy.ts

Confirmed by typescript-eslint.io

Did this fix it?

Cause 2 of 4

The tsconfig used for the build must stay as it is

1Check

The build config should not list test or tool files, yet ESLint needs them in a project.

grep -n "project" eslint.config.* .eslintrc.*

2Fix

Create a tsconfig.eslint.json that lists every file you lint, then point ESLint at it.

// tsconfig.eslint.json
{ "extends": "./tsconfig.json", "include": ["src", "component", "cypress", "*.config.*"] }

// eslint config
languageOptions: {
  parserOptions: { project: "./tsconfig.eslint.json" },
},

3Verify

Run ESLint on the failing file.

npx eslint component/TestComponent.cy.ts

Confirmed by typescript-eslint.io

Did this fix it?

Cause 3 of 4

One or two config files are outside every project

1Check

Tool config files are usually not part of tsconfig.json. With projectService, the allowDefaultProject option lets a few of them run with default compiler options.

grep -n "projectService" eslint.config.*

2Fix

Switch to the project service and list those files. Globs cannot contain **, and each match adds linting cost, so keep the list short.

parserOptions: {
  projectService: {
    allowDefaultProject: ["eslint.config.mjs"],
  },
},

3Verify

Run ESLint on the config file.

npx eslint eslint.config.mjs

Confirmed by typescript-eslint.io

Did this fix it?

Cause 4 of 4

The file does not need type-aware rules at all

1Check

Type-checked rules only matter for files with types. JavaScript tool files can skip them.

grep -n "disableTypeChecked" eslint.config.*

2Fix

Turn type-checked linting off for those files, or ignore them.

{
  files: ['**/*.js'],
  extends: [tseslint.configs.disableTypeChecked],
},

3Verify

Run ESLint over the project.

npx eslint .

Confirmed by typescript-eslint.io

Did this fix it?

How do I stop it coming back?

  • Keep one tsconfig that covers every file ESLint lints, or a dedicated tsconfig.eslint.json.
  • Set tsconfigRootDir so relative tsconfig paths do not depend on where you start ESLint.
  • Update the parser package: newer versions print a clearer message for this error.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.