文档管理中心
我的
您当前浏览的HarmonyOS 5.0.0(API 12)文档归档不再维护,推荐您使用最新版本。详细请参考文档维护策略变更。
指南DevEco Studio附录Code Linter代码检查规则ArkTS代码风格规则@hw-stylistic@hw-stylistic/array-bracket-spacing

@hw-stylistic/array-bracket-spacing

强制数组“[”之后和“]”之前加空格。该规则仅检查.ets文件类型。

规则配置

// code-linter.json5
{
  "rules": {
    "@hw-stylistic/array-bracket-spacing": "error"
  }
}

选项

该规则无需配置额外选项。

正例

export const arr = ['a', 'b'];

反例

// There should be no space after '['.
// There should be no space before ']'.
export const arr = [ 'a', 'b' ];

规则集

"plugin:@hw-stylistic/recommended"
"plugin:@hw-stylistic/all"

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