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
Output as plain text when running lint-staged through husky #693
Comments
I have the same issue. |
I found this issue related to chalk not displaying colors in windows using husky typicode/husky#350 and seems to work for adding the
By no means the best solution, but looks to be working as a temporary fix. |
We actually set it here https://github.com/okonet/lint-staged/blob/e879b6afbd0b922b5d5e950c52c01e95a6394b29/bin/lint-staged#L5-L10 but maybe |
Checked and is set to The problem occurs when is used with Husky.
|
@carlocorradini Thanks for testing this! I didn't have time to look into the suggestions myself. In the meantime I found this issue: typicode/husky#350. Here two ways are mentioned to enable colors for Husky output: Option 1: Create file # ~/.huskyrc
export FORCE_COLOR=1 Option 2: Add "husky": {
"hooks": {
"pre-commit": "env FORCE_COLOR=1 node ./node_modules/lint-staged/bin/lint-staged -r"
}
} Both options worked for me and I now have colors in the output. This is great since it makes the output more readable. However, the output from lint-staged is still being rendered as plain, static text: When running Any ideas if this can be solved as well? From what I can tell the animations are the output of listr but I'm unsure why the issue occurs. |
Same issue here. When running lint-staged solo, colors run normally, but when running through husky, no colors.. |
Hello, we currently try to force colors in the cli here: It would be helpful if somebody could debug the value of Additionally, if manually setting it to |
Looking at listr2's code here, it seems me might also have to override |
Interesting. While doing a git commit in Powershell I get plain text and the debug values within
When calling lint-staged directly, I get formatted output and the debug values are:
If I hardcode |
Added this to my package.json and this worked for me-
|
🎉 This issue has been resolved in version 12.3.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
First: confirming that it works Thank you for this release! Generally this seems to do the trick for Powershell 7.2.2 on Windows. When I run this command it works perfectly
Breaks as part of commit-hook When running as part of a commit-hook however it no longer seems to work. I have tested two variants: Variant 1: simply running it from the hook Husky pre-commit hook prevents lint-staged from outputting any colors; except for some specific ones related to the failure; or lint-staged doesn't detect that colors can be used correctly, however you want to put it. The commit hook
Variant 2: using FORCE_COLOR When I add an export with The commit hook
The output (truncated to preventing spam) Other notes Some lines in the first variant seem to already duplicate over multiple lines, so I'm not 100% sure that it's color related. Any tips on how to debug the issue? |
So, I don't understand if it has been solved or not. |
Same problem: [STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 3 files
[STARTED] **/*.{js,md,scss} — 1 file
[STARTED] prettier --write
[SUCCESS] prettier --write
[SUCCESS] **/*.{js,md,scss} — 1 file
[SUCCESS] package.json — 3 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...
[main 564ef05] test: lint-staged emoji work in konsole
2 files changed, 3 insertions(+), 3 deletions(-) Env: > node --version
v16.14.2
> npm --version
8.7.0
> cat package.json
"devDependencies": {
"husky": "^7.0.4",
"lint-staged": "^12.3.8",
"prettier": "2.6.2"
},
"prettier": {
"$schema": "https://json.schemastore.org/prettierrc",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf"
},
"lint-staged": {
"**/*.{js,md,scss}": "prettier --write"
}, |
I too have run into this same issue. It's unfortunate because the lint-staged format is pretty awesome, but triggered through Husky, it gets turned to plaintext. Forcing colors causes the output to post over and over for any update instead of updating in place. Powershell 5 1 19041 1320 |
Same issue for me :( |
I also have the same issue with: |
Same issue here: |
same question |
Same issue since last major upgrade. Forcing colors will create the problem mentioned by @webbertakken. Removing export FORCE_COLOR=1 will output the plain "log style" format |
still happens to me. I am on the latest version of both and using PowerShell in windows terminal. |
Latest MacOS, zsh, node 16, husky 8, lint-staged 12. Doesn't output colors when run through husky. |
Same problem |
same issue on MacOS Monterey 12.4 no colours, no animation, just status in plain text inside square brackets e.g. "[STARTED]", "[SUCCESS]", .etc |
This issue is already closed. Let's keep the discussion in #1145, or alternatively in typicode/husky#968. To me this looks like an issue not directly caused by |
I'm seeing the same issue as described awebbertakken where it looks like the console output is appended instead of replaced. If you look at the loading icon in front of "# Preparing lint-staged...", every new occurence is +1 frame. I'm on windows 11 using VS Code and Powershell terminal
with config:
|
It same problem here:
The error occurs in any Terminal: iterm2, Mac terminal, etc. |
For anyone landing here: this issue seems to be from neither lint-staged nor husky, and a pretty good workaround is already found. |
I've managed to fix the issue by downgrading lint-staged from 13.x to 12.x |
The issue is still present and the quoted fix is still valid. |
Description
When using lint-staged through a pre-commit hook with Husky, the output is shown as plain text as such:
When I run lint-staged on the command line, the output is fine:
I'm unsure what's causing this as I've tried it with both Powershell and Git Bash. Is it because of Husky or perhaps Git? I would like to have pretty output when committing.
Steps to reproduce
My config
lint-staged.config.js
:My Husky config in
packages.json
:Debug Logs
expand to view
Environment
lint-staged
: v9.2.1The text was updated successfully, but these errors were encountered: