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-compatis required for@cdoublev/eslint-config/browserand warns against the use of unsupportedbrowserinterfaces (these warnings can be muted by listing the corresponding interfaces insettings.polyfillsin the ESLint configuration file of the project)eslint-plugin-nodeis required for@cdoublev/eslint-config/nodeeslint-plugin-reactandeslint-plugin-react-hooksare required for@cdoublev/eslint-config/reacteslint-plugin-jestis 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:recommendedorplugin:[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.