lint-staged: Listr spinner/ticks not displaying
Description
I have been using lint-staged for a long time and never had any issues. But recently on just one of my machines, the Listr output is not displaying correctly. Instead of the nice spinners and ticks and I am getting the below output. Does anyone know what might be causing this to happen?
[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 2 files
[STARTED] *?(test|spec).{js,jsx,ts,tsx} — 0 file
[STARTED] *.{css,scss,md,html,json,yml,yaml} — 1 file
[SKIPPED] *?(test|spec).{js,jsx,ts,tsx} — no files
[STARTED] yarn pretty:fix
[SUCCESS] yarn pretty:fix
[SUCCESS] *.{css,scss,md,html,json,yml,yaml} — 1 file
[SUCCESS] package.json — 2 files
[SUCCESS] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SUCCESS] Applying modifications from tasks...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...
Debug Logs
expand to view
$ /Users/damienbutt/Projects/react-hooks/node_modules/.bin/lint-staged --debug
2022-04-26T20:13:03.026Z lint-staged:bin Running `lint-staged@12.4.0`
2022-04-26T20:13:03.027Z lint-staged:bin Options parsed from command-line: {
allowEmpty: false,
concurrent: true,
configPath: undefined,
cwd: undefined,
debug: true,
maxArgLength: null,
quiet: false,
relative: false,
shell: false,
stash: true,
verbose: false
}
2022-04-26T20:13:03.029Z lint-staged:validateOptions Validating options...
2022-04-26T20:13:03.029Z lint-staged:validateOptions Validated options!
2022-04-26T20:13:03.029Z lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`)
2022-04-26T20:13:03.030Z lint-staged:runAll Running all linter scripts...
2022-04-26T20:13:03.030Z lint-staged:runAll Using working directory `/Users/damienbutt/Projects/react-hooks`
2022-04-26T20:13:03.030Z lint-staged:resolveGitRepo Resolving git repo from `/Users/damienbutt/Projects/react-hooks`
2022-04-26T20:13:03.030Z lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`)
2022-04-26T20:13:03.030Z lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`)
2022-04-26T20:13:03.030Z lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ]
2022-04-26T20:13:03.053Z lint-staged:resolveGitRepo Resolved git directory to be `/Users/damienbutt/Projects/react-hooks`
2022-04-26T20:13:03.053Z lint-staged:resolveGitRepo Resolved git config directory to be `/Users/damienbutt/Projects/react-hooks/.git`
2022-04-26T20:13:03.053Z lint-staged:execGit Running git command [ 'log', '-1' ]
2022-04-26T20:13:03.068Z lint-staged:execGit Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only', '-z' ]
2022-04-26T20:13:03.081Z lint-staged:runAll Loaded list of staged files in git:
[ '/Users/damienbutt/Projects/react-hooks/.husky/pre-commit' ]
2022-04-26T20:13:03.082Z lint-staged:searchConfigs Searching for configuration files...
2022-04-26T20:13:03.082Z lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name' ]
2022-04-26T20:13:03.093Z lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '--others', '--exclude-standard' ]
2022-04-26T20:13:03.106Z lint-staged:searchConfigs Found possible config files: [ '/Users/damienbutt/Projects/react-hooks/package.json' ]
2022-04-26T20:13:03.106Z lint-staged:loadConfig Loading configuration from `/Users/damienbutt/Projects/react-hooks/package.json`...
2022-04-26T20:13:03.108Z lint-staged:loadConfig Successfully loaded config from `/Users/damienbutt/Projects/react-hooks/package.json`:
{
'*?(test|spec).{js,jsx,ts,tsx}': [ 'yarn lint:fix', 'yarn pretty:fix', 'yarn test' ],
'*.{css,scss,md,html,json,yml,yaml}': [ 'yarn pretty:fix' ]
}
2022-04-26T20:13:03.108Z lint-staged:validateConfig Validating config from `/Users/damienbutt/Projects/react-hooks/package.json`...
2022-04-26T20:13:03.108Z lint-staged:validateConfig Validated config from `/Users/damienbutt/Projects/react-hooks/package.json`:
2022-04-26T20:13:03.111Z lint-staged:validateConfig {
'*?(test|spec).{js,jsx,ts,tsx}': [ 'yarn lint:fix', 'yarn pretty:fix', 'yarn test' ],
'*.{css,scss,md,html,json,yml,yaml}': [ 'yarn pretty:fix' ]
}
2022-04-26T20:13:03.111Z lint-staged:searchConfigs Found 1 config files
2022-04-26T20:13:03.111Z lint-staged:groupFilesByConfig Grouping 1 files by 1 configurations
2022-04-26T20:13:03.112Z lint-staged:chunkFiles Skip chunking files because of undefined maxArgLength
2022-04-26T20:13:03.112Z lint-staged:generateTasks Generating linter tasks
2022-04-26T20:13:03.116Z lint-staged:generateTasks Generated task:
{
pattern: '*?(test|spec).{js,jsx,ts,tsx}',
commands: [ 'yarn lint:fix', 'yarn pretty:fix', 'yarn test' ],
fileList: []
}
2022-04-26T20:13:03.117Z lint-staged:generateTasks Generated task:
{
pattern: '*.{css,scss,md,html,json,yml,yaml}',
commands: [ 'yarn pretty:fix' ],
fileList: []
}
2022-04-26T20:13:03.117Z lint-staged:makeCmdTasks Creating listr tasks for commands [ 'yarn lint:fix', 'yarn pretty:fix', 'yarn test' ]
2022-04-26T20:13:03.120Z lint-staged:resolveTaskFn cmd: yarn
2022-04-26T20:13:03.120Z lint-staged:resolveTaskFn args: [ 'lint:fix' ]
2022-04-26T20:13:03.120Z lint-staged:resolveTaskFn execaOptions: {
cwd: '/Users/damienbutt/Projects/react-hooks',
preferLocal: true,
reject: false,
shell: false
}
2022-04-26T20:13:03.121Z lint-staged:resolveTaskFn cmd: yarn
2022-04-26T20:13:03.121Z lint-staged:resolveTaskFn args: [ 'pretty:fix' ]
2022-04-26T20:13:03.121Z lint-staged:resolveTaskFn execaOptions: {
cwd: '/Users/damienbutt/Projects/react-hooks',
preferLocal: true,
reject: false,
shell: false
}
2022-04-26T20:13:03.122Z lint-staged:resolveTaskFn cmd: yarn
2022-04-26T20:13:03.122Z lint-staged:resolveTaskFn args: [ 'test' ]
2022-04-26T20:13:03.122Z lint-staged:resolveTaskFn execaOptions: {
cwd: '/Users/damienbutt/Projects/react-hooks',
preferLocal: true,
reject: false,
shell: false
}
2022-04-26T20:13:03.122Z lint-staged:makeCmdTasks Creating listr tasks for commands [ 'yarn pretty:fix' ]
2022-04-26T20:13:03.122Z lint-staged:resolveTaskFn cmd: yarn
2022-04-26T20:13:03.123Z lint-staged:resolveTaskFn args: [ 'pretty:fix' ]
2022-04-26T20:13:03.123Z lint-staged:resolveTaskFn execaOptions: {
cwd: '/Users/damienbutt/Projects/react-hooks',
preferLocal: true,
reject: false,
shell: false
}
2022-04-26T20:13:03.123Z lint-staged Tasks were executed successfully!
→ No staged files match any configured task.
$ /Users/damienbutt/Projects/react-hooks/node_modules/.bin/commitlint --edit .git/COMMIT_EDITMSG
[develop 2e0965a] chore(husky): add debug flag
1 file changed, 1 insertion(+), 1 deletion(-)
✨ Done in 14.41s.
Environment
- OS: macOS Monterey
- Node.js: 16.14.2
lint-staged
: 12.4.0
Thanks,
D
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 18
- Comments: 23 (9 by maintainers)
Commits related to this issue
- fix: lint-staged coloring https://github.com/okonet/lint-staged/issues/1145 — committed to MoKhajavi75/project-template by MoKhajavi75 2 years ago
- fix: lint-staged coloring https://github.com/okonet/lint-staged/issues/1145 — committed to MoKhajavi75/project-template-cli by MoKhajavi75 2 years ago
- Add pre-commit hooks Excessive output: https://github.com/okonet/lint-staged/issues/1145 nbd — committed to mark-wiemer-org/ahkpp by mark-wiemer 2 years ago
- Engineering (#135) * Fixup Development.md * Sort package.json Using https://www.npmjs.com/package/sort-package-json 1.57.0 * Add prettierrc From mark-wiemer/vscode-helloworld * Teardow... — committed to mark-wiemer-org/ahkpp by mark-wiemer 2 years ago
I’m pretty sure it’s working fine now - here’s a screenshot of a
pre-commit
hook executing:Please note / some context:
export FORCE_COLOR=1
to my~/.huskyrc
based on the comments here etc.~/.huskyrc
Just tested this on git 2.37.1 and can confirm I’m getting pretty output in my husky pre-commit hook that runs lint-staged without having to set
FORCE_COLOR=1
or redirect output to/dev/tty
.this is the comment that fixed it for my build.
tldr; add
before running
lint-staged
in your hookI created a Draft PR that forces the
process.stdout
to be a writable stream to/dev/tty
… it feels a bit hacky but at least fixes the issue on my macOS Monterey Terminal.app.What are the possible downsides of this?
https://github.com/okonet/lint-staged/pull/1163
Hmm, after updating some dependencies in one of my projects, I’m also hitting this bug myself… Looks like
supports-color
is reporting that colors are not supported.npx lint-staged
.husky/lint-staged
git commit
, invoking husky and lint-stagedI ran into the same issue using both zsh and fish, putting
export FORCE_COLOR=1
at the top of.husky/pre-commit
fixed it for meI have a feeling this was caused by https://github.com/okonet/lint-staged/pull/1119, although I haven’t had the time to nail down why.
In our setup with husky, we now need to explicitly set
FORCE_COLOR
. There are a few of ways to do this as documented here: https://github.com/okonet/lint-staged/issues/693#issuecomment-549439481@brunolm Thanks, I think that is still an improvement to the current situation 👍
This still happens to me. Git is installed via Chocolatey
Added a note to FAQ here: https://github.com/okonet/lint-staged/pull/1200/commits/20ab7e17ce52ce0e9e0f855095bdab8e1ccd985c
After debugging, when running through
git
it seems to hit this line of code, becausestreamIsTTY === false
:https://github.com/chalk/supports-color/blob/ee88ebcfca649233bb35c9b0db226059883a77b8/index.js#L83-L85