mm_eslint 1.5.2 → 1.5.3

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.
@@ -227,6 +227,11 @@ ConstName.prototype._isConstantValue = function (value_node) {
227
227
  return false; // await表达式的结果通常是可变的,不是常量
228
228
  }
229
229
 
230
+ // 排除条件表达式(三元运算符)
231
+ if (value_node.type === 'ConditionalExpression') {
232
+ return false; // 条件表达式的结果在运行时确定,不是常量
233
+ }
234
+
230
235
  // 默认情况下,如果不是排除的类型,就认为是常量
231
236
  return true;
232
237
  }
@@ -134,6 +134,18 @@ VariableName.prototype.VariableDeclaration = function (node) {
134
134
  this.report(node, error, 'variable');
135
135
  return error;
136
136
  }
137
+
138
+ // 对于ConditionalExpression(条件表达式/三元运算符),直接处理
139
+ else if (decl.init.type === 'ConditionalExpression') {
140
+ let error = {
141
+ message: `变量'${name}'应该使用let标签声明而不是const标签声明`,
142
+ fix: function(fixer) {
143
+ return fixer.replaceTextRange([node.range[0], node.range[0] + 5], 'let');
144
+ }
145
+ };
146
+ this.report(node, error, 'variable');
147
+ return error;
148
+ }
137
149
  }
138
150
  // 对于const声明的其他情况,跳过变量规则检测(由常量规则处理)
139
151
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_eslint",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "ESLint plugin for personal naming conventions - supports PascalCase, camelCase, snake_case, and UPPER_SNAKE_CASE naming rules with intelligent recommendations",
5
5
  "main": "index.js",
6
6
  "keywords": [