eslint-config
/
2.2.2
eslint-config 2.2.2
Install from the command line:
Learn more about npm packages
$ npm install @stegripe/eslint-config@2.2.2
Install via package.json:
"@stegripe/eslint-config": "2.2.2"
About this version
A forked ESLint shareable configuration that we used in our projects.
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.
This package requires ESLint Flat Configuration.
Available configurations (most relevant):
- common - Common JavaScript rules.
- typescript - For usage with TypeScript.
- modules - For usage with ES Modules.
- node - For usage within a Node.js or Bun environment.
- prettier - For code styling with Prettier (exclusive with ESLint Stylistic).
- stylistic - For code styling with ESLint Stylistic (exclusive with Prettier).
- browser - For usage within a browser environment (DOM and Web APIs).
- edge - For usage within an edge/serverless environment. For example Cloudflare Workers.
- ignores - To enable global ignores for ESLint. Needed for ESLint to ignore files that shouldn't be linted.
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"]
}])];