Comments (9)
@MikeMcC399 ah, thank you!
This eslint/eslintrc#148 (comment) seems to do the trick.
So if anyone else encounters this, what seems to be working is the following:
{
...,
...compat
.config({
extends: ["plugin:cypress/recommended"],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
project: "./cypress/tsconfig.json",
},
})
.map((config) => ({ ...config, files: ["cypress/**/*"] })), // Add the files property to every array entry to restrict it to only be applied to these files.
...
}
Thanks again for the tip!
from eslint-plugin-cypress.
It's great that solved your issue. 🎉 This should probably go into the documentation as it will be a common problem for those upgrading and used to having a specific eslintrc*
file in the cypress
directory.
from eslint-plugin-cypress.
@ceisele-r
Thank you for re-posting your question!
Please say which version of eslint
and eslint-plugin-cypress
you are using.
Also to complete the picture, it is helpful to know which operating system you are using and which version of Node.js.
from eslint-plugin-cypress.
Each config object of the flat config can have it's own files
definition (see docs here). So this should be possible (not tested):
...
,
...compat.config({
extends: ["plugin:cypress/recommended"],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
project: "./cypress/tsconfig.json",
},
files: ["cypress/**/*.js"],
}),
...
from eslint-plugin-cypress.
@MikeMcC399 thanks, I'm on eslint 8.57.0
and eslint-plugin-cypress
3.2.0.
@codeflorist that's what I already tried before, but unfortunately, there is no files
property for ...compat.config(...) objects:
Object literal may only specify known properties, and 'files' does not exist in type 'Config<RulesRecord, RulesRecord>'.ts(2353)
So that's unfortunately no solution.
from eslint-plugin-cypress.
In the https://github.com/cypress-io/cypress-example-kitchensink repo there is a script defined as
"lint": "eslint --fix cypress app/assets/js/scripts.js"
so that only lints cypress
(and one other JavaScript file)
Would that be a workaround for you?
from eslint-plugin-cypress.
@MikeMcC399 unfortunately not.
It's a larger project where cypress is only one part.
Therefore, there is one new flat eslint.config.js
that should cover everything (regular code, other tests, cypress tests etc.) with one lint
script (as well as that VS Code picks up that single config for IDE support).
This used to work by having multiple eslintrc.js
files in respective directories that extended the main config.
According to my understanding of the new eslint.config.js
, this is now all to be flattened in that single config (to only ever have 1 eslint config file).
Therefore, there is the files
property in there now so that we can do something like:
{
...
{
files: ["src/whatever/**/*"],
rules: {
"@typescript-eslint/promise-function-async": "error",
},
},
...
}
to enforce specific rules/plugin configurations for specific directories/files.
But for your recommended compat solution using compat.config
, this does not seem to be an option (or I missed the correct syntax how to specify the files this compat.config
should be applied to).
from eslint-plugin-cypress.
Would you take a look at eslint/eslintrc#148 to see if this explains it?
You're welcome to take the question over to the ESLint experts in their Discord channel https://eslint.org/chat as well since it concerns how to use their @eslint/eslintrc library.
I will also see in parallel if I can get this working.
from eslint-plugin-cypress.
I'm going to close this issue now as v3.3.0 removes the reliance on the Flat mode compatibility utility.
from eslint-plugin-cypress.
Related Issues (20)
- Assignment of return value in ternary operator is not recognized HOT 1
- Refactor: Convert project to typescript HOT 4
- Peer dependency failure using `npm ci` on repo source HOT 2
- Eslint 8 deprecated rules `context`: planned failure Eslint 9 HOT 5
- Support ESLint 9 HOT 3
- Eslint 9 fails with legacy config .eslintrc HOT 6
- CircleCI tests only old eslint versions v4, v5 & v6 HOT 1
- CircleCI tests with end-of-life Node.js 16 HOT 2
- Script tests for other ESLint versions give warnings or fail HOT 3
- @cypress/[email protected] lacks support for ESLint 4 HOT 2
- @cypress/[email protected] conflicts through mocha for ESLint 5 support HOT 2
- Migrate from @cypress/eslint-plugin-dev to supported plugins HOT 6
- Outdated peerDependencies eslint >= 3.2.1 HOT 2
- Release v3.0.0 failed in semantic release HOT 11
- `.only` and `.skip` rule needs HOT 1
- Provide meta prerequisites for automatic document generation HOT 1
- cypress/no-async-before rule fails with "definition not found" HOT 1
- cypress/no-async-before rule documentation issues HOT 3
- config file invalid (using .ts) after update to 3.2.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-cypress.