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

Commit 32dd4e6

Browse files
committed
Add rule @typescript-eslint/array-type
1 parent 7bcf4b1 commit 32dd4e6

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Array Option.
5+
*/
6+
export type ArrayOption = 'array' | 'generic' | 'array-simple';
7+
8+
/**
9+
* Option.
10+
*/
11+
export type ArrayTypeOption = {
12+
/**
13+
* Sets the array type expected for mutable cases.
14+
*
15+
* @default 'array'
16+
*
17+
* @see [default](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md#options)
18+
*/
19+
default: ArrayOption;
20+
/**
21+
* Sets the array type expected for readonly arrays. If this is omitted, then the value for default will be used.
22+
*
23+
* @see [readonly](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md#options)
24+
*/
25+
readonly?: ArrayOption;
26+
};
27+
28+
/**
29+
* Options.
30+
*/
31+
export type ArrayTypeOptions = [ArrayTypeOption?];
32+
33+
/**
34+
* Requires using either `T[]` or `Array<T>` for arrays.
35+
*
36+
* @see [array-type](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md)
37+
*/
38+
export type ArrayTypeRuleConfig = RuleConfig<ArrayTypeOptions>;
39+
40+
/**
41+
* Requires using either `T[]` or `Array<T>` for arrays.
42+
*
43+
* @see [array-type](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md)
44+
*/
45+
export interface ArrayTypeRule {
46+
/**
47+
* Requires using either `T[]` or `Array<T>` for arrays.
48+
*
49+
* @see [array-type](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md)
50+
*/
51+
'@typescript-eslint/array-type': ArrayTypeRuleConfig;
52+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AdjacentOverloadSignaturesRule } from './adjacent-overload-signatures';
2+
import type { ArrayTypeRule } from './array-type';
23
import type { BanTsCommentRule } from './ban-ts-comment';
34
import type { ExplicitFunctionReturnTypeRule } from './explicit-function-return-type';
45
import type { InterfaceNamePrefixRule } from './interface-name-prefix';
@@ -18,6 +19,7 @@ import type { TypedefRule } from './typedef';
1819
* All @typescript-eslint rules.
1920
*/
2021
export type TypeScriptEslintRules = AdjacentOverloadSignaturesRule &
22+
ArrayTypeRule &
2123
BanTsCommentRule &
2224
ExplicitFunctionReturnTypeRule &
2325
InterfaceNamePrefixRule &

0 commit comments

Comments
 (0)