Skip to content

Instantly share code, notes, and snippets.

@DanielKucal
Last active March 24, 2021 05:16
Show Gist options
  • Save DanielKucal/600792c15fd0bf13d17be401906db5ab to your computer and use it in GitHub Desktop.
Save DanielKucal/600792c15fd0bf13d17be401906db5ab to your computer and use it in GitHub Desktop.
Run tslint in pre-commit with good performance and auto fixer

Fast lint with autofixer

for pre-commit hook

In order to run linter in a pre-commit hook you can check changed files only for performance reasons.

package.json:

{
  "scripts": [
    "fastlint": "git diff --cached --name-only | grep .ts$ |  xargs -L1 \"./node_modules/.bin/tslint\" --fix"
  ],
  "pre-commit": [
    "fastlint"
  ]
}

Remove the "--fix" if you do not want to auto fix files.

Requirements: pre-commit installed (npm i pre-commit --save-dev)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment