Personal ESLint config
- No prettier
- Linting and auto fixing for the following languages:
- JavaScript
- TypeScript
- JSON
- YAML
- Linting and auto fixing in code fences in markdown files
- Linting of JSDoc/TSDoc comments
- Auto sort and group imports with auto removal of unused imports
- Auto sort keys in objects, types, interfaces, json files and yaml files
- Semicolons
- Double quotes
- 2 spaces
- No trailing commas
npm i --save-dev @schoero/eslint-config
If you use npm < 7, you need to install the peer dependencies manually.
Create a .eslintrc.json
with the following content:
{
"extends": "@schoero"
}
It is also recommended to create a .eslintignore
file with the following content:
node_modules
!/.vscode
!/.github
For automatic code formatting on save, install the ESLint extension.
To recommend the extension in your repository create a .vscode/extensions.json
with the following content:
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
To configure the extension properly, create a .vscode/settings.json
with the following content:
{
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[json]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[json5]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[jsonc]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
},
"editor.formatOnSave": false,
"eslint.validate": ["javascript", "typescript", "json", "jsonc", "json5", "yaml"],
"prettier.enable": false
}
If you want to have linting scripts, you can use something like this in the package.json
:
{
"scripts": {
"lint": "node_modules/.bin/eslint --ext .ts,.tsx,.js,.jsx,.json,.jsonc,.yml ./",
"lint:ci": "npm run lint -- --max-warnings 0",
"lint:fix": "npm run lint -- --fix"
}
}