npm install --save-dev --save-exact prettier
# .prettierrc.json
echo {}> .prettierrc.json
# .prettierignore
build
coverage
REDME.md
npx prettier --write .
# check special file
prettier --write app/<your_directory>
npx prettier --check .
#package.json
{
"scripts": {
"prettier-watch": "onchange \"**/*\" -- prettier --write --ignore-unknown {{changed}}"
}
}
-
ESlint + prettier. (Link)
npm install --save-dev eslint-config-prettier
npm init @eslint/config
npx eslint <yourfile.js>
# settings.json
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript"]
-
ESlint + React. (Link)
# .editorconfig
[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 4
max_line_length = 80
npm install --save-dev husky lint-staged
npx husky install
npm set-script prepare "husky install"
npx husky add .husky/pre-commit "npx lint-staged"
# package.json
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
},
"husky": {
"hooks": {
"applypatch-msg": "echo \"[Husky] applypatch-msg\"",
"pre-applypatch": "echo \"[Husky] pre-applypatch\"",
"post-applypatch": "echo \"[Husky] post-applypatch\"",
"pre-commit": "prettier --write . && git add -A ."
}
}
"script":{
"pre-commit": "lint-staged",
}