ESLint Shared Configuration

Packages maintained by ESL Team often use ESLint to ensure code quality and consistency. To simplify the process of configuring ESLint for these packages, we have developed a shared ESLint configuration. This configuration is designed to be used as a base for ESLint configuration in projects that use ESL package, or decide to follow ESL source code style.

Installation

To use ESL shared ESLint configuration, you need to install it as npm package:

npm install --save-dev @exadel/eslint-config-esl

Ensure that you have the ESLint package of version 9.0.0 or higher, shared configuration is distributed only as flat ESLint config.

Once installed, the configuration needs to be added in eslint configuration file:

// Import only configs you need
import {lang, base, codestyle, medium, strict} from '@exadel/eslint-config-esl';

export default [
    // Default lang (parsers) configs, if required
    //...lang.js,
    //...lang.ts,
        
    // ESL ESLint configuration of your choice
    ...strict // or medium, or base, or codestyle   
    // Note: recommended sets of eslint / typscript-esint are included in base, medium and strict config.     
        
    // ESLint user configuration ...
];

Please note '@exadel/eslint-config-esl' is an ESM-only package. You either need to use ESM in your project or run eslint independently with .mjs configuration file.

Configuration

ESL Shared ESLint Configuration is split into several configurations/bunches:

The base ruleset recommended for consumers to have basic code checks similar to ESL source code. The codestyle ruleset is recommended for projects that want to follow ESL code style. The medium ruleset is a shortcut for projects that want to have both basic and code style checks. The strict ruleset is recommended for projects that completely follow ESL code style and want to have the most restrictive checks.

Default lang (parsers) configs

ESL Shared ESLint Configuration includes default lang (parsers) configs for JavaScript and TypeScript.

Feel free to extend or default them manually.

Default JavaScript parser config:

const js = {  // lang.js
    files: ['**/*.js', '**/*.mjs'],
    languageOptions: {
        ecmaVersion: 2017,
        sourceType: 'module',
        globals: {
            ...globals.browser,
            ...globals.node
        }
    }
};

Default TypeScript parser config:

const ts = { // lang.ts
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
        parser: tsParser, // @typescript-eslint/parser
        ecmaVersion: 2017,
        sourceType: 'module',
        parserOptions: {
            projectService: true
        },
        globals: {
            ...globals.browser
        }
    }
};

Inner Plugins

ESL Shared ESLint Configuration includes several inner plugins that are used to provide additional rules and configurations for ESLint. Here is the list of included plugins and their ESLint aliases:

All mentioned plugins are direct dependencies of @exadel/eslint-config-esl package, you don't need to install them separately.