Skip to content

creativewave/eslint-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

How rules are selected?

The following conventions apply for selecting rules:

  • they must not already be included in eslint:recommended or plugin:[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.