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

The recommended configuration is catered for TypeScript, and enforces stricter types through explicit return types and no any, amongst other rules. Additionally, the configuration emphasizes 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 Severity Notes
Indent: Tabs ⚠️ Warn
JSDoc: Check tag names ⚠️ Warn
JSDoc: No undefined types ⚠️ Warn
JSDoc: Require JSDoc ⚠️ Warn
TypeScript: Explicit function return types ⚠️ Warn Disabled for JavaScript, tests, and mock files.
TypeScript: Explicit member accessibility ⚠️ Warn No public required constructor.
TypeScript: Member ordering ⚠️ Warn Grouped by type and then access, and ordered alphabetically.
TypeScript: Sort type constituents ⚠️ 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