eslint-config-gmana
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
pnpm add eslint eslint-config-gmana prettier --dev
- Setup your project config in
eslint.config.mjs
:
import { getPresets } from 'eslint-config-gmana';
export default [
...(await getPresets(
'typescript',
'react',
'cssModules',
'tailwind',
'jest',
'cypress',
'vitest',
)),
{
},
];
- If you require globals, like browser APIs on
window
, you can add them to your config:
import globals from 'globals';
export default [
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
},
];
- To set up Prettier, add to your
package.json
:
"prettier": "eslint-config-gmana/.prettierrc.json"
- If you use TypeScript, add to your
tsconfig.json
:
"extends": "eslint-config-gmana/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:
dbaeumer.vscode-eslint
esbenp.prettier-vscode
To auto-fix errors from ESLint as well as Prettier on save, you can use the following configuration:
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}