ESLint Default Config
Initial Setup
- Install the package:
yarn add -DW eslint husky lint-staged prettier @neuledge/eslint-config
- Create a
.eslintrc.json
file with the following content:
{
"extends": "@neuledge"
}
- Create a
.prettierrc.json
file with the following content:
{
"singleQuote": true
}
- Add the following scripts to your
package.json
:
{
"scripts": {
"prepare": "husky install || echo \"skip husky\"",
"fix": "yarn lint:fix",
"lint": "eslint . --ext \"js,ts,mjs,cjs\"",
"lint:fix": "yarn lint --fix",
"lint:strict": "yarn lint --max-warnings 0"
}
}
- Add
lint-state
to the end of yourpackage.json
file:
{
"lint-staged": {
"*.{js,ts,mjs,cjs}": "eslint"
}
}
- Install and configure husky:
yarn prepare
yarn husky add .husky/commit-msg 'NODE_OPTIONS="--max_old_space_size=4096" npx --no-save lint-staged'
Usage
Linting
yarn lint
Fixing Linting Errors
yarn fix
Strict Linting
(Best used in CI)
yarn lint:strict