Skip to content

Instantly share code, notes, and snippets.

@pax-k
Last active February 1, 2023 22:25
Show Gist options
  • Save pax-k/181b5f4765321beb98616fa3a4f0b078 to your computer and use it in GitHub Desktop.
Save pax-k/181b5f4765321beb98616fa3a4f0b078 to your computer and use it in GitHub Desktop.
Husky, lint-staged, Turbo

Leveraging Turbo to speed up lint-staged.

  1. Install Husky https://typicode.github.io/husky/#/?id=yarn-2

  2. Install lint-staged https://github.com/okonet/lint-staged#installation-and-setup

  3. Install Turbo https://turbo.build/repo/docs

/.husky/pre-commit

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged --allow-empty

/.lintstagedrc

{
  "**/*+(.ts?|.tsx)": ["turbo lint:fix:staged format:staged --"]
}

/turbo.json

"//#lint:fix:staged": {
      "inputs": ["**/*.ts", "**/*.tsx"]
},
"//#format:staged": {
      "inputs": ["**/*.ts", "**/*.tsx"]
},

/package.json

{
...
  "scripts": {
    "lint:fix:staged": "eslint --fix",
    "format:staged": "prettier --write"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment