-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem setting up in a Next.js project with flat config, rules not enforced at all #240
Comments
If I comment out // ...compat.extends('next/core-web-vitals', 'next/typescript'),
// eslintPluginPrettierRecommended, then Cypress linting works fine. You might try moving There is a https://github.com/eslint/config-inspector which is sometimes helpful. When installing your dependencies there are dependency conflicts, however I don't think they would be causing your issue:
https://eslint.org/chat also offers ESLint assistance. |
@MikeMcC399 Thank you for the tip about the config inspector, however it crashed when I try to run it. Command: Opens the browser with this message:
I did however try running EDIT: I found the problem. There is a directory setting in eslint: {
dirs: ['src/', 'cypress/'],
}, I do however wonder how can I configure this plugin to only apply to files with the filename that ends with |
Good to see that you found the issue!
The plugin doesn't define any files to check. You can look into the source directory lib to understand the definitions. The ESLint documentation https://eslint.org/docs/latest/use/configure/configuration-files provides some explanation about how file selection is supposed to work. |
So is it correct then to do like this? {
...pluginCypress.configs.recommended,
files: ['cypress/**/*.js'],
rules: {
...pluginCypress.configs.recommended.rules,
'cypress/no-pause': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/unsafe-to-chain-command': 'off',
},
} I didn't get it to work with Thanks for all your help! |
Discord is probably your best bet to get expert configuration help. I also haven't been able to translate the ESLint documentation into a working example in this regard. |
The following seems to work: import pluginCypress from 'eslint-plugin-cypress/flat';
export default [
{
files: ['cypress/**/*.cy.js'],
plugins: {
cypress: pluginCypress
},
...pluginCypress.configs.recommended,
rules: {
...pluginCypress.configs.recommended.rules,
'cypress/no-pause': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/unsafe-to-chain-command': 'off',
},
},
]; Also if you have difficulty combining configurations you can write separate ones and use the eslint --inspect-config is good for checking when there are no legacy configs involved. |
Ok, I got it working now thanks! |
I am migrating a Next.js project to ESLint 9 with flat file format. I have gotten every plugin to work quite simply by following what it says in each projects docs. However, I cannot make "eslint-plugin-cypress" work at all. I add the configuration, and ESLint runs just fine but the cypress eslint rules are never enforced. For example to test it I add cy.wait(5000) and cy.pause() in some cypress tests and run the linter and it doesn't give any errors as I have configured it to do.
Is there something weird going on when using this together with Next.js? I have spent hours trying different things.
The cypress files are in a /cypress folder and all other code in /src under the __basedir. But this should not matter right?
Versions:
The config:
The text was updated successfully, but these errors were encountered: