Run linter in a subdirectory
See original GitHub issueOur monorepo has two relatively separate projects in it, with their own Prettier config in project-A
and project-B
. I’m looking for a way to do something like this:
"lint-staged": {
"project-A/**/*.js": [
"cd project-A && prettier --check"
],
"project-B/**/*.js": [
"cd project-B && prettier --check"
],
}
(Prettier needs to have a working directory set to either project-A
or project-B
to pick up the right ignore & config files.)
This doesn’t work as it resolves to something like this:
lint-staged:task bin: /usr/bin/cd +8ms
lint-staged:task args: [ 'project-A',
lint-staged:task '&&',
lint-staged:task 'yarn',
lint-staged:task 'prettier',
lint-staged:task '--check',
lint-staged:task '/Users/borekb/example/project-A/index.js' ] +0ms
A workaround is to create npm scripts like this:
"scripts": {
"prettier-A": "cd project-A && prettier --check",
"prettier-B": "cd project-B && prettier --check"
},
"lint-staged": {
"project-A/**/*.js": [ "yarn prettier-A" ],
"project-B/**/*.js": [ "yarn prettier-B" ]
}
Is there a built-in way to run lint-staged in a subdirectory / subfolder?
(We’re using lint-staged@8.1.15.)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Lint Staged does not access subfolders
It seems like your file pattern string in .lintstagedrc.json is wrong. Try remove dot before bracket and put it before each file extension ......
Read more >Using Husky Git Hooks and Lint-Staged With Nested Folders
Lint -staged allows you to run code against your staged git files to automate the tedious part of your workflows, such as formatting...
Read more >Running golangci-lint run for various different files
Hey when i run golangci-lint run app/main.go utils/db/db.go i get an error stating `named files must all be in one directory golang` why...
Read more >ESLint | AppCode Documentation
Configure linting scope · Open the Preferences dialog ( ⌃ ⌥ S ), go to Languages & Frameworks | JavaScript | Code Quality...
Read more >Ignoring Code - ESLint - Pluggable JavaScript Linter
When ESLint is run, it looks in the current working directory to find a .eslintignore file before determining which files to lint. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another way of working around this is to use yarn workspaces. Then you can basically run:
(Replying here since this thread pops up on web searches)
Feel free to re-open this issue if that’s not good enough!