Shared ESLint configuration for Lemontech products.
- Install
@5rabbits/eslint-configand its dependencies:
$ export PKG=@5rabbits/eslint-config && npm info $PKG peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add --dev $PKG-
If you have an
.eslintrcfile, add"extends": ["@5rabbits"]. -
If you don't have an
.eslintrcfile, create it on the root of your project:
$ echo '{\n "extends": ["@5rabbits"]\n}' > .eslintrc-
Add a
lintscript to yourpackage.json:{ "scripts": { "lint": "eslint . --ext .js,.jsx" } } -
Run with
yarn lintto check the entire project.
If the projects uses prettier (recommended), install eslint-config-prettier and append "prettier" to the .eslintrc extends array.
You can use husky and lint-staged to lint the changed files before commiting. Example:
// package.json
{
"lint-staged": {
"*.{js,jsx}": ["eslint"]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}If the changes causes lint errors the commit will fail until you fix them.
Use eslint-loader to automatically lint files on webpack builds.
Use rollup-plugin-eslint to automatically lint files on rollup builds.