@html-eslint/eslint-plugin 0.17.1 → 0.18.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.
@@ -16,7 +16,19 @@ module.exports = {
16
16
  },
17
17
 
18
18
  fixable: true,
19
- schema: [],
19
+ schema: [
20
+ {
21
+ type: "object",
22
+ properties: {
23
+ skip: {
24
+ type: "array",
25
+ items: {
26
+ type: "string",
27
+ },
28
+ },
29
+ },
30
+ },
31
+ ],
20
32
  messages: {
21
33
  [MESSAGE_IDS.EXPECT_NEW_LINE_AFTER]:
22
34
  "There should be a linebreak after {{tag}}.",
@@ -26,6 +38,11 @@ module.exports = {
26
38
  },
27
39
 
28
40
  create(context) {
41
+ const option = context.options[0] || { skip: [] };
42
+ const skipTags = option.skip;
43
+
44
+ let isInSkipTags = false;
45
+
29
46
  function checkSiblings(siblings) {
30
47
  siblings
31
48
  .filter((node) => node.type !== "Text")
@@ -78,10 +95,24 @@ module.exports = {
78
95
  }
79
96
  return {
80
97
  [["Tag", "Program"].join(",")](node) {
98
+ if (isInSkipTags) {
99
+ return;
100
+ }
101
+
81
102
  const children = node.type === "Program" ? node.body : node.children;
82
103
  checkSiblings(children);
104
+ if (skipTags.includes(node.name)) {
105
+ isInSkipTags = true;
106
+ return;
107
+ }
83
108
  checkChild(node, children);
84
109
  },
110
+ "Tag:exit"(node) {
111
+ if (skipTags.includes(node.name)) {
112
+ isInSkipTags = false;
113
+ return;
114
+ }
115
+ },
85
116
  };
86
117
  },
87
118
  };
@@ -27,7 +27,7 @@ const INDENT_TYPES = {
27
27
  SPACE: "space",
28
28
  };
29
29
 
30
- const IGNORING_NODES = ["pre", "xmp", "script", "style"];
30
+ const IGNORING_NODES = ["pre", "xmp"];
31
31
 
32
32
  /**
33
33
  * @type {Rule}
@@ -223,6 +223,14 @@ module.exports = {
223
223
  }
224
224
  indent();
225
225
  },
226
+ ScriptTag: indent,
227
+ "ScriptTag:exit": unindent,
228
+ OpenScriptTagStart: checkIndent,
229
+ OpenScriptTagEnd: checkIndent,
230
+ StyleTag: indent,
231
+ "StyleTag:exit": unindent,
232
+ OpenStyleTagStart: checkIndent,
233
+ OpenStyleTagEnd: checkIndent,
226
234
  OpenTagStart: checkIndent,
227
235
  OpenTagEnd: checkIndent,
228
236
  CloseTag: checkIndent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-eslint/eslint-plugin",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "ESLint plugin for html",
5
5
  "author": "yeonjuan",
6
6
  "homepage": "https://github.com/yeonjuan/html-eslint#readme",
@@ -40,11 +40,11 @@
40
40
  "accessibility"
41
41
  ],
42
42
  "devDependencies": {
43
- "@html-eslint/parser": "^0.17.1",
43
+ "@html-eslint/parser": "^0.18.0",
44
44
  "@types/eslint": "^7.2.10",
45
45
  "@types/estree": "^0.0.47",
46
46
  "es-html-parser": "^0.0.8",
47
47
  "typescript": "^4.4.4"
48
48
  },
49
- "gitHead": "2df409b76006ec7f9b6bb971d07c2ed8aeb42c7f"
49
+ "gitHead": "81c110ef8ac1bf444ead6e3df07459a2d80fd2ed"
50
50
  }