@html-eslint/eslint-plugin 0.47.0 → 0.48.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.
@@ -18,6 +18,7 @@
18
18
  * @typedef {Object} Option2
19
19
  * @property {number} [Option2.Attribute]
20
20
  * @property {Record<string, number>} [Option2.tagChildrenIndent]
21
+ * @property {boolean} [Option2.ignoreComment]
21
22
  */
22
23
 
23
24
  const { parseTemplateLiteral } = require("../utils/template-literal");
@@ -97,6 +98,10 @@ module.exports = {
97
98
  },
98
99
  additionalProperties: false,
99
100
  },
101
+ ignoreComment: {
102
+ type: "boolean",
103
+ default: false,
104
+ },
100
105
  },
101
106
  additionalProperties: false,
102
107
  },
@@ -110,6 +115,7 @@ module.exports = {
110
115
  const sourceCode = getSourceCode(context);
111
116
  const indentLevelOptions = (context.options && context.options[1]) || {};
112
117
  const lines = sourceCode.getLines();
118
+ const ignoreComment = indentLevelOptions.ignoreComment === true;
113
119
  const { indentType, indentSize, indentChar } = getIndentOptionInfo(context);
114
120
 
115
121
  /**
@@ -265,6 +271,48 @@ module.exports = {
265
271
  }
266
272
  }
267
273
 
274
+ /**
275
+ * @type {RuleListener}
276
+ */
277
+ const commentVisitor = {
278
+ Comment(node) {
279
+ indentLevel.indent(node);
280
+ },
281
+ CommentOpen: checkIndent,
282
+ CommentContent(node) {
283
+ indentLevel.indent(node);
284
+ if (hasTemplate(node)) {
285
+ node.parts.forEach((part) => {
286
+ if (part.type !== NODE_TYPES.Part) {
287
+ if (part.open) {
288
+ checkIndent(part.open);
289
+ }
290
+ if (part.close) {
291
+ checkIndent(part.close);
292
+ }
293
+ }
294
+ });
295
+ }
296
+
297
+ const lineNodes = splitToLineNodes(node);
298
+ lineNodes.forEach((lineNode) => {
299
+ if (lineNode.hasTemplate) {
300
+ return;
301
+ }
302
+ if (lineNode.value.trim().length) {
303
+ checkIndent(lineNode);
304
+ }
305
+ });
306
+ },
307
+ CommentClose: checkIndent,
308
+ "Comment:exit"(node) {
309
+ indentLevel.dedent(node);
310
+ },
311
+ "CommentContent:exit"(node) {
312
+ indentLevel.dedent(node);
313
+ },
314
+ };
315
+
268
316
  /**
269
317
  * @type {RuleListener}
270
318
  */
@@ -342,42 +390,7 @@ module.exports = {
342
390
  "Text:exit"(node) {
343
391
  indentLevel.dedent(node);
344
392
  },
345
- Comment(node) {
346
- indentLevel.indent(node);
347
- },
348
- CommentOpen: checkIndent,
349
- CommentContent(node) {
350
- indentLevel.indent(node);
351
- if (hasTemplate(node)) {
352
- node.parts.forEach((part) => {
353
- if (part.type !== NODE_TYPES.Part) {
354
- if (part.open) {
355
- checkIndent(part.open);
356
- }
357
- if (part.close) {
358
- checkIndent(part.close);
359
- }
360
- }
361
- });
362
- }
363
-
364
- const lineNodes = splitToLineNodes(node);
365
- lineNodes.forEach((lineNode) => {
366
- if (lineNode.hasTemplate) {
367
- return;
368
- }
369
- if (lineNode.value.trim().length) {
370
- checkIndent(lineNode);
371
- }
372
- });
373
- },
374
- CommentClose: checkIndent,
375
- "Comment:exit"(node) {
376
- indentLevel.dedent(node);
377
- },
378
- "CommentContent:exit"(node) {
379
- indentLevel.dedent(node);
380
- },
393
+ ...(ignoreComment ? {} : commentVisitor),
381
394
  };
382
395
  return visitor;
383
396
  }
