@lsby/eslint-plugin 0.0.7 → 0.0.8
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/no-null.js +22 -26
- package/package.json +1 -1
package/lib/rules/no-null.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
},
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'suggestion', // 表示这是个建议类型的规则
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'Disallow usage of null and replace it with undefined',
|
|
6
|
+
category: 'Best Practices',
|
|
7
|
+
recommended: false,
|
|
8
|
+
},
|
|
9
|
+
fixable: 'code', // 支持自动修复
|
|
10
|
+
schema: [], // 无额外配置
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
Literal(node) {
|
|
15
|
+
if (node.value === null) {
|
|
16
|
+
context.report({
|
|
17
|
+
node,
|
|
18
|
+
message: '不允许使用‘null’。使用‘undefined’代替。',
|
|
19
|
+
fix(fixer) {
|
|
20
|
+
return fixer.replaceText(node, 'undefined')
|
|
21
|
+
},
|
|
22
|
+
})
|
|
27
23
|
}
|
|
28
24
|
},
|
|
29
|
-
}
|
|
25
|
+
}
|
|
30
26
|
},
|
|
31
27
|
}
|