@hao360/eslint-plugin-cube
Advanced tools
@@ -14,2 +14,8 @@ "use strict"; | ||
| create: function(context) { | ||
| function checkAttrName(attr, attrName) { | ||
| if (attr instanceof RegExp) { | ||
| return attr.test(attrName) | ||
| } | ||
| return attrName === attr | ||
| } | ||
| return { | ||
@@ -19,23 +25,13 @@ "HTMLAttributeName": function (node) { | ||
| let attr = attributes[i]; | ||
| let attrValue = node.value.toLowerCase(); | ||
| if (attr instanceof RegExp) { | ||
| if (attr.test(attrValue)) { | ||
| context.report({ | ||
| node, | ||
| message: `禁止使用${attrValue}属性`, | ||
| loc: node.loc, | ||
| rang: node.rang | ||
| }) | ||
| break; | ||
| } | ||
| } else { | ||
| if (attrValue === attr) { | ||
| context.report({ | ||
| node, | ||
| message: `禁止使用${attrValue}属性`, | ||
| loc: node.loc, | ||
| rang: node.rang | ||
| }) | ||
| break; | ||
| } | ||
| let attrName = node.value.toLowerCase(); | ||
| let attrValue = node.parent.attributeValue ? node.parent.attributeValue.value : ''; | ||
| let isRegularExpression = /^{{/.test(attrValue.trim()); | ||
| if (!isRegularExpression && checkAttrName(attr, attrName)) { | ||
| context.report({ | ||
| node, | ||
| message: `禁止使用${attrName}属性`, | ||
| loc: node.loc, | ||
| rang: node.rang | ||
| }) | ||
| break; | ||
| } | ||
@@ -42,0 +38,0 @@ } |
+1
-1
| { | ||
| "name": "@hao360/eslint-plugin-cube", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "description": "cube rule validation plugin", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
32974
-0.03%708
-0.56%