@lsby/eslint-plugin 0.0.3 → 0.0.4
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 +8 -8
- package/package.json +1 -1
package/lib/rules/prefer-let.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = {
|
|
|
6
6
|
category: 'Best Practices',
|
|
7
7
|
recommended: false,
|
|
8
8
|
},
|
|
9
|
-
fixable: 'code',
|
|
9
|
+
fixable: 'code', // 支持修复
|
|
10
10
|
schema: [], // 没有配置选项
|
|
11
11
|
},
|
|
12
12
|
|
|
@@ -20,14 +20,14 @@ module.exports = {
|
|
|
20
20
|
node,
|
|
21
21
|
message: 'Use let instead of const or var',
|
|
22
22
|
fix(fixer) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
23
|
+
// 获取变量声明的范围
|
|
24
|
+
const range = node.range
|
|
25
|
+
// 确保给定的 range 是有效的
|
|
26
|
+
return fixer.replaceTextRange([range[0], range[0] + node.kind.length], 'let')
|
|
27
27
|
},
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
},
|
|
33
|
-
}
|
|
33
|
+
}
|