Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 50ec38b

Browse files
committed
Add rule @typescript-eslint/consistent-type-definitions
1 parent 9646e54 commit 50ec38b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type ConsistentTypeDefinitionsOption = 'type' | 'interface';
7+
8+
/**
9+
* Options.
10+
*/
11+
export type ConsistentTypeDefinitionsOptions = [ConsistentTypeDefinitionsOption?];
12+
13+
/**
14+
* Consistent with type definition either `interface` or `type`.
15+
*
16+
* @default 'interface'
17+
*
18+
* @see [consistent-type-definitions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md)
19+
*/
20+
export type ConsistentTypeDefinitionsRuleConfig = RuleConfig<ConsistentTypeDefinitionsOptions>;
21+
22+
/**
23+
* Consistent with type definition either `interface` or `type`.
24+
*
25+
* @default 'interface'
26+
*
27+
* @see [consistent-type-definitions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md)
28+
*/
29+
export interface ConsistentTypeDefinitionsRule {
30+
/**
31+
* Consistent with type definition either `interface` or `type`.
32+
*
33+
* @default 'interface'
34+
*
35+
* @see [consistent-type-definitions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md)
36+
*/
37+
'@typescript-eslint/consistent-type-definitions': ConsistentTypeDefinitionsRuleConfig;
38+
}

src/rules/typescript-eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { AwaitThenableRule } from './await-thenable';
44
import type { BanTsCommentRule } from './ban-ts-comment';
55
import type { BanTypesRule } from './ban-types';
66
import type { ConsistentTypeAssertionsRule } from './consistent-type-assertions';
7+
import type { ConsistentTypeDefinitionsRule } from './consistent-type-definitions';
78
import type { ExplicitFunctionReturnTypeRule } from './explicit-function-return-type';
89
import type { IndentRule } from './indent';
910
import type { InterfaceNamePrefixRule } from './interface-name-prefix';
@@ -31,6 +32,7 @@ export type TypeScriptEslintRules = AdjacentOverloadSignaturesRule &
3132
ConsistentTypeAssertionsRule &
3233
ExplicitFunctionReturnTypeRule &
3334
IndentRule &
35+
ConsistentTypeDefinitionsRule &
3436
InterfaceNamePrefixRule &
3537
MemberOrderingRule &
3638
NoExplicitAnyRule &

0 commit comments

Comments
 (0)