git-exec-and-restage
git-exec-and-restage copied to clipboard
Commits unfixed line from partly staged file
// fully.js
console.info('fully staged and missing semicolon')
// partly.js
console.info('staged part is missing semicolon')
console.info('unstaged part has no errors');
After commit I have these changes committed:
// fully.js
console.info('fully staged and missing semicolon');
(the missing semicolon is fixed)
// partly.js
console.info('staged part is missing semicolon')
(what was partly staged is committed but not fixed)
The expected behavior: fix and commit fully staged files and do not commit partly staged files with lint errors.
My package.json
"scripts": {
"precommit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx}": [
"git-exec-and-restage eslint --fix --"
]
},
"devDependencies": {
"git-exec-and-restage": "^1.0.1",
"husky": "^0.14.0",
"lint-staged": "^4.0.0",
@oluckyman I realise it's been a long time, but is there any chance you can elaborate on the behaviour you're seeing here? Particularly, I'm assuming partly.js
is actually fixed in your working copy but not restaged. Right? If so, I think it's correct.
git-exec-and-restage
aims to minimise the need to manually stage changes, but stays out of your way if you're partially staging files. My recommendation (and the scenario git-exec-and-restage
assumes) is that you check git status
after committing partially staged files, see the unstaged changes from linting, and amend your commit as you see fit.