eslint-config-semipretty
v6.0.0
Published
An ESLint config combining semistandard and prettier
Downloads
59
Readme
eslint-config-semipretty
An ESLint config combining semistandard and prettier
Installation
- Run
npx install-peerdeps --dev eslint-config-semipretty
Setup
- Create an
.eslintrc.js
file in the root of your project, with the following contents:
module.exports = {
extends: ['semipretty']
};
- Create an
.eslintignore
file in the root of your project, to exclude all JavaScript files that do not need to be linted, such as generated build files and third party modules. For most projects, the simplest approach is to just copy the contents of your.gitignore
file, e.g.:
build/
logs/
node_modules/
- Add
lint
andlint-fix
scripts to thescripts
object in yourpackage.json
:
"scripts": {
"lint": "eslint .",
"lint-fix": "eslint . --fix"
}
Bonus: Automatically lint files on commit
husky
allows you run commands automatically when Git events occur, such as when code is committed. lint-staged
ensures that only new and modified files are linted, to that the process is as fast as possible.
Install
husky
: runnpm install --save-dev husky lint-staged
Add the
lint-staged
andhusky
objects to yourpackage.json
:
"scripts": {
"lint": "eslint .",
"lint-fix": "eslint . --fix"
},
"lint-staged": {
"*.js": ["eslint --fix", "git add"]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
If you're using React
- Install
eslint-plugin-react
: runnpm install --save-dev eslint-plugin-react
- In your
.eslintrc.js
file, add the plugin and extend the default configuration, e.g.
module.exports = {
extends: ['semipretty', 'plugin:react/recommended'],
plugins: ['react']
};
If you're using Jest
- Install
eslint-plugin-jest
:npm install --save-dev eslint-plugin-jest
- In your
.eslintrc.js
file, add the plugin and extend the default configuration, e.g.
module.exports = {
extends: ['semipretty', 'plugin:jest/recommended'],
plugins: ['jest']
};
If you're using experimental JavaScript features
If you are using experimental JavaScript features such as class properties, you may encounter parsing errors which can be fixed by adding babel-eslint
.
- Install
babel-eslint
: Runnpm install --save-dev babel-eslint
- Set
babel-eslint
as the parser in your.eslintrc.js
file, for example:
module.exports = {
extends: ['semipretty'],
parser: 'babel-eslint'
};