@lsby/eslint-plugin 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/rules/prefer-let.js +6 -7
- package/package.json +1 -1
package/lib/rules/prefer-let.js
CHANGED
|
@@ -13,14 +13,13 @@ module.exports = {
|
|
|
13
13
|
create(context) {
|
|
14
14
|
return {
|
|
15
15
|
VariableDeclaration(node) {
|
|
16
|
+
// 跳过 unique symbol
|
|
16
17
|
if ((node.kind === 'const' || node.kind === 'var') && !node.declare) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
if (hasUniqueSymbol)
|
|
22
|
-
return // 跳过 unique symbol
|
|
23
|
-
}
|
|
18
|
+
let hasUniqueSymbol = node.declarations.some((decl) => {
|
|
19
|
+
const typeAnn = decl.id.typeAnnotation?.typeAnnotation
|
|
20
|
+
return typeAnn?.type === 'TSTypeOperator' && typeAnn.operator === 'unique'
|
|
21
|
+
})
|
|
22
|
+
if (hasUniqueSymbol) return
|
|
24
23
|
|
|
25
24
|
// 使用修复功能将 const 或 var 替换为 let
|
|
26
25
|
context.report({
|