1.1.0 • Published 5 years ago
@javiermaestre/eslint-config v1.1.0
ESLint configs
This project have presets for ESLint which I use in private projects:
Available configs
@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
Install as a DEV dependency
yarn add --dev @javiermaestre/eslint-config
npm install --D @javiermaestre/eslint-configExtend
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
envparserOptions, or others as you like (ESLINT documentation) - Override specific rules for your project
Default configs
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'
]
};Extra configuration
The plugin is ready to work with:
- Prettier - Adding a
.prettierrcfile - Editorconfig - Adding a
.editorconfigfile
You can override the settings on this files
Run linter
- For report
eslint --ext .js,.jsx .- For auto fixing
eslint --ext .js,.jsx . --fixNext steps
Add support for:
// for Node.js projects
'@javiermaestre/eslint-config/node',
// for Angular projects
'@javiermaestre/eslint-config/angular',
...