@html-eslint/eslint-plugin 0.47.1 → 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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-eslint/eslint-plugin",
3
- "version": "0.47.1",
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.1",
44
- "@html-eslint/template-parser": "^0.47.1",
45
- "@html-eslint/template-syntax-parser": "^0.47.1",
46
- "@html-eslint/types": "^0.47.1"
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"
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
61
61
  },
62
- "gitHead": "9f998c473f62f6e86b8c1d8cc30015bea04ddac4"
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"}