Closed Lonli-Lokli closed 3 years ago
Same issue here! :(
@Lonli-Lokli Please provide something closer to a reproduction of the issue.
If you ran eslint --quiet
then you are not using the Nx tooling to invoke ESLint.
In order to begin looking into this we need much more information about your setup: configuration files, the commands you ran.
I also strongly advise checking out the docs on typescript-eslint regarding performance so that you can understand what is going on: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#my-linting-feels-really-slow
@JamesHenry Ok we use husky + lint-staged + prettier + eslint in our project.
So on every commit we run linting to ensure everything is ok. We cannot run angular nx lint directly as it does not work with lint-staged, eg it can lint only staged files.
So we have this in our package.json
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"import-conductor --staged -p @test -i libs/api/src/generated/**/*.ts",
"prettier --write",
"node --max_old_space_size=4096 node_modules/eslint/bin/eslint.js --quiet"
],
"*.{js,json,md,html}": [
"prettier --write"
],
"*.{scss,css}": [
"prettier --write",
"stylelint --syntax scss --fix"
]
},
I'm seeing this with nx/ng lint for a newly generated Nest app which seems to have added eslint (on v10 though)
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
@JamesHenry was my answer clear for you?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
@Lonli-Lokli To make that setup work, you will need to have a dedicated eslint-focused tsconfig
which includes all of your TypeScript files. The way typescript + eslint is configured with Nx is focused on using typescript + eslint with Nx, specifically - meaning on a project by project basis.
You will also need to set the parserOptions.project
value to use that dedicated eslint config, instead of the standard root Nx one, just for this use case. I'm not sure if overriding one subsection of a config like parserOptions.project
is actually possible via the eslint CLI, so you may additionally have to create a dedicated eslint config file for this.
Putting it all together - NOTE: untested, and off the top of my head, so may need some tweaking:
tsconfig.eslint.json
{
"extends": "./tsconfig.base.json",
"includes": ["**/*.ts"]
}
lint-staged.eslintrc.json
{
"extends": "./.eslintrc.json",
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["./tsconfig.eslint.json"]
}
}
]
}
Then update your call to the ESLint CLI (seemingly "node --max_old_space_size=4096 node_modules/eslint/bin/eslint.js --quiet"
) to point specifically at the lint-staged.eslintrc.json
, or whatever name you go with.
Hope that helps!
@JamesHenry thanks I will give it a try.
Have you considered husky & lint-staged integration in Nrwl apps?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
@Lonli-Lokli we will not integrate husky
in the generated workspace, as that would interfere with existing setup people already have. Additionally, pre-commit hooks rarely run just linter, so it's hard to build a silver bullet that would fit everyone's needs.
We do however use husky
internally on the nx
where we run certain checks on pre-push.
We might integrate lint-staged
at some point, but currently it's not so trivial.
@Lonli-Lokli @meeroslav I discussed this with Victor yesterday.
As meeroslav says, we do not have any plans to integrate that tooling into Nx, but we are working on the linting performance on two different fronts concurrently:
Those, combined with the more informal tips I gave above around a solution above for your specific scenario should covers things well for now and as per Victor's instructions I will be closing this one.
@Lonli-Lokli To make that setup work, you will need to have a dedicated eslint-focused
tsconfig
which includes all of your TypeScript files. The way typescript + eslint is configured with Nx is focused on using typescript + eslint with Nx, specifically - meaning on a project by project basis.You will also need to set the
parserOptions.project
value to use that dedicated eslint config, instead of the standard root Nx one, just for this use case. I'm not sure if overriding one subsection of a config likeparserOptions.project
is actually possible via the eslint CLI, so you may additionally have to create a dedicated eslint config file for this.Putting it all together - NOTE: untested, and off the top of my head, so may need some tweaking:
tsconfig.eslint.json
{ "extends": "./tsconfig.base.json", "includes": ["**/*.ts"] }
lint-staged.eslintrc.json
{ "extends": "./.eslintrc.json", "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "parserOptions": { "project": ["./tsconfig.eslint.json"] } } ] }
Then update your call to the ESLint CLI (seemingly
"node --max_old_space_size=4096 node_modules/eslint/bin/eslint.js --quiet"
) to point specifically at thelint-staged.eslintrc.json
, or whatever name you go with.Hope that helps!
A bit late but wanted to share, that this setup worked for me!
Just had to remove the *.js
files from the new lint-staged.eslintrc.json
and add --no-ignore
, otherwise the ignore pattern of root .eslintrc.json
kicks in:
lint-staged.eslintrc.json
{
"extends": "./.eslintrc.json",
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["./tsconfig.eslint.json"]
}
}
]
}
.lintstagedrc.js
module.exports = {
// ...
'*.{js,ts,html}': (files) => [
`eslint --quiet --no-ignore -c lint-staged.eslintrc.json ${files.join(
' '
)}`,
],
};
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
eslint --quiet fails with current structure with Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Expected Behavior
No errors
Steps to Reproduce
Just migrated from v10 to v11, might be caused by wrong ts configuration (no include in tsconfig), see https://github.com/typescript-eslint/typescript-eslint/issues/1551
Environment
Node : 10.22.0 OS : win32 x64 npm : 6.14.6
nx : Not Found @nrwl/angular : 11.2.10 @nrwl/cli : 11.2.10 @nrwl/cypress : 11.2.10 @nrwl/devkit : 11.2.10 @nrwl/eslint-plugin-nx : 11.2.10 @nrwl/express : Not Found @nrwl/jest : 11.2.10 @nrwl/linter : 11.2.10 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 11.2.10 @nrwl/web : Not Found @nrwl/workspace : 11.2.10 typescript : 4.0.3