lint-staged hang for nx monorepo
See original GitHub issueDescription
Steps to reproduce
checkout develop branch
git clone https://github.com/xmlking/ngx-starter-kit -b develop
run lint-staged
npx lint-staged
this command hang forever.
you can run lint commands successfully e.g.
npm run affected:lint -- --uncommitted --fix --parallel
if you remove --fix --parallel
from lint-staged
command then the lint-staged
works
Debug Logs
expand to view
npx lint-staged -d
lint-staged:bin Running `lint-staged@8.0.0` +0ms
lint-staged:find-bin Loaded package.json using `process.cwd()` +0ms
lint-staged Loading config using `cosmiconfig` +0ms
lint-staged Successfully loaded config from `/Developer/Work/SPA/ngx-starter-kit/package.json`:
lint-staged { '{apps,libs}/**/*.{ts,json,md,scss}':
lint-staged [ 'npm run affected:lint -- --uncommitted --fix --parallel',
lint-staged 'npm run format:write -- --uncommitted',
lint-staged 'git add' ] } +3ms
lint-staged:cfg Normalizing config +0ms
lint-staged:cfg Validating config +2ms
Running lint-staged with the following config:
{
linters: {
'{apps,libs}/**/*.{ts,json,md,scss}': [
'npm run affected:lint -- --uncommitted --fix --parallel',
'npm run format:write -- --uncommitted',
'git add'
]
},
concurrent: true,
chunkSize: 9007199254740991,
globOptions: {
matchBase: true,
dot: true
},
ignore: [],
subTaskConcurrency: 1,
renderer: 'verbose'
}
lint-staged:run Running all linter scripts +0ms
lint-staged:run Resolved git directory to be `/Developer/Work/SPA/ngx-starter-kit` +1ms
lint-staged:run Loaded list of staged files in git:
lint-staged:run [ 'package.json',
lint-staged:run 'package-lock.json',
lint-staged:run 'libs/ngx-utils/src/lib/directives/router-link-match/router-link-match.directive.spec.ts',
lint-staged:run 'libs/ngx-utils/src/lib/directives/ng-let/ng-let.directive.spec.ts',
lint-staged:run 'libs/chat-box/src/lib/services/speech-to-text.service.ts',
lint-staged:run 'PLAYBOOK.md' ] +29ms
lint-staged:gen-tasks Generating linter tasks +0ms
lint-staged:cfg Normalizing config +34ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks { pattern: '{apps,libs}/**/*.{ts,json,md,scss}',
lint-staged:gen-tasks commands:
lint-staged:gen-tasks [ 'npm run affected:lint -- --uncommitted --fix --parallel',
lint-staged:gen-tasks 'npm run format:write -- --uncommitted',
lint-staged:gen-tasks 'git add' ],
lint-staged:gen-tasks fileList:
lint-staged:gen-tasks [ '/Developer/Work/SPA/ngx-starter-kit/libs/ngx-utils/src/lib/directives/router-link-match/router-link-match.directive.spec.ts',
lint-staged:gen-tasks '/Developer/Work/SPA/ngx-starter-kit/libs/ngx-utils/src/lib/directives/ng-let/ng-let.directive.spec.ts',
lint-staged:gen-tasks '/Developer/Work/SPA/ngx-starter-kit/libs/chat-box/src/lib/services/speech-to-text.service.ts' ] } +17ms
Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running linters... [started]
Running tasks for {apps,libs}/**/*.{ts,json,md,scss} [started]
lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'npm run affected:lint -- --uncommitted --fix --parallel', 'npm run format:write -- --uncommitted', 'git add' ] +0ms
lint-staged:find-bin Resolving binary for command `npm run affected:lint -- --uncommitted --fix --parallel` +206ms
lint-staged:find-bin Binary for `npm run affected:lint -- --uncommitted --fix --parallel` resolved to `/Developer/Work/SPA/ngx-starter-kit/node_modules/.bin/npm` +3ms
lint-staged:task ✔ OS: darwin; File path chunking unnecessary +0ms
lint-staged:find-bin Resolving binary for command `npm run format:write -- --uncommitted` +0ms
lint-staged:find-bin Resolving binary for `npm` from cache +0ms
lint-staged:task ✔ OS: darwin; File path chunking unnecessary +0ms
lint-staged:find-bin Resolving binary for command `git add` +0ms
lint-staged:find-bin Binary for `git add` resolved to `/usr/local/bin/git` +1ms
lint-staged:task ✔ OS: darwin; File path chunking unnecessary +1ms
npm run affected:lint -- --uncommitted --fix --parallel [started]
lint-staged:task bin: /Developer/Work/SPA/ngx-starter-kit/node_modules/.bin/npm +0ms
lint-staged:task args: [ 'run',
lint-staged:task 'affected:lint',
lint-staged:task '--',
lint-staged:task '--uncommitted',
lint-staged:task '--fix',
lint-staged:task '--parallel',
lint-staged:task '/Developer/Work/SPA/ngx-starter-kit/libs/ngx-utils/src/lib/directives/router-link-match/router-link-match.directive.spec.ts',
lint-staged:task '/Developer/Work/SPA/ngx-starter-kit/libs/ngx-utils/src/lib/directives/ng-let/ng-let.directive.spec.ts',
lint-staged:task '/Developer/Work/SPA/ngx-starter-kit/libs/chat-box/src/lib/services/speech-to-text.service.ts' ] +0ms
lint-staged:task opts: { reject: false } +1ms
Environment
- OS:
- Node.js: 10
lint-staged
: v8.0.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:26 (4 by maintainers)
Top Results From Across the Web
affected:lint with lint-staged hangs in nx monorepo · Issue #869
I am using affected:lint with lint-staged and noticed it hangs forever when I run npx lint-staged . wonder if I am doing something...
Read more >affected:lint with lint-staged hangs in nx monorepo
I am using affected:lint with lint-staged and noticed it hangs forever when I run npx lint-staged . wonder if I am doing something...
Read more >Create an Nx Workspace with prettier, husky and lint-staged
In this lesson we create a new empty Nx Workspace by running `yarn create ... the a pre-commit hook in husky and make...
Read more >Affected - Nx
As your workspace grows, retesting all projects becomes too slow. To address this Nx implements code change analysis to get the min set...
Read more >Add env-var, lint-staged and etc. for nx workspace
Add env-var, lint-staged and etc. for nx workspace ; Add env-var. npm i --save env-var · $ · --save env-var added 1 package,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dear @iiroj , thanks for coming back with another idea. I tried your approach (i.e., moving the config to a dedicated file and not having it in the package.json).
This separate config file is used - i can see this, because i changed the glob-file-pattern (i.e., i removed the
html
type). However, it still shows the respective error.However, when digging into the
nx affected:lint
command, i found a--files
param, that takes a list of all files to be used - this can be used as a replacement for the--uncommited
.In this context, i changed your config file from above to this one here:
Note that for the
affected:lint
you need to separate the files by,
and for thegit
command by' '
. For now, this command runs as expected… I tried a commit that previously failed and it now properly commits. I will keep an eye 👀 on this 😆Thanks a lot for pointing me into the (hopefully) right direction! You’re awesome!
Enlightening! You saved my life!
Lint like flight~~~