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

Commit bb76c88

Browse files
committed
Add rule @typescript-eslint/no-inferrable-types
1 parent 0e45a3e commit bb76c88

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ module.exports = defineConfig({
9595
'esnext',
9696
'globals',
9797
'greasemonkey',
98+
'inferrable',
9899
'jsdoc',
99100
'jsx',
100101
'lang',

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ExplicitFunctionReturnTypeRule } from './explicit-function-return-
33
import type { InterfaceNamePrefixRule } from './interface-name-prefix';
44
import type { MemberOrderingRule } from './member-ordering';
55
import type { NoExplicitAnyRule } from './no-explicit-any';
6+
import type { NoInferrableTypesRule } from './no-inferrable-types';
67

78
/**
89
* All @typescript-eslint rules.
@@ -11,4 +12,5 @@ export type TypeScriptEslintRules = BanTsCommentRule &
1112
ExplicitFunctionReturnTypeRule &
1213
InterfaceNamePrefixRule &
1314
MemberOrderingRule &
14-
NoExplicitAnyRule;
15+
NoExplicitAnyRule &
16+
NoInferrableTypesRule;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type NoInferrableTypesOption = {
7+
/**
8+
* @default false
9+
*
10+
* @see [ignoreParameters](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md#ignoreparameters)
11+
*/
12+
ignoreParameters?: boolean;
13+
/**
14+
* @default false
15+
*
16+
* @see [ignoreProperties](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md#ignoreproperties)
17+
*/
18+
ignoreProperties?: boolean;
19+
};
20+
21+
/**
22+
* Options.
23+
*/
24+
export type NoInferrableTypesOptions = [NoInferrableTypesOption?];
25+
26+
/**
27+
* Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
28+
*
29+
* @see [no-inferrable-types](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md)
30+
*/
31+
export type NoInferrableTypesRuleConfig = RuleConfig<NoInferrableTypesOptions>;
32+
33+
/**
34+
* Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
35+
*
36+
* @see [no-inferrable-types](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md)
37+
*/
38+
export interface NoInferrableTypesRule {
39+
/**
40+
* Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
41+
*
42+
* @see [no-inferrable-types](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md)
43+
*/
44+
'@typescript-eslint/no-inferrable-types': NoInferrableTypesRuleConfig;
45+
}

0 commit comments

Comments
 (0)