@html-eslint/eslint-plugin 0.23.0 → 0.23.1
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/constants/svg-camel-case-attributes.js +73 -0
- package/lib/rules/lowercase.js +43 -1
- package/package.json +2 -2
- package/types/constants/svg-camel-case-attributes.d.ts +3 -0
- package/types/constants/svg-camel-case-attributes.d.ts.map +1 -0
- package/types/constants/svg-camelcase-attributes.d.ts +3 -0
- package/types/constants/svg-camelcase-attributes.d.ts.map +1 -0
- package/types/rules/lowercase.d.ts.map +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
"allowReorder",
|
|
3
|
+
"attributeName",
|
|
4
|
+
"attributeType",
|
|
5
|
+
"autoReverse",
|
|
6
|
+
"baseFrequency",
|
|
7
|
+
"baseProfile",
|
|
8
|
+
"calcMode",
|
|
9
|
+
"clipPath",
|
|
10
|
+
"clipPathUnits",
|
|
11
|
+
"contentScriptType",
|
|
12
|
+
"contentStyleType",
|
|
13
|
+
"diffuseConstant",
|
|
14
|
+
"edgeMode",
|
|
15
|
+
"externalResourcesRequired",
|
|
16
|
+
"filterRes",
|
|
17
|
+
"filterUnits",
|
|
18
|
+
"glyphRef",
|
|
19
|
+
"gradientTransform",
|
|
20
|
+
"gradientUnits",
|
|
21
|
+
"kernelMatrix",
|
|
22
|
+
"kernelUnitLength",
|
|
23
|
+
"keyPoints",
|
|
24
|
+
"keySplines",
|
|
25
|
+
"keyTimes",
|
|
26
|
+
"lengthAdjust",
|
|
27
|
+
"limitingConeAngle",
|
|
28
|
+
"markerHeight",
|
|
29
|
+
"markerUnits",
|
|
30
|
+
"markerWidth",
|
|
31
|
+
"maskContentUnits",
|
|
32
|
+
"maskUnits",
|
|
33
|
+
"numOctaves",
|
|
34
|
+
"onBlur",
|
|
35
|
+
"onChange",
|
|
36
|
+
"onClick",
|
|
37
|
+
"onFocus",
|
|
38
|
+
"onKeyUp",
|
|
39
|
+
"onLoad",
|
|
40
|
+
"pathLength",
|
|
41
|
+
"patternContentUnits",
|
|
42
|
+
"patternTransform",
|
|
43
|
+
"patternUnits",
|
|
44
|
+
"pointsAtX",
|
|
45
|
+
"pointsAtY",
|
|
46
|
+
"pointsAtZ",
|
|
47
|
+
"preserveAlpha",
|
|
48
|
+
"preserveAspectRatio",
|
|
49
|
+
"primitiveUnits",
|
|
50
|
+
"refX",
|
|
51
|
+
"refY",
|
|
52
|
+
"repeatCount",
|
|
53
|
+
"repeatDur",
|
|
54
|
+
"requiredExtensions",
|
|
55
|
+
"requiredFeatures",
|
|
56
|
+
"specularConstant",
|
|
57
|
+
"specularExponent",
|
|
58
|
+
"spreadMethod",
|
|
59
|
+
"startOffset",
|
|
60
|
+
"stdDeviation",
|
|
61
|
+
"stitchTiles",
|
|
62
|
+
"surfaceScale",
|
|
63
|
+
"systemLanguage",
|
|
64
|
+
"tableValues",
|
|
65
|
+
"targetX",
|
|
66
|
+
"targetY",
|
|
67
|
+
"textLength",
|
|
68
|
+
"viewBox",
|
|
69
|
+
"viewTarget",
|
|
70
|
+
"xChannelSelector",
|
|
71
|
+
"yChannelSelector",
|
|
72
|
+
"zoomAndPan",
|
|
73
|
+
];
|
package/lib/rules/lowercase.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const { NODE_TYPES } = require("@html-eslint/parser");
|
|
9
9
|
const { RULE_CATEGORY } = require("../constants");
|
|
10
|
+
const SVG_CAMEL_CASE_ATTRIBUTES = require("../constants/svg-camel-case-attributes");
|
|
10
11
|
|
|
11
12
|
const MESSAGE_IDS = {
|
|
12
13
|
UNEXPECTED: "unexpected",
|
|
@@ -33,6 +34,31 @@ module.exports = {
|
|
|
33
34
|
},
|
|
34
35
|
|
|
35
36
|
create(context) {
|
|
37
|
+
const allowedAttrKeySet = new Set(SVG_CAMEL_CASE_ATTRIBUTES);
|
|
38
|
+
/**
|
|
39
|
+
* @type {TagNode[]}
|
|
40
|
+
*/
|
|
41
|
+
const svgStack = [];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {TagNode} node
|
|
45
|
+
*/
|
|
46
|
+
function enterSvg(node) {
|
|
47
|
+
svgStack.push(node);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function exitSvg() {
|
|
51
|
+
svgStack.pop();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} key
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/
|
|
58
|
+
function isAllowedAttributeKey(key) {
|
|
59
|
+
return !!svgStack.length && allowedAttrKeySet.has(key);
|
|
60
|
+
}
|
|
61
|
+
|
|
36
62
|
/**
|
|
37
63
|
* @param {TagNode | StyleTagNode | ScriptTagNode} node
|
|
38
64
|
*/
|
|
@@ -72,6 +98,9 @@ module.exports = {
|
|
|
72
98
|
}
|
|
73
99
|
if (node.attributes && node.attributes.length) {
|
|
74
100
|
node.attributes.forEach((attribute) => {
|
|
101
|
+
if (isAllowedAttributeKey(attribute.key.value)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
75
104
|
if (attribute.key.value !== attribute.key.value.toLowerCase()) {
|
|
76
105
|
context.report({
|
|
77
106
|
node: attribute.key,
|
|
@@ -92,7 +121,20 @@ module.exports = {
|
|
|
92
121
|
}
|
|
93
122
|
|
|
94
123
|
return {
|
|
95
|
-
Tag
|
|
124
|
+
Tag(node) {
|
|
125
|
+
if (node.name.toLocaleLowerCase() === "svg") {
|
|
126
|
+
enterSvg(node);
|
|
127
|
+
}
|
|
128
|
+
check(node);
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* @param {TagNode} node
|
|
132
|
+
*/
|
|
133
|
+
"Tag:exit"(node) {
|
|
134
|
+
if (node.name.toLocaleLowerCase() === "svg") {
|
|
135
|
+
exitSvg();
|
|
136
|
+
}
|
|
137
|
+
},
|
|
96
138
|
StyleTag: check,
|
|
97
139
|
ScriptTag: check,
|
|
98
140
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-eslint/eslint-plugin",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "ESLint plugin for html",
|
|
5
5
|
"author": "yeonjuan",
|
|
6
6
|
"homepage": "https://github.com/yeonjuan/html-eslint#readme",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"es-html-parser": "^0.0.8",
|
|
52
52
|
"typescript": "^4.4.4"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "62903977d8106d40b1916b5abcb65538ade321e2"
|
|
55
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-camel-case-attributes.d.ts","sourceRoot":"","sources":["../../lib/constants/svg-camel-case-attributes.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-camelcase-attributes.d.ts","sourceRoot":"","sources":["../../lib/constants/svg-camelcase-attributes.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lowercase.d.ts","sourceRoot":"","sources":["../../lib/rules/lowercase.js"],"names":[],"mappings":"wBAgBU,UAAU;;yBAfN,OAAO,UAAU,EAAE,UAAU;sBAC7B,OAAO,UAAU,EAAE,OAAO;2BAC1B,OAAO,UAAU,EAAE,YAAY;4BAC/B,OAAO,UAAU,EAAE,aAAa"}
|