文档管理中心
您当前浏览的HarmonyOS 5.0.1(API 13)文档归档不再维护,推荐您使用最新版本。详细请参考文档维护策略变更。
指南DevEco Studio附录Code Linter代码检查规则通用规则@typescript-eslint@typescript-eslint/array-type

@typescript-eslint/array-type

定义数组类型时,建议使用相同的样式。比如都使用T[]或者都使用Array<T>。

规则配置

收起
自动换行
深色代码主题
复制
  1. // code-linter.json5
  2. {
  3. "rules": {
  4. "@typescript-eslint/array-type": "error"
  5. }
  6. }

选项

详情请参考typescript/array-type 选项。

正例

收起
自动换行
深色代码主题
复制
  1. const x: string[] = ['a', 'b'];
  2. const y: readonly string[] = ['a', 'b'];
  3. export { x, y };

反例

收起
自动换行
深色代码主题
复制
  1. const x: Array<string> = ['a', 'b'];
  2. const y: ReadonlyArray<string> = ['a', 'b'];
  3. export { x, y };

规则集

收起
自动换行
深色代码主题
复制
  1. plugin:@typescript-eslint/all

Code Linter代码检查规则的配置指导请参考代码Code Linter检查。

在 指南 中进行搜索
请输入您想要搜索的关键词