@html-eslint/eslint-plugin 0.23.0 → 0.24.0

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.
@@ -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
+ ];
@@ -55,6 +55,7 @@ module.exports = {
55
55
  type: "object",
56
56
  properties: {
57
57
  pattern: { type: "string" },
58
+ flags: { type: "string" },
58
59
  },
59
60
  additionalProperties: false,
60
61
  },
@@ -74,7 +75,10 @@ module.exports = {
74
75
  const checkNaming =
75
76
  convention === CONVENTIONS.REGEX
76
77
  ? (/** @type string */ name) =>
77
- new RegExp(context.options[1].pattern).test(name)
78
+ new RegExp(
79
+ context.options[1].pattern,
80
+ context.options[1].flags || ""
81
+ ).test(name)
78
82
  : CONVENTION_CHECKERS[convention];
79
83
 
80
84
  return {
@@ -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: check,
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.0",
3
+ "version": "0.24.0",
4
4
  "description": "ESLint plugin for html",
5
5
  "author": "yeonjuan",
6
6
  "homepage": "https://github.com/yeonjuan/html-eslint#readme",
@@ -45,11 +45,11 @@
45
45
  "accessibility"
46
46
  ],
47
47
  "devDependencies": {
48
- "@html-eslint/parser": "^0.23.0",
48
+ "@html-eslint/parser": "^0.24.0",
49
49
  "@types/eslint": "^8.56.2",
50
50
  "@types/estree": "^0.0.47",
51
51
  "es-html-parser": "^0.0.8",
52
52
  "typescript": "^4.4.4"
53
53
  },
54
- "gitHead": "4399086819b9c93546fe3b16493638a84ac362c0"
54
+ "gitHead": "1e0611bef4b126819ae09ae9ec28b8808f524bd8"
55
55
  }
@@ -0,0 +1,3 @@
1
+ declare const _exports: string[];
2
+ export = _exports;
3
+ //# sourceMappingURL=svg-camel-case-attributes.d.ts.map
@@ -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,3 @@
1
+ declare const _exports: string[];
2
+ export = _exports;
3
+ //# sourceMappingURL=svg-camelcase-attributes.d.ts.map
@@ -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":"id-naming-convention.d.ts","sourceRoot":"","sources":["../../lib/rules/id-naming-convention.js"],"names":[],"mappings":"wBAoCU,UAAU;;yBAnCN,OAAO,UAAU,EAAE,UAAU;sBAC7B,OAAO,UAAU,EAAE,OAAO;4BAC1B,OAAO,UAAU,EAAE,aAAa;2BAChC,OAAO,UAAU,EAAE,YAAY"}
@@ -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"}