npm install @elgato/eslint-config --save-dev
Create an eslint.config.js file at the root of your project.
// eslint.config.js
import { config } from "@elgato/eslint-config";
export default config.recommended;Then add a linting script to your package.json file.
{
"scripts": {
"lint": "eslint --max-warnings 0"
}
}Finally, to test everything is working run npm run lint.
There are two configurations available:
- Recommended —
config.recommended - Strict —
config.strict(stricter type enforcing)
All configurations are tailored for TypeScript, with the strict configuration enforcing stricter types through explicit return types. Additionally, all configurations emphasize the importance of well-documented code (jsdocs) and encourages structured code in the form of member ordering.
- JSDoc recommended
- ESLint recommended
- TypeScript ESLint recommended
| Rule | Recommended | Strict | Notes |
|---|---|---|---|
| Indent: Tabs | |||
| JSDoc: Check tag names | Additional tags: csspart, cssproperty, jest-environment, slot |
||
| JSDoc: No undefined types | |||
| JSDoc: Require JSDoc | |||
| JSDoc: Require Returns | Disabled for getters. | ||
| TypeScript: Explicit function return types | ✅ Off | Disabled for JavaScript, tests, and mock files. | |
| TypeScript: Explicit member accessibility | No public required constructor. |
||
| TypeScript: Member ordering | Grouped by type and then access, and ordered alphabetically. | ||
| TypeScript: Sort type constituents |
Additionally, the following rules are disabled for test and mock files:
- TypeScript: No explicit
any - TypeScript: No
requireimports
-
Mocks and tests
- Allow
anyandrequire. - Do not require explicit return types.
- Allow
.github/bin/dist/node_modules/
Members of a class should be grouped by type and then by access, and ordered alphabetically. The ordering is as follows:
Type Order
- Fields
- Constructors
- Signatures / call signatures
- Properties (get / set)
- Methods
Access Order
- Public (static / abstract / regular)
- Protected (static / abstract / regular)
- Private (static / abstract / regular)
Configuration settings can be overriden using the defineConfig helper function from ESLint, extending @elgato/eslint-config, and then defining your preferred settings.
// eslint.config.js
import { defineConfig } from "eslint/config";
import { config } from "@elgato/eslint-config";
export default defineConfig([
{
extends: [export default config.recommended],
// Anything from here will override @elgato/eslint-config
rules: {
"no-unused-vars": "warn",
},
},
]);Learn more about overriding settings.