Skip to content

An ESLint shareable config that I used in my projects

License

Notifications You must be signed in to change notification settings

Hazmi35/eslint-config

Repository files navigation

eslint-config

An opinionated, but sane ESLint shareable config that I used in my projects ✔

Install

npm install -D @hazmi35/eslint-config # npm
pnpm add -D @hazmi35/eslint-config # pnpm
yarn add -D @hazmi35/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:

Configuration

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

Node.js with ESM
import { common, modules, node, stylistic, ignores } from "@hazmi35/eslint-config";

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

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

export default [...common, ...modules, ...node, ...stylistic, ...typescript, ...ignores];
Usage with Prettier
import { common, modules, node, prettier, ignores } from "@hazmi35/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"]
    }
])];