I use husky to check JS before commit. In my package.json i have
"scripts": {
"lintStyles": "stylelint app/**/*.scss",
"fixStylesLinting": "stylelint app/**/*.scss --fix",
"lintJS": "eslint app/**/*.js",
"fixJSLinting": "eslint --fix app/**/*.js",
"precommit": "npm run lintJS"
}
It works, what i don't understand is how can i run both lintJS, lintStyles commands.
The npm-run-all CLI is installed can be installed via NPM or Yarn: npm install npm-run-all — save-dev , and once installed, it boasts three different commands, based on your needs: npm-run-all (the main command, which has documentation on all of the flags and additions you can pass in via the command line)
Husky is a very popular (1 million downloads a month) npm package that allows custom scripts to be ran against your repository. Husky works with any project that uses a package. json file. It also works out of the box with SourceTree!
to include more than one script add &&
for ex:
precommit: npm run lint:sass && npm run lint:js
This should work:
"scripts": {
"lint:scss": "stylelint app/**/*.scss",
"fixStylesLinting": "stylelint app/**/*.scss --fix",
"lint:js": "eslint app/**/*.js",
"fixJSLinting": "eslint --fix app/**/*.js",
"precommit": "npm run lint:*"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With