motleyagency / eslint-config-motley

Motley (https://motley.fi) JavaScript/Typescript guidelines as ESLint rules with Prettier autoformatting
https://motley.fi
MIT License
6 stars 0 forks source link

Force linting of staged files #51

Closed bostrom closed 6 years ago

bostrom commented 6 years ago

Lint errors go unnoticed unless the developer has a linter enabled in the editor, an even then the developer can choose to ignore lint errors. Perhaps we could force linting of staged files?

  "lint-staged": {
    "*.{js,json,graphql,md,css,scss,less,ts}": [
+     "eslint --fix",
      "prettier --write",
      "git add"
    ]
  }
petetnt commented 6 years ago

That's fine with me, caveat is that eslint is really bad at --fix:ing things not related styles and those Prettier does much better job at. 🤷‍♂️ Not sure what the specific order should be either? For example eslint-disable-next-line easily breaks when prettier applies now lines 🤔

bostrom commented 6 years ago

Hm yes. And actually the above config won't work since it tries to run eslint on .json files for example and that will always break. So perhaps a solution is to just override the lint-staged config with your own, which could include the eslint command if desired.

50 enables this by not overwriting the lint-staged config each time the package is installed.