@@ -40,7 +40,7 @@ module.exports = {
40
40
 
41
41
  return {
42
42
  Tag(node) {
43
- if (!["h1", "h2", "h3", "h5", "h6"].includes(node.name)) {
43
+ if (!["h1", "h2", "h3", "h4", "h5", "h6"].includes(node.name)) {
44
44
  return;
45
45
  }
46
46
  headings.push({
@@ -49,7 +49,6 @@ const elements = new Map([
49
49
  ["article", "10:2015"],
50
50
  ["aside", "10:2015"],
51
51
  ["audio", "10:2015"],
52
- ["audio.autoplay", "0:"],
53
52
  ["audio.controls", "10:2015"],
54
53
  ["audio.controlslist", "0:"],
55
54
  ["audio.crossorigin", "10:2020"],
@@ -98,7 +97,7 @@ const elements = new Map([
98
97
  ["col.align", "0:"],
99
98
  ["col.char", "0:"],
100
99
  ["col.charoff", "0:"],
101
- ["col.span", "10:2015"],
100
+ ["col.span", "0:"],
102
101
  ["col.valign", "0:"],
103
102
  ["col.width", "0:"],
104
103
  ["colgroup", "10:2015"],
@@ -422,7 +421,7 @@ const elements = new Map([
422
421
  ["script.referrerpolicy.unsafe-url", "0:"],
423
422
  ["script.src", "10:2015"],
424
423
  ["script.type", "10:2015"],
425
- ["script.type.importmap", "5:2023"],
424
+ ["script.type.importmap", "10:2023"],
426
425
  ["script.type.module", "10:2018"],
427
426
  ["script.type.speculationrules", "0:"],
428
427
  ["script.type.speculationrules.eagerness", "0:"],
@@ -589,12 +588,12 @@ const globalAttributes = new Map([
589
588
  ["accesskey", "10:2015"],
590
589
  ["autocapitalize", "0:"],
591
590
  ["autocorrect", "0:"],
592
- ["autofocus", "5:2023"],
591
+ ["autofocus", "10:2023"],
593
592
  ["contenteditable", "10:2015"],
594
593
  ["contenteditable.plaintext-only", "5:2025"],
595
594
  ["enterkeyhint", "10:2021"],
596
595
  ["exportparts", "10:2020"],
597
- ["inert", "5:2023"],
596
+ ["inert", "10:2023"],
598
597
  ["inert.ignores_find_in_page", "0:"],
599
598
  ["inputmode", "10:2021"],
600
599
  ["is", "0:"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-eslint/eslint-plugin",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for HTML",
6
6
  "author": "yeonjuan",
@@ -40,10 +40,10 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@eslint/plugin-kit": "^0.3.1",
43
- "@html-eslint/parser": "^0.47.0",
44
- "@html-eslint/template-parser": "^0.47.0",
45
- "@html-eslint/template-syntax-parser": "^0.47.0",
46
- "@html-eslint/types": "^0.47.0"
43
+ "@html-eslint/parser": "^0.48.0",
44
+ "@html-eslint/template-parser": "^0.48.0",
45
+ "@html-eslint/template-syntax-parser": "^0.48.0",
46
+ "@html-eslint/types": "^0.48.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "eslint": "^8.0.0 || ^9.0.0"
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@eslint/core": "^0.14.0",
53
53
  "@types/estree": "^0.0.47",
54
- "es-html-parser": "0.3.0",
54
+ "es-html-parser": "0.3.1",
55
55
  "eslint": "^9.27.0",
56
56
  "espree": "^10.3.0",
57
57
  "typescript": "^5.8.3"
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
61
61
  },
62
- "gitHead": "caaddba72ff95d1f3a0aa3e4896d797b94f0c079"
62
+ "gitHead": "e88504c082ac41e59e4b82e1c9da5ff780114508"
63
63
  }
@@ -20,6 +20,7 @@ type Option1 = "tab" | number;
20
20
  type Option2 = {
21
21
  Attribute?: number | undefined;
22
22
  tagChildrenIndent?: Record<string, number> | undefined;
23
+ ignoreComment?: boolean | undefined;
23
24
  };
24
25
  import type { RuleModule } from "../../types";
25
26
  import type { AnyNode } from "@html-eslint/types";
@@ -1 +1 @@
1
- {"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../../lib/rules/indent/indent.js"],"names":[],"mappings":";;;wBAuDU,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;;qBAlD3B,OAAO,GAAG,IAAI;;SAEb,KAAK;WACL,OAAO;;;kBAEP,aAAa;;;gBAEb,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC;gBACvC,MAAM;gBACN,MAAM;;eAEP,KAAK,GAAG,MAAM;;;;;gCAd+B,aAAa;6BAD+C,oBAAoB;0BAChF,aAAa"}
1
+ {"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../../lib/rules/indent/indent.js"],"names":[],"mappings":";;;wBAwDU,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;;qBAnD3B,OAAO,GAAG,IAAI;;SAEb,KAAK;WACL,OAAO;;;kBAEP,aAAa;;;gBAEb,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC;gBACvC,MAAM;gBACN,MAAM;;eAEP,KAAK,GAAG,MAAM;;;;;;gCAd+B,aAAa;6BAD+C,oBAAoB;0BAChF,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../../lib/rules/utils/baseline.js"],"names":[],"mappings":"AAOA,2CAmkBG;AACH,mDA4BG;AAvmBH;;GAEG;AACH,4BAAsB,EAAE,CAAC;AACzB,2BAAqB,CAAC,CAAC;AACvB,6BAAuB,CAAC,CAAC"}
1
+ {"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../../lib/rules/utils/baseline.js"],"names":[],"mappings":"AAOA,2CAkkBG;AACH,mDA4BG;AAtmBH;;GAEG;AACH,4BAAsB,EAAE,CAAC;AACzB,2BAAqB,CAAC,CAAC;AACvB,6BAAuB,CAAC,CAAC"}