I am working on a React monorepo and I have the below scripts in the root package.json
:
"scripts": {
"build": "lerna run build",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
}
},
lint-staged.config.js
module.exports = {
'**/*.*': 'yarn build',
};
When I commit the code, the commit fails with the below error:
✖ yarn build:
ERR! lerna Unknown arguments: /Users/xyz/lint-staged.config.js, /Users/xyz/package.json
error Command failed with exit code 1.
$ lerna run build /Users/xyz/lint-staged.config.js /Users/xyz/package.json
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky > pre-commit hook failed (add --no-verify to bypass)
In the monorepo packages folder, the package.json
contains the scripts as below:
package/webApp/package.json
"scripts": {
"build": "run-s clean compile",
"clean": "rm -rf *.tsbuildinfo & rm -rf build && rm -rf tmp",
"compile": "run-p compile:*",
}
Can't we run the build command in lint-staged or is something missing in my implementation?
Thanks