This project have presets for ESLint which I use in private projects:
@javiermaestre/eslint-config/a11y
- Accessibility rules from eslint-plugin-jsx-a11y@javiermaestre/eslint-config/core
- ESLINT base config from eslint-config-airbnb@javiermaestre/eslint-config/react
- Based on React rules ofAirbnb
@javiermaestre/eslint-config/react-hooks
- Based on React Hooks rules ofAirbnb
@javiermaestre/eslint-config/react-typescript
- Based on @typescript-eslint/eslint-plugin
Install as a DEV dependency
yarn add --dev @javiermaestre/eslint-config
npm install --D @javiermaestre/eslint-config
Extend configs creating a .eslintrc.js
or eslintrc.json
file on your project:
// eslintrc.js
module.exports = {
extends: [
'@javiermaestre/eslint-config/core',
'@javiermaestre/eslint-config/react',
'@javiermaestre/eslint-config/react-hooks',
'@javiermaestre/eslint-config/react-typescript'
]
};
// eslintrc.json
{
"extends": ["@javiermaestre/eslint-config/core", "@javiermaestre/eslint-config/react-typescript"]
}
Also, you can override and customise rules:
- Set the config properties of ESLINT, like
env
parserOptions
, or others as you like (ESLINT documentation
) - Override specific rules for your project
This are configs ready to use:
- Config for JS
// eslintrc.js
module.exports = {
extends: ['@javiermaestre/eslint-config/core']
};
- Config for Typescript
// eslintrc.js
module.exports = {
extends: ['@javiermaestre/eslint-config/typescript']
};
- Config for React
// eslintrc.js
module.exports = {
extends: [
'@javiermaestre/eslint-config/react' // React package extends from /core
]
};
- Config for React with Typescript
// eslintrc.js
module.exports = {
extends: [
'@javiermaestre/eslint-config/react-typescript' // React Typescript package extends from /react and /core
]
};
- Config for React with Typescript and Hooks
// eslintrc.js
module.exports = {
extends: [
'@javiermaestre/eslint-config/react-typescript', // React Typescript package with Hooks extends from /react and /core
'@javiermaestre/eslint-config/react-hooks'
]
};
The plugin is ready to work with:
- Prettier - Adding a
.prettierrc
file - Editorconfig - Adding a
.editorconfig
file
You can override the settings on this files
- For report
eslint --ext .js,.jsx .
- For auto fixing
eslint --ext .js,.jsx . --fix
Add support for:
// for Node.js projects
'@javiermaestre/eslint-config/node',
// for Angular projects
'@javiermaestre/eslint-config/angular',
...