@lsby/eslint-plugin 0.0.3 → 0.0.5

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.
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ create(context) {
3
+ return {
4
+ UnaryExpression(node) {
5
+ if (node.operator === '!') {
6
+ context.report({
7
+ node,
8
+ message: "禁止使用 '!' 运算符, 写出更明确的判断条件会减少可能的问题, 如果存在重用逻辑就封装函数.",
9
+ })
10
+ }
11
+ },
12
+ }
13
+ },
14
+ }
@@ -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
- return fixer.replaceTextRange(
24
- [node.start, node.start + node.kind.length],
25
- 'let'
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsby/eslint-plugin",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "pub:public": "bumpp && npm publish --access public",