You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a brand new project (angular monorepo) which uses flat eslint configuration. The generated project has a root level eslint.config.mjs, and also has one for the single application. However, eslint only ever considers the top level config as per this blog post. So, the whole setup is invalid; the app level configuration is never read. Therefore, for cypress tests for example, one cannot ignore cypress-specific eslint warnings because cypress.configs['recommended'] is never applied (it'd have to be at the root level).
Expected Behavior
I'd expect that monorepos using flat esconfig would have the correct configuration (single top-level eslint.config.mjs) with the proper setup.
GitHub Repo
No response
Steps to Reproduce
create a new workspace with npx create-nx-workspace (angular / integrated monorepo / esbuild / sass / jest / cypress)
add this extra line to /apps/example-project-e2e/src/e2e/app.cy.ts: // eslint-disable-next-line cypress/no-assigning-return-values
lint the generated e2e test files with npx eslint apps/example-project-e2e/**
observe the error 4:1 error Definition for rule 'cypress/no-assigning-return-values' was not found cypress/no-assigning-return-values
You most likely have misinterpret the eslint documentation about flat config. It still allows each project to have its own eslint config file. However, it will no longer look for other eslint config files as soon as a config file has been found. The previous eslint configuration would merge all found eslint configurations file found in the entire file tree.
When the ESLint CLI is used, it searches for eslint.config.js from the current working directory and if not found will continue the search up the directory’s ancestors until the file is found or the root directory is hit. That one eslint.config.js file contains all of the configuration information
What goes wrong for you is that you are not running eslint for the specific project when you do:
npx eslint apps/example-project-e2e/**
but you are running eslint in the root folder instead. So there indeed the current working directory is the root folder and the root eslint config file will be used.
However, if you would do:
npx nx lint example-project-e2e
That would use the project folder as current working directory and the task will run without any issues.
~/repos/thdk/cypress-eslint (main ✗) npx nx lint test-e2e --skip-nx-cache
> nx run test-e2e:lint
> eslint .
/Users/thdk/repos/thdk/cypress-eslint/apps/test-e2e/src/e2e/app.cy.ts
3:1 warning Unused eslint-disable directive (no problems were reported from 'cypress/no-assigning-return-values')
✖ 1 problem (0 errors, 1 warning)
0 errors and 1 warning potentially fixable with the `--fix` option.
Note that there are two syntaxes for run tasks with nx:
# npx nx run [project-name]:[target-name]:[configuration-name]
npx nx run example-project-e2e:lint
# npx nx [target-name] [project-name] --configuration [configuration-name]
npx nx lint example-project-e2e
(configuration-name is optional and not required here)
I see. The reason this came up was that I could not longer commit certain files as the pre-commit hook failed (husky + lint-staged), as my lint-staged configuration in package.json was something like { "*.ts": "eslint" }, and that obviously runs from the root folder, ignoring the project specific eslint configuration. I guess I have to make that a bit more sophisticated ..
Current Behavior
I've created a brand new project (angular monorepo) which uses flat eslint configuration. The generated project has a root level
eslint.config.mjs
, and also has one for the single application. However, eslint only ever considers the top level config as per this blog post. So, the whole setup is invalid; the app level configuration is never read. Therefore, for cypress tests for example, one cannot ignore cypress-specific eslint warnings becausecypress.configs['recommended']
is never applied (it'd have to be at the root level).Expected Behavior
I'd expect that monorepos using flat esconfig would have the correct configuration (single top-level
eslint.config.mjs
) with the proper setup.GitHub Repo
No response
Steps to Reproduce
npx create-nx-workspace
(angular / integrated monorepo / esbuild / sass / jest / cypress)/apps/example-project-e2e/src/e2e/app.cy.ts
:// eslint-disable-next-line cypress/no-assigning-return-values
npx eslint apps/example-project-e2e/**
4:1 error Definition for rule 'cypress/no-assigning-return-values' was not found cypress/no-assigning-return-values
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: