@html-eslint/eslint-plugin 0.34.0-alpha.0 → 0.34.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.
- package/lib/rules/id-naming-convention.js +8 -7
- package/lib/rules/no-duplicate-attrs.js +2 -2
- package/lib/rules/utils/node.js +1 -13
- package/package.json +5 -5
- package/types/rules/id-naming-convention.d.ts.map +1 -1
- package/types/rules/utils/node.d.ts +2 -7
- package/types/rules/utils/node.d.ts.map +1 -1
|
@@ -12,11 +12,7 @@ const {
|
|
|
12
12
|
isPascalCase,
|
|
13
13
|
isKebabCase,
|
|
14
14
|
} = require("./utils/naming");
|
|
15
|
-
const {
|
|
16
|
-
findAttr,
|
|
17
|
-
isAttributesEmpty,
|
|
18
|
-
isExpressionInTemplate,
|
|
19
|
-
} = require("./utils/node");
|
|
15
|
+
const { findAttr, isAttributesEmpty, hasTemplate } = require("./utils/node");
|
|
20
16
|
const { createVisitors } = require("./utils/visitors");
|
|
21
17
|
|
|
22
18
|
const MESSAGE_IDS = {
|
|
@@ -94,7 +90,12 @@ module.exports = {
|
|
|
94
90
|
return;
|
|
95
91
|
}
|
|
96
92
|
const idAttr = findAttr(node, "id");
|
|
97
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
idAttr &&
|
|
95
|
+
idAttr.value &&
|
|
96
|
+
!hasTemplate(idAttr.value) &&
|
|
97
|
+
!checkNaming(idAttr.value.value)
|
|
98
|
+
) {
|
|
98
99
|
context.report({
|
|
99
100
|
node: idAttr,
|
|
100
101
|
data: {
|
|
@@ -117,7 +118,7 @@ module.exports = {
|
|
|
117
118
|
if (
|
|
118
119
|
idAttr &&
|
|
119
120
|
idAttr.value &&
|
|
120
|
-
!
|
|
121
|
+
!hasTemplate(idAttr.value) &&
|
|
121
122
|
!checkNaming(idAttr.value.value)
|
|
122
123
|
) {
|
|
123
124
|
context.report({
|
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
if (Array.isArray(node.attributes)) {
|
|
42
42
|
const attrsSet = new Set();
|
|
43
43
|
node.attributes.forEach((attr) => {
|
|
44
|
-
if (attr.key && attrsSet.has(attr.key.value)) {
|
|
44
|
+
if (attr.key && attrsSet.has(attr.key.value.toLowerCase())) {
|
|
45
45
|
context.report({
|
|
46
46
|
node: attr,
|
|
47
47
|
data: {
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
messageId: MESSAGE_IDS.DUPLICATE_ATTRS,
|
|
51
51
|
});
|
|
52
52
|
} else {
|
|
53
|
-
attrsSet.add(attr.key.value);
|
|
53
|
+
attrsSet.add(attr.key.value.toLowerCase());
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
package/lib/rules/utils/node.js
CHANGED
|
@@ -69,7 +69,7 @@ function isOverlapWithTemplates(templates, range) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* @param {AttributeKey} node
|
|
72
|
+
* @param {AttributeKey | AttributeValue} node
|
|
73
73
|
* @returns {boolean}
|
|
74
74
|
*/
|
|
75
75
|
function hasTemplate(node) {
|
|
@@ -150,17 +150,6 @@ function getLocBetween(before, after) {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* @param {AttributeValue} node
|
|
155
|
-
* @return {boolean}
|
|
156
|
-
*/
|
|
157
|
-
function isExpressionInTemplate(node) {
|
|
158
|
-
if (node.type === NODE_TYPES.AttributeValue) {
|
|
159
|
-
return node.value.indexOf("${") === 0;
|
|
160
|
-
}
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
153
|
/**
|
|
165
154
|
* @param {AnyNode} node
|
|
166
155
|
* @returns {node is Tag}
|
|
@@ -257,7 +246,6 @@ module.exports = {
|
|
|
257
246
|
splitToLineNodes,
|
|
258
247
|
getLocBetween,
|
|
259
248
|
findParent,
|
|
260
|
-
isExpressionInTemplate,
|
|
261
249
|
isTag,
|
|
262
250
|
isComment,
|
|
263
251
|
isText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-eslint/eslint-plugin",
|
|
3
|
-
"version": "0.34.0
|
|
3
|
+
"version": "0.34.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
|
"dependencies": {
|
|
48
|
-
"@html-eslint/template-parser": "^0.
|
|
49
|
-
"@html-eslint/template-syntax-parser": "^0.34.0
|
|
48
|
+
"@html-eslint/template-parser": "^0.34.0",
|
|
49
|
+
"@html-eslint/template-syntax-parser": "^0.34.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@html-eslint/parser": "^0.34.0
|
|
52
|
+
"@html-eslint/parser": "^0.34.0",
|
|
53
53
|
"@types/eslint": "^9.6.1",
|
|
54
54
|
"@types/estree": "^0.0.47",
|
|
55
55
|
"es-html-parser": "^1.0.0-alpha.4",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"espree": "^10.3.0",
|
|
58
58
|
"typescript": "^5.7.2"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f0401cc30d1510d6f5c7511280c0a6b9779fea0c"
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-naming-convention.d.ts","sourceRoot":"","sources":["../../lib/rules/id-naming-convention.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"id-naming-convention.d.ts","sourceRoot":"","sources":["../../lib/rules/id-naming-convention.js"],"names":[],"mappings":";;;wBAqCU,UAAU;;kBApCN,OAAO,UAAU,EAAE,UAAU;WAC7B,OAAO,UAAU,EAAE,GAAG;iBACtB,OAAO,UAAU,EAAE,SAAS;gBAC5B,OAAO,UAAU,EAAE,QAAQ"}
|
|
@@ -53,11 +53,6 @@ export function getLocBetween(before: {
|
|
|
53
53
|
* @returns {null | AnyNode}
|
|
54
54
|
*/
|
|
55
55
|
export function findParent(node: Exclude<AnyNode, Line>, predicate: (node: AnyNode) => boolean): null | AnyNode;
|
|
56
|
-
/**
|
|
57
|
-
* @param {AttributeValue} node
|
|
58
|
-
* @return {boolean}
|
|
59
|
-
*/
|
|
60
|
-
export function isExpressionInTemplate(node: AttributeValue): boolean;
|
|
61
56
|
/**
|
|
62
57
|
* @param {AnyNode} node
|
|
63
58
|
* @returns {node is Tag}
|
|
@@ -108,8 +103,8 @@ export function isRangesOverlap(rangeA: Range, rangeB: Range): boolean;
|
|
|
108
103
|
*/
|
|
109
104
|
export function getTemplateTokens(tokens: AnyToken[]): ((CommentContent | Text)["templates"][number])[];
|
|
110
105
|
/**
|
|
111
|
-
* @param {AttributeKey} node
|
|
106
|
+
* @param {AttributeKey | AttributeValue} node
|
|
112
107
|
* @returns {boolean}
|
|
113
108
|
*/
|
|
114
|
-
export function hasTemplate(node: AttributeKey): boolean;
|
|
109
|
+
export function hasTemplate(node: AttributeKey | AttributeValue): boolean;
|
|
115
110
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../lib/rules/utils/node.js"],"names":[],"mappings":"wBACc,OAAO,aAAa,EAAE,SAAS;kBAC/B,OAAO,aAAa,EAAE,GAAG;wBACzB,OAAO,aAAa,EAAE,SAAS;uBAC/B,OAAO,aAAa,EAAE,QAAQ;mBAC9B,OAAO,aAAa,EAAE,IAAI;mBAC1B,OAAO,aAAa,EAAE,IAAI;6BAC1B,OAAO,aAAa,EAAE,cAAc;sBACpC,OAAO,aAAa,EAAE,OAAO;sBAC7B,OAAO,aAAa,EAAE,OAAO;6BAC7B,OAAO,aAAa,EAAE,cAAc;2BACpC,OAAO,aAAa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