Skip to content

elgatosf/eslint-config

Repository files navigation

@elgato/eslint-config

ESLint configuration used by Elgato projects.

@elgato/eslint-config npm package Join the Marketplace Makers Discord Elgato homepage

Installation

npm install @elgato/eslint-config --save-dev

Usage

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.

Configuration

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.

Extends

  • JSDoc recommended
  • ESLint recommended
  • TypeScript ESLint recommended

Rules

Rule Recommended Strict Notes
Indent: Tabs ⚠️ Warn ⚠️ Warn
JSDoc: Check tag names ⚠️ Warn ⚠️ Warn Additional tags: csspart, cssproperty, jest-environment, slot
JSDoc: No undefined types ⚠️ Warn ⚠️ Warn
JSDoc: Require JSDoc ⚠️ Warn ⚠️ Warn
JSDoc: Require Returns ⚠️ Warn ⚠️ Warn Disabled for getters.
TypeScript: Explicit function return types ✅ Off ⚠️ Warn Disabled for JavaScript, tests, and mock files.
TypeScript: Explicit member accessibility ⚠️ Warn ⚠️ Warn No public required constructor.
TypeScript: Member ordering ⚠️ Warn ⚠️ Warn Grouped by type and then access, and ordered alphabetically.
TypeScript: Sort type constituents ⚠️ Warn ⚠️ Warn

Additionally, the following rules are disabled for test and mock files:

  • TypeScript: No explicit any
  • TypeScript: No require imports

Variants

  • Mocks and tests

    • Allow any and require.
    • Do not require explicit return types.

Ignored

  • .github/
  • bin/
  • dist/
  • node_modules/

Member Ordering

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)

Overrides

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.

About

ESLint configuration used by Elgato projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •