recommended推荐规则清单
=================

#### 通用规则推荐规则集@typescript-eslint/recommended

<table id="table1843815320456"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row948483212455"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p7484832194519">@typescript-eslint/await-thenable</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14842032154516">不允许对不是“Thenable”对象的值使用await关键字（“Thenable”表示某个对象拥有“then”方法，比如Promise）。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row648433213459"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p748493264519">@typescript-eslint/consistent-type-imports</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p548403218452">强制使用一致的类型导入风格。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row74844327457"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1348483224513">@typescript-eslint/explicit-function-return-type</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p648453294511">函数和类方法需要显式的定义返回类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row14484732204510"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p9484432174513">@typescript-eslint/explicit-module-boundary-types</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p114841032104517">导出到外部的函数和公共类方法，需要显式的定义返回类型和参数类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1484732154518"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1248493234517">@typescript-eslint/no-dynamic-delete</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p3484113219455">不允许在computed key表达式上使用“delete”运算符。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1548473244512"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p20484532154510">@typescript-eslint/no-explicit-any</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1948473214520">不允许使用“any”类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row194938329456"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p7493163213454">@typescript-eslint/no-for-in-array</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p3493183274517">禁止使用 for-in 循环来遍历数组元素。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row2049315326454"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p7493163244519">@typescript-eslint/no-this-alias</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1749353294514">禁止将“this”赋值给一个变量。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row649393254520"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p6493932124519">@typescript-eslint/no-unnecessary-type-constraint</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p18493163215453">不允许在泛型中使用不必要的约束条件。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row164931332154515"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p0493203284514">@typescript-eslint/no-unsafe-argument</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p4493163214514">不允许将any类型的值作为函数的参数传入。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row13493532184511"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1849316325451">@typescript-eslint/no-unsafe-assignment</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p124934327458">禁止将“any”类型的值赋值给变量和属性。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row64935321452"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p849483217450">@typescript-eslint/no-unsafe-call</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1494183210457">禁止调用“any”类型的表达式。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row15494732144515"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p549419325456">@typescript-eslint/no-unsafe-member-access</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p19494173294515">禁止成员访问“any”类型的值。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row18494143204517"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p44942032134517">@typescript-eslint/no-unsafe-return</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p749473214454">函数禁止返回类型为“any”的值。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row144941232174514"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p134944323457">@typescript-eslint/prefer-literal-enum-member</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p3494153264518">要求所有枚举成员都定义为字面量值。</p></td></tr></tbody></table>

#### 安全规则推荐规则集@security/recommended

<table id="table18680359154612"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row27086594469"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1670825944612">@security/no-commented-code</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p170812595469">不使用的代码段建议直接删除，不允许通过注释的方式保留。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row197081059164616"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1470885912463">@security/no-unsafe-aes</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p170814591465">该规则禁止在AES加密算法中使用不安全的ECB加密模式。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row207081059104620"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p15708165954610">@security/no-unsafe-dh</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p187081259124610">该规则禁止使用不安全的DH密钥协商算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row187081759124610"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p470825916466">@security/no-unsafe-dh-key</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p2708759104612">该规则禁止使用不安全的DH密钥。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4708145910463"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14708105964611">@security/no-unsafe-dsa</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p570855917465">该规则禁止使用不安全的DSA签名算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row270815964620"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1870835916462">@security/no-unsafe-dsa-key</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p2070915918463">该规则禁止使用不安全的DSA密钥。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row147091259104614"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p0709105917466">@security/no-unsafe-ecdsa</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14709205954617">该规则禁止在ECDSA签名算法中使用不安全的SHA1摘要算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row47091459164617"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1270965934616">@security/no-unsafe-hash</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p127091559164618">该规则使用禁止不安全的哈希算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4709165913468"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p2709185915467">@security/no-unsafe-mac</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p870955918460">该规则禁止在MAC消息认证算法中使用不安全的哈希算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4709105917464"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p5709105915464">@security/no-unsafe-rsa-encrypt</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1770917597469">该规则禁止使用不安全的RSA非对称加密算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row37091459134619"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1270919596466">@security/no-unsafe-rsa-key</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p470919599461">该规则禁止使用不安全的RSA密钥。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row167091259134610"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1570975912466">@security/no-unsafe-rsa-sign</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p15709125911462">该规则禁止不安全的RSA签名算法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row167091159174612"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1370915984612">@security/no-unsafe-3des</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1470925914619">该规则禁止使用不安全的3DES加密模式。</p></td></tr></tbody></table>

