Skip to content
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

Commits unfixed line from partly staged file #12

Open
oluckyman opened this issue Jun 23, 2017 · 1 comment
Open

Commits unfixed line from partly staged file #12

oluckyman opened this issue Jun 23, 2017 · 1 comment

Comments

@oluckyman
Copy link

// 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",
@motiz88
Copy link
Owner

motiz88 commented May 20, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants