generator-chisel icon indicating copy to clipboard operation
generator-chisel copied to clipboard

Lint on commit only when relevant files changed

Open luboskmetko opened this issue 8 years ago • 5 comments

Is something like that possible? It's a bit annoying that lint CSS and lint JS run every time even when commit doesn't update any JS/CSS files. Not a high priority, though.

luboskmetko avatar Sep 08 '17 10:09 luboskmetko

Overcommit (for ruby) is doing some magic and is linting only things that you changed but i think it may not be simple to implement. Definitely would be nice to have but I agree with low priority.

jakub300 avatar Sep 08 '17 11:09 jakub300

Or maybe... https://www.npmjs.com/package/gulp-git-changed

jakub300 avatar Sep 08 '17 11:09 jakub300

Also: https://www.npmjs.com/package/gulp-gitmodified

jakub300 avatar Sep 08 '17 11:09 jakub300

you might want to check out lint-staged: https://github.com/okonet/lint-staged & husky: https://github.com/typicode/husky

When used in combination you can setup lint-staged to run various linters for whatever file types you would like by utilizing a git pre-commit hook. Both of these packages make it very simple to do.

you will need to run npm i -D lint-staged husky first, then:

You could do something like this in the package.json

"scripts": {
    "build": "gulp build",
    "build-report": "gulp build && gulp report",
    "dev": "gulp",
    "lint:js": "gulp lint-js",
    "lint:scss": "gulp lint-css",
    "start": "gulp",
    "watch": "gulp"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.js": ["npm run lint:js", "git add"],
    "*.scss": ["npm run lint:scss", "git add"]
  },

robertguss avatar Jul 17 '19 16:07 robertguss

Thanks for the tip, @robertguss!

luboskmetko avatar Jul 18 '19 07:07 luboskmetko