question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`cypress.config.ts` triggers ESLint errors

See original GitHub issue

Current behavior

When configuring Cypress with cypress.config.ts (TypeScript file), and using ESLint with parser: '@typescript-eslint/parser' the following error is triggered:

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

Basically, because a TypeScript file is not included in my tsconfig.json this error is triggered and neither /* eslint-disable */ or /* eslint-disable-next-line */ will fix the error.

The only way to fix it is to add cypress.config.ts in my .eslintignore file which disabled linting on the config file (not ideal).

I also cannot include cypress.config.ts in my tsconfig.json because it would compile the file.

Desired behavior

There shouldn’t be any ESLint issue related to the cypress.config.ts

Maybe an idea would be to move the config file under the cypress directory and make sure it’s included in the Cypress tsconfig.json?

Test code to reproduce

An example should be available as soon as I push my changes here: https://github.com/Avansai/next-multilingual

Cypress Version

latest

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
nbouvrettecommented, Jul 30, 2022

I actually found a decent workaround, I simply added cypress.config.ts in the cypress/tsconfig.json file like that:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"]
  },
  "include": ["../cypress.config.ts", "**/*.ts"]
}

This might be worth adding somewhere in the documentation?

0reactions
nbouvrettecommented, Oct 4, 2022

@arimgibson thanks for sharing. I didn’t use that but instead added this in my parent tsconfig.json:

"exclude": ["node_modules", "cypress", "./cypress.config.ts"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

New Cypress 10 global TypeScript type conflicts with Jest ...
The following new global TypeScript type for expect in node_modules/cypress/types/cypress-expect.d.ts causes conflicts with Jest expect ...
Read more >
Cypress linting and type check is ignored on command line ...
I have a nest.js + cypress with TS setup. ... On the CLI when running the command below, cypress errors are not caught....
Read more >
Best Practices - Cypress Documentation
Real World Practices The Cypress team maintains the Real World App (RWA), a full stack example application that demonstrates best practices and scalable....
Read more >
Setting up the first acceptance tests in GitLab CI pipeline
Cypress : Setting up the first acceptance tests in GitLab CI pipeline ... After adding the typescript, renaming files to .ts and reshuffling, ......
Read more >
Linting Cypress code using ESLint and eslint-plugin-cypress
Installing ESLint, linting React application and using https://github.com/ cypress -io/ eslint -plugin- cypress to add settings for Cypress specs ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found