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

Commit 39ec79e

Browse files
committed
Add rule @typescript-eslint/typedef
1 parent 1d0f8cb commit 39ec79e

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { PreferNullishCoalescingRule } from './prefer-nullish-coalescing';
1111
import type { PreferOptionalChainRule } from './prefer-optional-chain';
1212
import type { PreferReadonlyRule } from './prefer-readonly';
1313
import type { RestrictTemplateExpressionsRule } from './restrict-template-expressions';
14+
import type { TypedefRule } from './typedef';
1415

1516
/**
1617
* All @typescript-eslint rules.
@@ -27,4 +28,5 @@ export type TypeScriptEslintRules = BanTsCommentRule &
2728
PreferNullishCoalescingRule &
2829
PreferOptionalChainRule &
2930
PreferReadonlyRule &
30-
RestrictTemplateExpressionsRule;
31+
RestrictTemplateExpressionsRule &
32+
TypedefRule;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type TypedefOption = {
7+
/**
8+
* Whether to enforce type annotations on variables declared using array destructuring.
9+
*
10+
* @default false
11+
*
12+
* @see [arrayDestructuring](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#arraydestructuring)
13+
*/
14+
arrayDestructuring?: boolean;
15+
/**
16+
* Whether to enforce type annotations for parameters of arrow functions.
17+
*
18+
* @default false
19+
*
20+
* @see [arrowParameter](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#arrowparameter)
21+
*/
22+
arrowParameter?: boolean;
23+
/**
24+
* Whether to enforce type annotations on member variables of classes.
25+
*
26+
* @default false
27+
*
28+
* @see [memberVariableDeclaration](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#membervariabledeclaration)
29+
*/
30+
memberVariableDeclaration?: boolean;
31+
/**
32+
* Whether to enforce type annotations on variables declared using object destructuring.
33+
*
34+
* @default false
35+
*
36+
* @see [objectDestructuring](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#objectdestructuring)
37+
*/
38+
objectDestructuring?: boolean;
39+
/**
40+
* Whether to enforce type annotations for parameters of functions and methods.
41+
*
42+
* @default false
43+
*
44+
* @see [parameter](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#parameter)
45+
*/
46+
parameter?: boolean;
47+
/**
48+
* Whether to enforce type annotations for properties of interfaces and types.
49+
*
50+
* @default false
51+
*
52+
* @see [propertyDeclaration](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#propertydeclaration)
53+
*/
54+
propertyDeclaration?: boolean;
55+
/**
56+
* Whether to enforce type annotations for variable declarations, excluding array and object destructuring.
57+
*
58+
* @default false
59+
*
60+
* @see [variableDeclaration](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#variabledeclaration)
61+
*/
62+
variableDeclaration?: boolean;
63+
/**
64+
* Ignore variable declarations for non-arrow and arrow functions.
65+
*
66+
* @default false
67+
*
68+
* @see [variableDeclarationIgnoreFunction](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md#variabledeclarationignorefunction)
69+
*/
70+
variableDeclarationIgnoreFunction?: boolean;
71+
};
72+
73+
/**
74+
* Options.
75+
*/
76+
export type TypedefOptions = [TypedefOption?];
77+
78+
/**
79+
* Requires type annotations to exist.
80+
*
81+
* @see [typedef](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md)
82+
*/
83+
export type TypedefRuleConfig = RuleConfig<TypedefOptions>;
84+
85+
/**
86+
* Requires type annotations to exist.
87+
*
88+
* @see [typedef](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md)
89+
*/
90+
export interface TypedefRule {
91+
/**
92+
* Requires type annotations to exist.
93+
*
94+
* @see [typedef](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/typedef.md)
95+
*/
96+
'@typescript-eslint/typedef': TypedefRuleConfig;
97+
}

0 commit comments

Comments
 (0)