Prettier shareable configuration for my Javascript based projects (Web and Mobile)
npm install --save-dev prettier-config-kbshl
.prettierrc.js
module.exports = require('prettier-config-kbshl');
.prettierignore
Copy and paste the following snippet:
### Node ###
node_modules
**/package.json
**/package-lock.json
### Builds ###
dist
coverage
build
### VSCode ###
.vscode
.history
### Titanium Mobile ###
Resources
app/widgets
./i18n
./platform
or do something like this:
cat ./node_modules/prettier-config-kbshl/.prettierignore >> .prettierignore
package.json
e.g.
...
"scripts": {
"format": "prettier --write \"src/**/*.+(js|ts|vue|json)\""
}
...
I recommend to use Prettier together with husky and lint-staged as a pre-commit
git hook.
npm install --save-dev husky lint-staged
package.json
e.g.
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*.+(js|ts|vue|json|css|sass|less|graphql|yml|yaml|scss|md)": [
"prettier --write",
"git add",
]
}
...
MIT © Konstantin Büschel