In the interest of DRY and Code formatting we want to define one format across all our applications
Assumes you have a working node project (ie, package.json
exists) with code in ./src/
yarn add eslint-config-madecomfy --dev
touch .eslintrc
{
"extends": [
"madecomfy"
]
}
...
"scripts": {
"build": "webpack",
"lint": "eslint src"
},
...
yarn lint
The following steps will prevent badly formatted code from being pushed to remote.
yarn add husky lint-staged --dev
...
"scripts": {
"build": "webpack",
"lint": "eslint src",
"precommit": "lint-staged"
},
"lint-staged": {
"src/**/*.{js,jsx}": [
"eslint --fix",
"git add"
]
}
...