Nez Nez
Nez Nez

Reputation: 113

How to setup lint-staged with turbo monorepo?

I have a turbo monorepo, with packages/... and apps/app-a, apps/app-b . I have set up husky pre-commit hook, which will run pnpm dlx lint-staged

I want lint-staged to run lint script from the closest to the staged file package.json file. So for example:

  1. staged foo.js from apps/app-a - it will run the lint script described in apps/app-a/package.json
  2. bar.js from apps/app-b will run lint from apps/app-b/package.json

etc.

Is that possible?

I tried to setup lintsatgedrc.json in the apps/app-a and apps/app-b folders, with

{
  "*.{ts,tsx}": ["pnpm run lint", "pnpm run check-types"]
}

But its always try to run the lint and chack-types scripts from the monorepo's root package.json.

Upvotes: 8

Views: 3614

Answers (1)

Jupi
Jupi

Reputation: 1

Just Add -- after commands

Like

 "*.{ts,tsx}": ["pnpm run lint --", "pnpm run check-types --"]

When you run turbo run lint, Turborepo will automatically execute the lint tasks for each sub-package.

Upvotes: 0

Related Questions