I have a monorepo application with a few sub-apps. I want to run the linter only for a specific app and not for the whole repo. This is the folder structure.
├── apps
│ ├── app-1
│ ├── app-2
And this is the npm scripts.
"scripts": {
"lint": "eslint --fix 'apps/$APP_NAME/**/*.{ts,tsx}' --ignore-pattern 'node_modules/'",
},
As you can see, I am trying to add some variable inside the path by command line
npm run lint APP_NAME=app-1
but it throws an error like
No files matching the pattern "apps/$APP_NAME/**/*.{ts,tsx}" were found.
What's wrong with this approach?
P.S.
In an ideal world, I would like to just run npm run lint app-1.
Use cross-env.
Install the cross-env.
npm i -D cross-env
Modify package.json to:
"scripts" {
"lint:app1": "cross-env APP_NAME=app-1 npm run lint",
"lint": "cross-env-shell eslint --fix 'apps/$APP_NAME/**/*.{ts,tsx}' --ignore-pattern 'node_modules/'"
}
Then run npm run lint:app1