1.4.1 • Published 11 days ago
@tools-aoeur/eslint-config v1.4.1
@tools-aoeur/eslint-config
Goals
- Find errors that are detectable with static analysis.
- Make reading code easier by providing consistent code style.
- Make writing code faster by leveraging auto fix wherever possible.
Getting started
npm install eslint @tools-aoeur/eslint-config --save-dev
- Setup your project config in
eslint.config.mjs
:
import { getPresets } from '@tools-aoeur/eslint-config';
export default [
...(await getPresets(
// Base config
'typescript', // or 'javascript'
// Optional extensions
'lodash',
'react',
'cssModules',
'jest',
'cypress',
'vitest'
)),
{
// Your custom config
}
];
- If you require globals, like browser APIs on
window
, you can add them to your config:
// eslint.config.mjs
import globals from 'globals';
export default [
// ...
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
}
];
- To set up Prettier, add to your
package.json
:
"prettier": "@tools-aoeur/eslint-config/.prettierrc.json"
- If you use TypeScript, add to your
tsconfig.json
:
"extends": "@tools-aoeur/eslint-config/tsconfig.json"
Happy linting!
Further configuration
CI integration
To validate your code in a CI pipeline, add the following to your package.json
:
"scripts": {
"lint": "eslint src && prettier src --check"
}
VSCode integration
The following two extensions are recommended:
To auto-fix errors from ESLint as well as Prettier on save, you can use the following configuration:
// settings.json (VSCode)
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
Versioning
- Patch releases are for improved documentation, fixing a rule to stop reporting false positives and internal code changes.
- Minor releases are for changes to rules that can automatically be fixed.
- Major releases happen when rules are changed that can't be fixed automatically.