Skip to content

An ESLint shareable configuration that we used in our projects.

License

Notifications You must be signed in to change notification settings

stegripe/eslint-config

Repository files navigation

eslint-config

A forked ESLint shareable configuration that we used in our projects.

Install

npm install -D @stegripe/eslint-config # npm
pnpm add -D @stegripe/eslint-config # pnpm
yarn add -D @stegripe/eslint-config # yarn

This package has the required dependency installed automatically by peer dependencies by default on npm v7+, pnpm, or yarn. Install them manually if not.

Usage

This package requires ESLint Flat Configuration.

Available configurations (most relevant):

Configuration

Create an eslint.config.js file in the root of your project and add the following code:

Node.js with CJS
module.exports = (async () => {
    const { common, node, stylistic, ignores } = await import("@stegripe/eslint-config");

    return [...common, ...node, ...stylistic, ...ignores];
})();
Node.js with TypeScript
import { common, modules, node, stylistic, typescript, ignores } from "@stegripe/eslint-config";

export default [...common, ...modules, ...node, ...stylistic, ...typescript, ...ignores];
Node.js with ESM
import { common, modules, node, stylistic, ignores } from "@stegripe/eslint-config";

export default [...common, ...modules, ...node, ...stylistic, ...ignores];
Usage with Prettier
import { common, modules, node, prettier, ignores } from "@stegripe/eslint-config";

// Prettier must not be used with stylistic config, because it will conflict with each other.
export default [...common, ...modules, ...node, ...prettier, ...ignores];
Extending rules

Extending rules using the extend function is recommended.

import { common, extend, modules, node, stylistic, typescript, ignores } from "./index.js";

export default [...common, ...modules, ...node, ...stylistic, ...ignores, ...extend(typescript, [{
    rule: "typescript/no-unnecessary-condition",
    option: [
        "warn",
        {
            allowConstantLoopConditions: false
        }
    ]
    // or
    option: ["off"]
}])];