0.0.1-alpha.2 โข Published 5 years ago
prettier-files v0.0.1-alpha.2
prettier-check
cli for quick checking and formatting prettier ๐๐ผ ๐๐ผ ๐๐ผ
require
Please install prettier
>= version 1.15.3
"peerDependencies": {
"prettier": ">=1.15.3"
},
install
npm install --save-dev prettier prettier-files
Usage
(1) adds prettierFiles attribute in package.json
package.json
adds prettierFiles attribute
...
"prettierFiles":[
"src/**/*.js*",
"src/**/*.ts*",
"src/**/*.less",
"config/**/*.js*",
"scripts/**/*.js"
],
...
(2) api
Usage: prettier-files [options] [command]
Options:
-v, --version output the version number
-h, --help output usage information
Commands:
check|-c prettier check
write|-w prettier write
check
prettier will be get prettierFiles attribute in package.json
by default
prettier-files check
you can use an array of strings through the third parameter for easy use in combination with pre-commit Hook
prettierFiles check ['path1', 'path2']
wrtie
prettier will be get prettierFiles attribute in package.json
by default
prettier-files write
you can use an array of strings through the third parameter for easy use with pre-commit Hook
prettierFiles write ['path1', 'path2']
(3) Matching rules
based on glob
. Refer to matching rules.๏ผ
pre-commit hook
Usually prettier is used with pre-commit Hook, The following examples use with husky and lint-stage
(1) install huskyใlint-staged
npm install husky lint-staged --save --dev
(2) configure package.json
"lint-staged": "lint-staged"
...
"lint-staged": {
"**/*.{js,ts,tsx,json,jsx,less}": [
"prettier-files check",
"git add"
],
"**/*.{js,jsx}": "npm run lint-staged:js"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
License
MIT license
MIT