0.10.3 • Published 7 months ago
@cdoublev/eslint-config v0.10.3
ESLint configuration
How to use a configuration:
Append its identifier to the extends
property of the ESLint configuration file:
@cdoublev/eslint-config
(extended by all configurations below): to lint (ES6+) files executed anywhere@cdoublev/eslint-config/node
: to lint files executed in NodeJS@cdoublev/eslint-config/browser
: to lint files executed in a browser@cdoublev/eslint-config/jest
: to lint files executed in Jest@cdoublev/eslint-config/react
: to lint files executed in React
For example, in a React application rendered server side and tested with Jest:
// .eslintrc.js
module.exports = {
extends: ['@cdoublev/eslint-config'],
overrides: [
{
files: ['__mocks__/**/*.js', '__tests__/**/*.js'],
extends: ['@cdoublev/eslint-config/node', '@cdoublev/eslint-config/jest'],
},
{
files: ['server/**/*.js'],
extends: ['@cdoublev/eslint-config/node'],
},
{
files: ['src/**/*.js'],
extends: ['@cdoublev/eslint-config/react'],
},
],
}
Optional dependencies:
The following dependencies may be required depending on the configuration.
eslint-plugin-compat
is required for@cdoublev/eslint-config/browser
and warns against the use of unsupportedbrowser
interfaces (these warnings can be muted by listing the corresponding interfaces insettings.polyfills
in the ESLint configuration file of the project)eslint-plugin-node
is required for@cdoublev/eslint-config/node
eslint-plugin-react
andeslint-plugin-react-hooks
are required for@cdoublev/eslint-config/react
eslint-plugin-jest
is required for@cdoublev/eslint-config/jest
How rules are selected?
The following conventions apply for selecting rules:
- they must not already be included in
eslint:recommended
orplugin:[plugin-name]/recommended
- they must be as few as possible to detect errors
- they must be otherwise related to spacing, line breaks, code clarity, and (performance) optimization
- they must not prevent code clarity
- they must be widely accepted by the JS community
Configuring a linter to detect as many errors as possible is often counterproductive: the runtime and tests are already responsible for this.
This document provides some comments about each rule. If a rule exists in this document and is not activated, it will never be.