#### 性能规则推荐规则集@performance/recommended

<table id="table2043145924814"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row5276131211116"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p92765129113">@performance/foreach-args-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p19276612117">建议在ForEach参数中设置keyGenerator。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row510412593482"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p210417595485">@performance/high-frequency-log-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1610435944819">不建议在高频函数中使用Hilog。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row3104859174814"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p161041659154812">@performance/hp-arkts-no-use-any-export-current</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1010465944811">避免使用export * 导出当前module中定义的类型和数据。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row111041359114820"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p131042059104816">@performance/hp-arkts-no-use-any-export-other</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p111041159184819">避免使用export * 导出其他module中定义的类型和数据。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row71041359174816"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p210425917487">@performance/hp-arkui-avoid-update-auto-state-var-in-aboutToReuse</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1810435918484">避免在aboutToReuse中对自动更新值的状态变量进行更新。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row610485917480"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p210475984817">@performance/hp-arkui-combine-same-arg-animateto</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p81041259174814">建议动画参数相同时使用同一个animateTo。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row5104105984810"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p81041559114819">@performance/hp-arkui-load-on-demand</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p01041259114810">建议使用按需加载。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row9104559104818"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p310425916482">@performance/hp-arkui-no-func-as-arg-for-reusable-component</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p610445964815">避免使用函数作为复用的自定义组件创建时的入参。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row6104165915482"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p0104459154814">@performance/hp-arkui-no-state-var-access-in-loop</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p2010465984811">避免在for、while等循环逻辑中频繁读取状态变量。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1610445912487"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p19104115954819">@performance/hp-arkui-no-stringify-in-lazyforeach-key-generator</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p51047598484">在使用LazyForEach进行组件复用的key生成器函数里，不要使用stringify。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row10104559124816"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p181041259204817">@performance/hp-arkui-replace-nested-reusable-component-by-builder</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p61050599486">建议使用@Builder替代嵌套的自定义组件。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1410585919481"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p13105185913481">@performance/hp-arkui-set-cache-count-for-lazyforeach-grid</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p5105175934817">建议在Grid下使用LazyForEach时设置合理的cacheCount。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row3105115914480"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p21051596485">@performance/hp-arkui-suggest-cache-avplayer</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p121052597489">建议缓存AVPlayer实例减少起播时延。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row181051459164814"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p10105145934818">@performance/hp-arkui-suggest-reuseid-for-if-else-reusable-component</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p2105659164818">建议使用reuseId标记不同结构的组件构成。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4105115934815"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p41051659144812">@performance/hp-arkui-suggest-use-effectkit-blur</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p5105359104816">建议使用effectKit.createEffect实现模糊效果。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row151051959184815"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p11051759124818">@performance/hp-arkui-use-grid-layout-options</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1610517597486">建议在指定位置时使用GridLayoutOptions提升Grid性能。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row18105165919487"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p210515594485">@performance/hp-arkui-use-local-var-to-replace-state-var</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p18105105911485">建议使用临时变量替换状态变量。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row8105145974817"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p4105165913486">@performance/hp-arkui-use-object-link-to-replace-prop</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p4105165904811">建议使用@ObjectLink代替@Prop减少不必要的深拷贝。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row20105959114818"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p71051659124812">@performance/hp-arkui-use-onAnimationStart-for-swiper-preload</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p181051459144811">建议Swiper预加载机制搭配 OnAnimationStart 接口回调使用。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row17105359194812"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p410595984813">@performance/hp-arkui-use-reusable-component</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1010514598483">建议复杂组件的定义，尽量使用组件复用。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row11105165984818"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p12105155904813">@performance/hp-arkui-use-scale-to-replace-attr-animateto</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p110585912482">建议组件布局改动时使用图形变换属性动画。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row810545916488"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p8105159114813">@performance/hp-arkui-use-transition-to-replace-animateto</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p910511595482">建议组件转场动画使用transition。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1017619469193"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p9861047161919">@performance/hp-ffrt-no-use-std</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p2862047201915">禁止在FFRT worker中使用std::xxx等同步接口。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row410595910481"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p11105359134813">@performance/no-high-loaded-frame-rate-range</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p141051159104815">不允许锁定最高帧率运行。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row15105175914810"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p1810555994812">@performance/start-window-icon-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p8106559134817">启动页图标分辨率建议不超过256 * 256。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1410655914819"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p6106105913481">@performance/waterflow-data-preload-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p15106195911488">建议对waterflow子组件进行数据预加载。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row575417230416"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p1275502384110">@performance/web-on-active-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p27558234419">使用了Web预渲染技术的应用，建议在预渲染完成后（onFirstMeaningfulPaint），调用停止渲染接口（onInactive）。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row56001449204115"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p86001749204111">@performance/gif-hardware-decoding-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p760013498416">在使用@ohos/gif-drawable库解码gif图片时，建议开启硬解码，提升gif加载性能。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4847123618447"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p16997521194517">@performance/no-use-any-import</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p78601752113213">使用import的方式引入对应的模块时，建议按需引用使用到的变量代替“import *”的方式，以减少 .ets文件的执行耗时和文件中所有export变量的初始化过程。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row022019508446"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p455013264462">@performance/avoid-overusing-custom-component-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1822075018448">当在应用中使用自定义组件时，可以优先使用@Builder函数代替自定义组件，@Builder函数不会在后端FrameNode节点树上创建一个新的树节点，有助于缩短页面的加载和渲染时长。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1641635474420"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p141665444420">@performance/bad-deep-clone-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p24161054174419">避免使用不合理深拷贝，如JSON.parse(JSON.stringify(foo))和_.cloneDeep(foo)。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row5464165824411"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p9464115834410">@performance/reuse-date-instances-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p2046419588446">用于检测在循环或调用频繁的方法中重复创建Date对象，建议开发者重用现有实例或使用时间戳进行计算，减少创建Date成本。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row3464558204413"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p146425814416">@performance/crypto-replacement-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p1717372242711">对于三方库@ohos/crypto-js所提供的大部分接口，SDK（@ohos.security.cryptoFramework）中有对应的系统原生实现。建议使用系统原生接口。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row144640582445"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p545504494">@performance/monitor-invisible-area-in-image-animation</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p17464115894419">使用ImageAnimation实现帧动画时，建议显式调用monitorInvisibleArea接口。在动画组件不可见时，会停止动画播放，减少无效的冗余动画带来的负载恶化。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row441665418442"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p7281191819493">@performance/datashare-query-unrelease-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p17416145414446">建议使用DataShareHelper的query接口查询数据得到结果后，应及时关闭，避免造成内存泄漏。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row14265116134513"><td class="cellrowborder" valign="top" width="49.95%"><p id="ZH-CN_TOPIC_0000002594474044__p1750954917491">@performance/update-state-var-between-animatetos-check</p></td><td class="cellrowborder" valign="top" width="50.05%"><p id="ZH-CN_TOPIC_0000002594474044__p15508649104911">如果多个animateTo之间存在状态更新，会导致执行下一个animateTo之前又存在需要更新的脏节点，可能造成冗余更新。因此不建议在两次animateTo之间进行状态变量更新。</p></td></tr></tbody></table>

