Questions tagged [lint-staged]
98 questions
8
votes
1 answer
How to setup lint-staged for Vue projects?
I created a new Vue3 app using the Vue CLI and selected Prettier for my linter config. I want to use commitlint, husky and lint-staged to validate commit messages and lint the code before pushing it.
What I did
Based on…
user17177048
8
votes
2 answers
GitHub desktop Husky pre-commit hook does not
I installed husky@4 and lint-staged as per many other projects (on Mac OS11). The terminal command flow git add . and git commit -m 'something' flow works fine: Husky's pre-commit hook and lint-staged commands are picked up successfully. However,…

Phil Lucks
- 2,704
- 6
- 31
- 57
8
votes
2 answers
How to bypass pre-commit hooks after fixing merge conflicts?
TLDR: git rev-parse -q --verify MERGE_HEAD errors out when NOT in a merge state. How can I get a similar command that would error out when we're IN a merge state?
Problem: when I merge master into my branch and it has conflicts, I have to manually…

Flavio Wuensche
- 9,460
- 1
- 57
- 54
7
votes
1 answer
Prettier format a json file
I have a unformatted json file that gets stored in my application with the following structure
src
/forms
/test
- abc.json
I am using husky and lint-staged to make use of prettier and linting on pre-commit. The configuration resides in my…

RRP
- 2,563
- 6
- 29
- 52
6
votes
0 answers
Pending git changes are lost when commit fails due to linting error (husky + lint-staged)
I have an Angular app using git and Visual Studio Code. I set up ESLint and am using husky to run lint-staged in a pre-commit hook, so that changes with linting errors cannot be committed.
When I first set it up, the pending changes in failed…

Roobot
- 860
- 1
- 10
- 20
6
votes
1 answer
Unstaged changes could not be restored due to a merge conflict
When I execute git commit -m "commit message" command, lint-staged shows this error:
My configuration in package.json:
"husky": {
"hooks": {
"pre-commit": "npm run validate && lint-staged"
}
},
"lint-staged": {
"*.+(js|ts|tsx)":…

Arif
- 6,094
- 4
- 49
- 81
6
votes
2 answers
How to use lint-staged in a lerna monorepo to run the same command in all packages?
I have the following root package.json:
{
"name": "project",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build",
"dev": "lerna run start --stream --parallel",
"format": "yarn prettier…
user13103906
5
votes
0 answers
lint-staged not adding files modified by prettier
I'm running lint-staged (v11.0.0) as part of my pre-commit hook through Husky (v4.3.8). My lint-staged performs eslint (v7.27.0) and Prettier (v2.3.0). However, after Prettier runs, the "prettified" files aren't added to the commit.
How can files…

Luke
- 20,878
- 35
- 119
- 178
5
votes
0 answers
How to run "stylelint --fix" with husky and lint-staged without blocking the commit
I'm using husky and lint-staged to run "stylelint --fix" on my sass files with this configuration
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git update-index --again"
}
},
"lint-staged": {
…

Alessandro Nicola
- 61
- 1
- 2
5
votes
1 answer
No Test case found Jest
I am facing a strange issue with lint-staged plugin. It was working fine earlier.
So the issue is when I run npm run test it generates the coverage report.
"test": "cross-env CI=true react-scripts test --coverage",
But when I run the same command…

Jitender
- 7,593
- 30
- 104
- 210
4
votes
1 answer
lint-staged custom config > error Command failed with exit code 1
I'm following the first example (copy/paste) of custom config file (lint-staged.config.js) for lint-staged packaged from its github README without success. I get error Command failed with exit code 1. always.
I tried this...
I have tried three…

Zyncho
- 407
- 6
- 12
4
votes
1 answer
Running `lint-staged` takes a lot of time even for a single changed file
Running npm run pre-commit takes a lot of time even if only one file has been changed.
package.json script:
"pre-commit": "lint-staged",
and lint-staged commands:
"lint-staged": {
"src/**/*.{ts,js,json}": [
"eslint…

Radu
- 83
- 1
- 8
4
votes
1 answer
How to have multiple patterns for lint-staged?
I had it match on .rb and .js files for instance.
e.g. **/*.{js,rb}
And wanted to also match on Gemfile and Rakefile for instance.

Dorian
- 7,749
- 4
- 38
- 57
4
votes
1 answer
How to correct lint-staged problems?
I´m getting an error with lint-staged trying to scan files outside 'src/**' dir, despite configuration file (below). Running eslint into console dont shows the same error (only show warnings).
Considering lint-staged is called via Husky I cant…

Paulo Gontijo
- 41
- 3
4
votes
2 answers
setting up lint-staged for jest
I have to try to set up a husky with lint-staged. Initially, I was trying to set up like the following but that does not work.
"lint-staged": {
"*.js": [
"prettier --write",
"eslint src/ --fix",
"npm run test",
"git add"
…

Jitender
- 7,593
- 30
- 104
- 210