From 0549d94c9c441c3fbfb7e3e11bc39630536aea69 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Wed, 24 Mar 2021 17:15:46 +0100 Subject: [PATCH] Define Extends --- src/extends/eslint.d.ts | 4 ++++ src/extends/index.d.ts | 14 ++++++++++++++ src/index.d.ts | 8 +++++++- src/utility-types.d.ts | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/extends/eslint.d.ts create mode 100644 src/extends/index.d.ts create mode 100644 src/utility-types.d.ts diff --git a/src/extends/eslint.d.ts b/src/extends/eslint.d.ts new file mode 100644 index 00000000..35854af6 --- /dev/null +++ b/src/extends/eslint.d.ts @@ -0,0 +1,4 @@ +/** + * Eslint extensions. + */ +export type EslintExtensions = 'eslint:recommended' | 'eslint:all'; diff --git a/src/extends/index.d.ts b/src/extends/index.d.ts new file mode 100644 index 00000000..4e89999d --- /dev/null +++ b/src/extends/index.d.ts @@ -0,0 +1,14 @@ +import type { LiteralUnion } from '../utility-types'; +import type { EslintExtensions } from './eslint'; + +/** + * All known extensions. + */ +export type KnownExtensions = LiteralUnion; + +/** + * Extending Configuration Files. + * + * @see [Extends](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files) + */ +export type Extends = KnownExtensions | Array; diff --git a/src/index.d.ts b/src/index.d.ts index 0d2d8b0c..64e3afa0 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,4 +1,5 @@ import type { Environments } from './env'; +import type { Extends } from './extends'; import type { Overrides } from './overrides'; import type { ParserOptions } from './parser-options'; import type { Rules } from './rules'; @@ -16,7 +17,12 @@ export interface EslintConfig { * @see [Environments](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments) */ env?: Environments; - extends?: string[]; + /** + * Extending Configuration Files. + * + * @see [Extends](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files) + */ + extends?: Extends; parser?: string; parserOptions?: ParserOptions; plugins?: string[]; diff --git a/src/utility-types.d.ts b/src/utility-types.d.ts new file mode 100644 index 00000000..678a1294 --- /dev/null +++ b/src/utility-types.d.ts @@ -0,0 +1,6 @@ +/** + * A literal type that supports custom further strings but preserves autocompletion in IDEs. + * + * @see [copied from issue](https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609) + * */ +export type LiteralUnion = T | (U & { zz_IGNORE_ME?: never });