#### 预览规则集@previewer/recommended

<table id="table9212813175016"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row422521314508"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14226161315011">@previewer/mandatory-default-value-for-local-initialization</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p4226313165010">如果组件的属性支持本地初始化，需要设置一个合法的不依赖运行时的默认值。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4226141365013"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p4226913195010">@previewer/no-page-method-on-preview-component</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1622661345012">禁止在非路由组件上实例化onPageShow、onPageHide、onBackPress等页面级方法。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row922617131503"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p32260137506">@previewer/no-unallowed-decorator-on-root-component</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p122618134503">对于@Entry组件，不允许使用@Consume、@Link、@ObjectLink、@Prop注解；对于@Preview组件，建议使用一个定义了完整的、合法的、不依赖运行时的默认值的父组件作为预览该组件的容器。</p></td></tr></tbody></table>

#### 一次开发多端部署规则推荐规则集@cross-device-app-dev/recommended

<table id="table370415124468"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row157240122466"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p147245126465">@cross-device-app-dev/color-contrast</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1310211405552">文本和背景之间的颜色对比度至少为4.5:1以确保可读性。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row20724161294615"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1783685965514">@cross-device-app-dev/color-value</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p16724141215461">颜色值应当使用“$r”从color.json中引用，以适配不同的系统颜色模式，禁止使用固定的值。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row4724812164620"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p157249128461">@cross-device-app-dev/font-size</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1072471244620">字体大小要求至少为8fp以便于阅读。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1272415121469"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p07241812114619">@cross-device-app-dev/font-size-unit</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p9724141215462">字体大小单位建议使用fp，以适配系统字体设置。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row6725812194611"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1671216388573">@cross-device-app-dev/grid-columns-span</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1372511284618">不推荐开发者将栅格中所有的GridCol子组件只设置span属性，且值与父组件的columns属性相等。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row572591224615"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p772541211467">@cross-device-app-dev/grid-span-value</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p177251312114620">在栅格布局组件GridCol中，span和offset不建议使用小数。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row57252012174613"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p117251712174614">@cross-device-app-dev/sidebar-navigation</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1372561214613">对于2in1和tablet设备，应将Tabs组件设置为侧边导航栏。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row172516125469"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p963163525915">@cross-device-app-dev/size-unit</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p147256128464">组件通用属性width、height和size，应当使用vp作为单位，以适配不同设备屏幕宽度。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row772531220469"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p10725181274613">@cross-device-app-dev/touch-target-size</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p10623686013">组件通用属性responseRegion点击热区需满足最小尺寸要求。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row12150447513"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p01500416519">@cross-device-app-dev/one-multi-breakpoint-check</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p19150104115116">一多特性必须使用系统断点判断是否开启，不能通过设备类型、设备方向或是否可折叠等属性来判断。</p></td></tr></tbody></table>

