-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[turborepo] Using turbo scripts with lint-staged, .husky and ESLint #3364
Comments
I'm guessing that lint-staged is calling
turbo interprets that last argument as a task name, which it isn't. Try changing your {
"*.{js,ts,tsx}": ["npm run format", "npm run lint --"],
"*.json": ["npm run format"]
} (notice the extra Ultimately you're trying to produce this command: https://turbo.build/repo/docs/reference/command-line-reference#turbo-run-task |
Great, now it works. Adding the {
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev --parallel",
- "lint": "turbo run lint",
+ "lint": "turbo run lint --",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky install"
},
} |
Great! Glad it worked out @pt232! |
Are you all sure it work? It does not throw error now, BUT the range is not scoped as lint-staged, it's command effect on ALL files in you moorepo! |
And what's worse, these config and ignore files in every project of monorepo cannot effect on their own project now |
Can confirm this wont fix, will behave the same as calling your lint script directly from the git hook without lint-staged |
Unfortunately not working well, see vercel/turborepo#3364
Added |
My solution, which works great: Package.json:
.lintstagedrc:
pre-commit:
I guess it bypasses turbo, but as it only lints and formats staged files it's more than fine. |
@Scooter1337 's solution still threw me errors as I didn't have an eslint config in project root. Found a solution here - https://nitpum.com/post/lint-staged-eslint-monorepo/ The approach involves adding a .lintstagedrc config in each package:
With this setup, lint-staged picks up the nearest config based on the staged file, also following the ESLint config in that directory. |
it worked for me |
What version of Turborepo are you using?
1.7.0
What package manager are you using / does the bug impact?
npm
What operating system are you using?
Windows
Describe the Bug
I would like to use
turbo
scripts (liketurbo run lint
) in combination with lint-staged. However, I get the following error message when linting:index.tsx in this case is the file where I made changes for the commit.
If I add the changed file to the turbo.json file, then it works. But I guess that's not the point. 😀 Maybe this problem is also related to lint-staged rather than turborepo.
By the way: other npm scripts (like
npm run format
) run without errors.Thanks for your help!
Expected Behavior
I would have expected to be able to run simple
turbo
scripts. But maybe the whole thing is not possible at all.To Reproduce
Run the following commands to reproduce this issue:
npx lint-staged --concurrent false
to the .husky/pre-commit hookI have the following package.json:
And the following turbo.json:
Reproduction Repo
No response
The text was updated successfully, but these errors were encountered: