@lsby/eslint-plugin 0.0.22 → 0.0.23
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// 对于状态小于等于两个的条件, else 只会兜底一种情况, 这是正确的
|
|
5
5
|
// 但如果状态继续增加, else 兜底必然匹配一个以上种状态
|
|
6
6
|
// 此时 else 部分会默默吃掉新增状态却无任何提示, 这很容易造成意外的状态逻辑遗漏
|
|
7
|
-
// 这种情况下应当使用提早返回 或 switch
|
|
7
|
+
// 这种情况下应当使用提早返回(early return)或 switch 穷尽
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
10
10
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,9 +44,11 @@ const rule = {
|
|
|
44
44
|
meta: {
|
|
45
45
|
type: 'problem',
|
|
46
46
|
docs: {
|
|
47
|
-
description: '
|
|
47
|
+
description: '禁止在非二值状态的等于/不等于条件中使用 else。当状态扩张时,else 会隐匿地处理新状态,容易造成状态逻辑遗漏。',
|
|
48
|
+
},
|
|
49
|
+
messages: {
|
|
50
|
+
noElse: '禁止在非二值状态的等于/不等于条件中使用 else。若逻辑本质为二值状态,请先通过辅助变量表示为布尔值;若为多状态逻辑,请使用提早返回(early return)或 switch 穷尽。',
|
|
48
51
|
},
|
|
49
|
-
messages: { noElse: '禁止在等于/不等于条件中使用 else,请使用提早返回或 switch 语句进行穷尽检查。' },
|
|
50
52
|
schema: [],
|
|
51
53
|
},
|
|
52
54
|
defaultOptions: [],
|