#### ArkTS代码风格规则推荐规则集@hw-stylistic/recommended

<table id="table989373912465"><tbody><tr id="ZH-CN_TOPIC_0000002594474044__row17927143944615"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p29271539134617">@hw-stylistic/array-bracket-spacing</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1592773974610">强制数组“[”之后和“]”之前加空格。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row29271039104614"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p11927113917463">@hw-stylistic/brace-style</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p149275398461">强制大括号和语句位于同一行。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1192710395463"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p292793913467">@hw-stylistic/comma-spacing</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p15927639144617">强制数组元素和函数中多个参数之间的逗号后面加空格，逗号前不加空格。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row192714395465"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1092733914468">@hw-stylistic/curly</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p5927153924613">条件语句和循环语句的逻辑代码必须写在大括号中。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row10927339154620"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p20927539194618">@hw-stylistic/file-naming-convention</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p12927939164619">强制代码文件和资源文件保持一致的命名风格。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row09271395464"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1092853913467">@hw-stylistic/indent</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1928143994617">强制switch语句中的case和default缩进一层。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row169281339174614"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p3928939204614">@hw-stylistic/keyword-spacing</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1392883974619">在关键字前后强制加空格。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row1092833954615"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p119282039124611">@hw-stylistic/max-len</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p4928539144614">强制代码行最大长度为120个字符。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row12928153918469"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p119285396465">@hw-stylistic/no-multi-spaces</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p192803984616">不允许出现连续多个空格，除非是换行。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row9928193984611"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p6928133914466">@hw-stylistic/no-tabs</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p10928339194611">禁止使用tab作为缩进，推荐使用空格。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row14928439184617"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p6928193934620">@hw-stylistic/object-property-newline</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p18928539154615">强制对象属性换行。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row792873915464"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p1928143919462">@hw-stylistic/one-var-declaration-per-line</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p492813974610">变量声明时，要求一次仅声明一个变量。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row15928539174614"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p6928639164614">@hw-stylistic/operator-linebreak</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p59283392464">强制运算符位于代码行末。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row169281639174614"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p592853919469">@hw-stylistic/quotes</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p189281539194614">强制字符串使用单引号。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row15928163994620"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p20928239164611">@hw-stylistic/semi-spacing</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p59281439164617">强制分号之前不加空格。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row192817393461"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p69284392469">@hw-stylistic/space-before-blocks</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p109281339104611">强制在“{”之前加空格。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row392893912466"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14928103911468">@hw-stylistic/space-before-function-paren</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p39291396465">在函数名和“(”之间强制不加空格。该规则仅检查.ets文件类型。</p></td></tr><tr id="ZH-CN_TOPIC_0000002594474044__row392973964610"><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p14929183934614">@hw-stylistic/space-infix-ops</p></td><td class="cellrowborder" valign="top" width="50%"><p id="ZH-CN_TOPIC_0000002594474044__p13929123916468">强制运算符前后都加空格。</p></td></tr></tbody></table>