mm_eslint 1.2.2 → 1.2.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.
- package/index.js +16 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -887,9 +887,22 @@ Detector.prototype._checkFuncProp = function (name, config, errors) {
|
|
|
887
887
|
* @private
|
|
888
888
|
*/
|
|
889
889
|
Detector.prototype._checkClassProp = function (name, config, errors) {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
890
|
+
// 对于类实例的属性名,允许使用小驼峰命名
|
|
891
|
+
// 只有类定义本身才要求使用PascalCase
|
|
892
|
+
const is_class_instance = true; // 这里可以根据上下文进一步优化
|
|
893
|
+
|
|
894
|
+
if (is_class_instance) {
|
|
895
|
+
// 类实例允许使用小驼峰命名
|
|
896
|
+
const func_res = this._checkName("function-name", name);
|
|
897
|
+
if (!func_res.valid) {
|
|
898
|
+
errors.push(`${config.name}(类实例)${func_res.errors.join(", ")}`);
|
|
899
|
+
}
|
|
900
|
+
} else {
|
|
901
|
+
// 类定义要求使用PascalCase
|
|
902
|
+
const cls_res = this._checkName("class-name", name);
|
|
903
|
+
if (!cls_res.valid) {
|
|
904
|
+
errors.push(`${config.name}(类)${cls_res.errors.join(", ")}`);
|
|
905
|
+
}
|
|
893
906
|
}
|
|
894
907
|
};
|
|
895
908
|
|