@html-eslint/eslint-plugin 0.34.0 → 0.35.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/element-newline.js +158 -153
- package/lib/rules/indent/indent.js +41 -6
- package/lib/rules/no-aria-hidden-body.js +1 -1
- package/lib/rules/no-extra-spacing-attrs.js +2 -1
- package/lib/rules/no-extra-spacing-text.js +1 -2
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- package/lib/rules/no-positive-tabindex.js +1 -1
- package/lib/rules/no-target-blank.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/prefer-https.js +3 -2
- package/lib/rules/quotes.js +2 -1
- package/lib/rules/require-button-type.js +1 -1
- package/lib/rules/require-form-method.js +3 -2
- package/lib/rules/utils/node.js +31 -17
- package/lib/types/ast.d.ts +10 -1
- package/package.json +8 -8
- package/types/rules/element-newline.d.ts +4 -7
- package/types/rules/element-newline.d.ts.map +1 -1
- package/types/rules/indent/indent.d.ts +4 -1
- package/types/rules/indent/indent.d.ts.map +1 -1
- package/types/rules/no-extra-spacing-attrs.d.ts.map +1 -1
- package/types/rules/prefer-https.d.ts.map +1 -1
- package/types/rules/quotes.d.ts.map +1 -1
- package/types/rules/require-form-method.d.ts.map +1 -1
- package/types/rules/utils/node.d.ts +17 -8
- package/types/rules/utils/node.d.ts.map +1 -1
- package/types/rules/indent.d.ts +0 -22
- package/types/rules/indent.d.ts.map +0 -1
- package/types/types/settings.d.ts +0 -13
- package/types/types/settings.d.ts.map +0 -1
|
@@ -6,22 +6,24 @@
|
|
|
6
6
|
* @typedef { import("../types").ScriptTag } ScriptTag
|
|
7
7
|
* @typedef { import("../types").StyleTag } StyleTag
|
|
8
8
|
* @typedef { import("../types").Text } Text
|
|
9
|
-
* @typedef {
|
|
10
|
-
* @typedef {
|
|
11
|
-
*
|
|
12
|
-
* childLast: NewlineNode | null;
|
|
13
|
-
* shouldBeNewline: boolean;
|
|
14
|
-
* }} NodeMeta
|
|
9
|
+
* @typedef { import("../types").AnyNode } AnyNode
|
|
10
|
+
* @typedef { import("../types").OpenTagEnd } OpenTagEnd
|
|
11
|
+
* @typedef { import("../types").CloseTag } CloseTag
|
|
15
12
|
*/
|
|
16
13
|
|
|
17
14
|
const { RULE_CATEGORY } = require("../constants");
|
|
18
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
isTag,
|
|
17
|
+
isComment,
|
|
18
|
+
isText,
|
|
19
|
+
splitToLineNodes,
|
|
20
|
+
isLine,
|
|
21
|
+
isScript,
|
|
22
|
+
isStyle,
|
|
23
|
+
} = require("./utils/node");
|
|
19
24
|
const { createVisitors } = require("./utils/visitors");
|
|
20
25
|
const MESSAGE_IDS = {
|
|
21
26
|
EXPECT_NEW_LINE_AFTER: "expectAfter",
|
|
22
|
-
EXPECT_NEW_LINE_AFTER_OPEN: "expectAfterOpen",
|
|
23
|
-
EXPECT_NEW_LINE_BEFORE: "expectBefore",
|
|
24
|
-
EXPECT_NEW_LINE_BEFORE_CLOSE: "expectBeforeClose",
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -100,167 +102,169 @@ module.exports = {
|
|
|
100
102
|
],
|
|
101
103
|
messages: {
|
|
102
104
|
[MESSAGE_IDS.EXPECT_NEW_LINE_AFTER]:
|
|
103
|
-
"There should be a linebreak after {{
|
|
104
|
-
[MESSAGE_IDS.EXPECT_NEW_LINE_AFTER_OPEN]:
|
|
105
|
-
"There should be a linebreak after {{tag}} open.",
|
|
106
|
-
[MESSAGE_IDS.EXPECT_NEW_LINE_BEFORE]:
|
|
107
|
-
"There should be a linebreak before {{tag}} element.",
|
|
108
|
-
[MESSAGE_IDS.EXPECT_NEW_LINE_BEFORE_CLOSE]:
|
|
109
|
-
"There should be a linebreak before {{tag}} close.",
|
|
105
|
+
"There should be a linebreak after {{name}}.",
|
|
110
106
|
},
|
|
111
107
|
},
|
|
112
108
|
|
|
113
109
|
create(context) {
|
|
114
110
|
const option = context.options[0] || {};
|
|
115
|
-
|
|
111
|
+
/**
|
|
112
|
+
* @type {string[]}
|
|
113
|
+
*/
|
|
114
|
+
const skipTags = option.skip || ["pre", "code"];
|
|
116
115
|
const inlineTags = optionsOrPresets(option.inline || []);
|
|
117
116
|
|
|
118
117
|
/**
|
|
119
|
-
* @param {
|
|
120
|
-
* @returns {
|
|
118
|
+
* @param {AnyNode[]} children
|
|
119
|
+
* @returns {Exclude<AnyNode, Text>[]}
|
|
121
120
|
*/
|
|
122
|
-
function
|
|
121
|
+
function getChildrenToCheck(children) {
|
|
123
122
|
/**
|
|
124
|
-
* @type {
|
|
123
|
+
* @type {Exclude<AnyNode, Text>[]}
|
|
125
124
|
*/
|
|
126
|
-
const
|
|
127
|
-
childFirst: null,
|
|
128
|
-
childLast: null,
|
|
129
|
-
shouldBeNewline: false,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const nodesWithContent = [];
|
|
133
|
-
for (
|
|
134
|
-
let length = siblings.length, index = 0;
|
|
135
|
-
index < length;
|
|
136
|
-
index += 1
|
|
137
|
-
) {
|
|
138
|
-
const node = siblings[index];
|
|
125
|
+
const childrenToCheck = [];
|
|
139
126
|
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
for (const child of children) {
|
|
128
|
+
if (isText(child)) {
|
|
129
|
+
const lines = splitToLineNodes(child);
|
|
130
|
+
childrenToCheck.push(...lines);
|
|
131
|
+
continue;
|
|
142
132
|
}
|
|
133
|
+
childrenToCheck.push(child);
|
|
143
134
|
}
|
|
135
|
+
return childrenToCheck.filter((child) => !isEmptyText(child));
|
|
136
|
+
}
|
|
144
137
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
/**
|
|
139
|
+
* @param {AnyNode} before
|
|
140
|
+
* @param {AnyNode} after
|
|
141
|
+
* @returns {boolean}
|
|
142
|
+
*/
|
|
143
|
+
function isOnTheSameLine(before, after) {
|
|
144
|
+
return before.loc.end.line === after.loc.start.line;
|
|
145
|
+
}
|
|
152
146
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
/**
|
|
148
|
+
* @param {AnyNode} node
|
|
149
|
+
* @returns {boolean}
|
|
150
|
+
*/
|
|
151
|
+
function shouldSkipChildren(node) {
|
|
152
|
+
if (isTag(node) && skipTags.includes(node.name.toLowerCase())) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
156
157
|
|
|
157
|
-
|
|
158
|
+
/**
|
|
159
|
+
* @param {AnyNode} node
|
|
160
|
+
* @returns {boolean}
|
|
161
|
+
*/
|
|
162
|
+
function isInline(node) {
|
|
163
|
+
return (
|
|
164
|
+
isLine(node) ||
|
|
165
|
+
(isTag(node) && inlineTags.includes(node.name.toLowerCase()))
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param {AnyNode[]} children
|
|
171
|
+
* @param {AnyNode} parent
|
|
172
|
+
* @param {[OpenTagEnd, CloseTag]} [wrapper]
|
|
173
|
+
*/
|
|
174
|
+
function checkChildren(children, parent, wrapper) {
|
|
175
|
+
if (shouldSkipChildren(parent)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
158
178
|
|
|
159
|
-
|
|
179
|
+
const childrenToCheck = getChildrenToCheck(children);
|
|
180
|
+
const firstChild = childrenToCheck[0];
|
|
181
|
+
if (
|
|
182
|
+
wrapper &&
|
|
183
|
+
firstChild &&
|
|
184
|
+
childrenToCheck.some((child) => !isInline(child))
|
|
185
|
+
) {
|
|
186
|
+
const open = wrapper[0];
|
|
187
|
+
if (isOnTheSameLine(open, firstChild)) {
|
|
188
|
+
context.report({
|
|
189
|
+
node: open,
|
|
190
|
+
messageId: MESSAGE_IDS.EXPECT_NEW_LINE_AFTER,
|
|
191
|
+
data: { name: getName(parent) },
|
|
192
|
+
fix(fixer) {
|
|
193
|
+
return fixer.insertTextAfter(open, `\n`);
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
160
198
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const nodeChildShouldBeNewline = nodeMeta.shouldBeNewline;
|
|
199
|
+
childrenToCheck.forEach((current, index) => {
|
|
200
|
+
const next = childrenToCheck[index + 1];
|
|
164
201
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
202
|
+
if (
|
|
203
|
+
!next ||
|
|
204
|
+
!isOnTheSameLine(current, next) ||
|
|
205
|
+
(isInline(current) && isInline(next))
|
|
206
|
+
) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
168
209
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (isNotNewlineStart(nodeMeta.childFirst)) {
|
|
179
|
-
context.report({
|
|
180
|
-
node: node,
|
|
181
|
-
messageId: MESSAGE_IDS.EXPECT_NEW_LINE_AFTER_OPEN,
|
|
182
|
-
data: { tag: label(node) },
|
|
183
|
-
fix(fixer) {
|
|
184
|
-
return fixer.insertTextAfter(node.openEnd, `\n`);
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
210
|
+
context.report({
|
|
211
|
+
node: current,
|
|
212
|
+
messageId: MESSAGE_IDS.EXPECT_NEW_LINE_AFTER,
|
|
213
|
+
data: { name: getName(current, { isClose: true }) },
|
|
214
|
+
fix(fixer) {
|
|
215
|
+
return fixer.insertTextAfter(current, `\n`);
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
});
|
|
189
219
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
fix(fixer) {
|
|
200
|
-
return fixer.insertTextBefore(node.close, `\n`);
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
220
|
+
childrenToCheck.forEach((child) => {
|
|
221
|
+
if (isTag(child)) {
|
|
222
|
+
/**
|
|
223
|
+
* @type {[OpenTagEnd, CloseTag] | undefined}
|
|
224
|
+
*/
|
|
225
|
+
const wrapper = child.close
|
|
226
|
+
? [child.openEnd, child.close]
|
|
227
|
+
: undefined;
|
|
228
|
+
checkChildren(child.children, child, wrapper);
|
|
206
229
|
}
|
|
230
|
+
});
|
|
207
231
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
messageId: MESSAGE_IDS.EXPECT_NEW_LINE_BEFORE,
|
|
225
|
-
data: { tag: label(nodeNext) },
|
|
226
|
-
fix(fixer) {
|
|
227
|
-
return fixer.insertTextBefore(nodeNext, `\n`);
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
+
const lastChild = childrenToCheck[childrenToCheck.length - 1];
|
|
233
|
+
if (
|
|
234
|
+
wrapper &&
|
|
235
|
+
lastChild &&
|
|
236
|
+
childrenToCheck.some((child) => !isInline(child))
|
|
237
|
+
) {
|
|
238
|
+
const close = wrapper[1];
|
|
239
|
+
if (isOnTheSameLine(close, lastChild)) {
|
|
240
|
+
context.report({
|
|
241
|
+
node: lastChild,
|
|
242
|
+
messageId: MESSAGE_IDS.EXPECT_NEW_LINE_AFTER,
|
|
243
|
+
data: { name: getName(lastChild, { isClose: true }) },
|
|
244
|
+
fix(fixer) {
|
|
245
|
+
return fixer.insertTextAfter(lastChild, `\n`);
|
|
246
|
+
},
|
|
247
|
+
});
|
|
232
248
|
}
|
|
233
249
|
}
|
|
234
|
-
|
|
235
|
-
return meta;
|
|
236
250
|
}
|
|
237
251
|
|
|
238
252
|
/**
|
|
239
|
-
* @param {
|
|
253
|
+
* @param {AnyNode} node
|
|
254
|
+
* @returns {boolean}
|
|
240
255
|
*/
|
|
241
256
|
function isEmptyText(node) {
|
|
242
|
-
return
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* @param {NewlineNode} node
|
|
247
|
-
*/
|
|
248
|
-
function isNotNewlineEnd(node) {
|
|
249
|
-
return node.type !== `Text` || /(\n|\r\n)\s*$/.test(node.value) === false;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* @param {NewlineNode} node
|
|
254
|
-
*/
|
|
255
|
-
function isNotNewlineStart(node) {
|
|
256
|
-
return node.type !== `Text` || /^(\n|\r\n)/.test(node.value) === false;
|
|
257
|
+
return (
|
|
258
|
+
(isText(node) && node.value.trim().length === 0) ||
|
|
259
|
+
(isLine(node) && node.value.trim().length === 0)
|
|
260
|
+
);
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
/**
|
|
260
|
-
* @param {
|
|
264
|
+
* @param {AnyNode} node
|
|
261
265
|
* @param {{ isClose?: boolean }} options
|
|
262
266
|
*/
|
|
263
|
-
function
|
|
267
|
+
function getName(node, options = {}) {
|
|
264
268
|
const isClose = options.isClose || false;
|
|
265
269
|
if (isTag(node)) {
|
|
266
270
|
if (isClose) {
|
|
@@ -268,6 +272,24 @@ module.exports = {
|
|
|
268
272
|
}
|
|
269
273
|
return `<${node.name}>`;
|
|
270
274
|
}
|
|
275
|
+
if (isLine(node)) {
|
|
276
|
+
return "text";
|
|
277
|
+
}
|
|
278
|
+
if (isComment(node)) {
|
|
279
|
+
return "comment";
|
|
280
|
+
}
|
|
281
|
+
if (isScript(node)) {
|
|
282
|
+
if (isClose) {
|
|
283
|
+
return `</script>`;
|
|
284
|
+
}
|
|
285
|
+
return "<script>";
|
|
286
|
+
}
|
|
287
|
+
if (isStyle(node)) {
|
|
288
|
+
if (isClose) {
|
|
289
|
+
return `</style>`;
|
|
290
|
+
}
|
|
291
|
+
return "<style>";
|
|
292
|
+
}
|
|
271
293
|
return `<${node.type}>`;
|
|
272
294
|
}
|
|
273
295
|
|
|
@@ -287,26 +309,9 @@ module.exports = {
|
|
|
287
309
|
return result;
|
|
288
310
|
}
|
|
289
311
|
|
|
290
|
-
/**
|
|
291
|
-
* @param {NewlineNode} node
|
|
292
|
-
*/
|
|
293
|
-
function shouldBeNewline(node) {
|
|
294
|
-
if (isComment(node)) {
|
|
295
|
-
return /[\n\r]+/.test(node.value.value.trim());
|
|
296
|
-
}
|
|
297
|
-
if (isTag(node)) {
|
|
298
|
-
return inlineTags.includes(node.name.toLowerCase()) === false;
|
|
299
|
-
}
|
|
300
|
-
if (isText(node)) {
|
|
301
|
-
return /[\n\r]+/.test(node.value.trim());
|
|
302
|
-
}
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
312
|
return createVisitors(context, {
|
|
307
313
|
Document(node) {
|
|
308
|
-
|
|
309
|
-
checkSiblings(node.children);
|
|
314
|
+
checkChildren(node.children, node);
|
|
310
315
|
},
|
|
311
316
|
});
|
|
312
317
|
},
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
* @typedef { import("../../types").Tag } Tag
|
|
6
6
|
* @typedef { import("../../types").RuleListener } RuleListener
|
|
7
7
|
* @typedef { import("../../types").Context } Context
|
|
8
|
+
* @typedef { import("../../types").TemplateText } TemplateText
|
|
8
9
|
* @typedef { import("eslint").AST.Token } Token
|
|
9
10
|
* @typedef { import("eslint").SourceCode } SourceCode
|
|
10
11
|
* @typedef { import("eslint").AST.Range } Range
|
|
11
12
|
* @typedef { import("eslint").AST.SourceLocation } SourceLocation
|
|
12
13
|
* @typedef { import("../../types").TemplateLiteral } TemplateLiteral
|
|
14
|
+
* @typedef { import("../../types").OpenTemplate } OpenTemplate
|
|
15
|
+
* @typedef { import("../../types").CloseTemplate } CloseTemplate
|
|
13
16
|
*
|
|
14
17
|
*
|
|
15
18
|
* @typedef {Object} IndentType
|
|
@@ -24,8 +27,14 @@
|
|
|
24
27
|
*/
|
|
25
28
|
|
|
26
29
|
const { parse } = require("@html-eslint/template-parser");
|
|
30
|
+
const { NodeTypes } = require("es-html-parser");
|
|
27
31
|
const { RULE_CATEGORY } = require("../../constants");
|
|
28
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
splitToLineNodes,
|
|
34
|
+
isLine,
|
|
35
|
+
isTag,
|
|
36
|
+
hasTemplate,
|
|
37
|
+
} = require("../utils/node");
|
|
29
38
|
const {
|
|
30
39
|
shouldCheckTaggedTemplateExpression,
|
|
31
40
|
shouldCheckTemplateLiteral,
|
|
@@ -173,7 +182,7 @@ module.exports = {
|
|
|
173
182
|
let parentIgnoringChildCount = 0;
|
|
174
183
|
|
|
175
184
|
/**
|
|
176
|
-
* @param {AnyNode | Line} node
|
|
185
|
+
* @param {AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate} node
|
|
177
186
|
* @returns {string}
|
|
178
187
|
*/
|
|
179
188
|
function getActualIndent(node) {
|
|
@@ -228,7 +237,7 @@ module.exports = {
|
|
|
228
237
|
}
|
|
229
238
|
|
|
230
239
|
/**
|
|
231
|
-
* @param {AnyNode | Line} node
|
|
240
|
+
* @param {AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate} node
|
|
232
241
|
*/
|
|
233
242
|
function checkIndent(node) {
|
|
234
243
|
if (parentIgnoringChildCount > 0) {
|
|
@@ -303,10 +312,23 @@ module.exports = {
|
|
|
303
312
|
},
|
|
304
313
|
Text(node) {
|
|
305
314
|
indentLevel.indent(node);
|
|
315
|
+
if (hasTemplate(node)) {
|
|
316
|
+
node.parts.forEach((part) => {
|
|
317
|
+
if (part.type !== NodeTypes.Part) {
|
|
318
|
+
if (part.open) {
|
|
319
|
+
checkIndent(part.open);
|
|
320
|
+
}
|
|
321
|
+
if (part.close) {
|
|
322
|
+
checkIndent(part.close);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
306
328
|
const lineNodes = splitToLineNodes(node);
|
|
307
329
|
|
|
308
330
|
lineNodes.forEach((lineNode) => {
|
|
309
|
-
if (lineNode.
|
|
331
|
+
if (lineNode.hasTemplate) {
|
|
310
332
|
return;
|
|
311
333
|
}
|
|
312
334
|
if (lineNode.value.trim().length) {
|
|
@@ -323,9 +345,22 @@ module.exports = {
|
|
|
323
345
|
CommentOpen: checkIndent,
|
|
324
346
|
CommentContent(node) {
|
|
325
347
|
indentLevel.indent(node);
|
|
348
|
+
if (hasTemplate(node)) {
|
|
349
|
+
node.parts.forEach((part) => {
|
|
350
|
+
if (part.type !== NodeTypes.Part) {
|
|
351
|
+
if (part.open) {
|
|
352
|
+
checkIndent(part.open);
|
|
353
|
+
}
|
|
354
|
+
if (part.close) {
|
|
355
|
+
checkIndent(part.close);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
326
361
|
const lineNodes = splitToLineNodes(node);
|
|
327
362
|
lineNodes.forEach((lineNode) => {
|
|
328
|
-
if (lineNode.
|
|
363
|
+
if (lineNode.hasTemplate) {
|
|
329
364
|
return;
|
|
330
365
|
}
|
|
331
366
|
if (lineNode.value.trim().length) {
|
|
@@ -363,7 +398,7 @@ module.exports = {
|
|
|
363
398
|
};
|
|
364
399
|
|
|
365
400
|
/**
|
|
366
|
-
* @param {AnyNode | Line} node
|
|
401
|
+
* @param {AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate} node
|
|
367
402
|
* @param {string} actualIndent
|
|
368
403
|
* @return {{range: Range; loc: SourceLocation}}
|
|
369
404
|
*/
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
const { RULE_CATEGORY } = require("../constants");
|
|
17
17
|
const { getLocBetween } = require("./utils/node");
|
|
18
|
+
const { getSourceCode } = require("./utils/source-code");
|
|
18
19
|
const { createVisitors } = require("./utils/visitors");
|
|
19
20
|
|
|
20
21
|
const MESSAGE_IDS = {
|
|
@@ -92,7 +93,7 @@ module.exports = {
|
|
|
92
93
|
const disallowInAssignment = !!(context.options[0] || [])
|
|
93
94
|
.disallowInAssignment;
|
|
94
95
|
|
|
95
|
-
const sourceCode =
|
|
96
|
+
const sourceCode = getSourceCode(context).text;
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* @param {Attribute[]} attrs
|
|
@@ -88,7 +88,6 @@ module.exports = {
|
|
|
88
88
|
const text = node.value;
|
|
89
89
|
const matcher = /(^|[^\n \t])([ \t]+\n|\t[\t ]*|[ \t]{2,})/g;
|
|
90
90
|
|
|
91
|
-
// eslint-disable-next-line no-constant-condition
|
|
92
91
|
while (true) {
|
|
93
92
|
const offender = matcher.exec(text);
|
|
94
93
|
if (offender === null) {
|
|
@@ -99,7 +98,7 @@ module.exports = {
|
|
|
99
98
|
const indexStart = node.range[0] + matcher.lastIndex - space.length;
|
|
100
99
|
const indexEnd = indexStart + space.length;
|
|
101
100
|
|
|
102
|
-
const hasOverlap = isOverlapWithTemplates(node.
|
|
101
|
+
const hasOverlap = isOverlapWithTemplates(node.parts, [
|
|
103
102
|
indexStart,
|
|
104
103
|
indexEnd,
|
|
105
104
|
]);
|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
|
62
62
|
/**
|
|
63
63
|
* @param {string[]} lines
|
|
64
64
|
* @param {number} lineOffset
|
|
65
|
-
* @param {((CommentContent | Text)['
|
|
65
|
+
* @param {((CommentContent | Text)['parts'][number])[]} tokens
|
|
66
66
|
*/
|
|
67
67
|
function check(lines, lineOffset, tokens) {
|
|
68
68
|
/** @type {number[]} */
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
const href = findAttr(node, "href");
|
|
51
51
|
if (href && href.value && isExternalLink(href.value.value)) {
|
|
52
52
|
const rel = findAttr(node, "rel");
|
|
53
|
-
if (rel && rel.value && rel.value.
|
|
53
|
+
if (rel && rel.value && rel.value.parts.length) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
|
45
45
|
* @param {string} source
|
|
46
46
|
* @param {string[]} lines
|
|
47
47
|
* @param {number} rangeOffset
|
|
48
|
-
* @param {((CommentContent | Text)['
|
|
48
|
+
* @param {((CommentContent | Text)['parts'][number])[]} tokens
|
|
49
49
|
*/
|
|
50
50
|
function check(source, lines, rangeOffset, tokens) {
|
|
51
51
|
let rangeIndex = rangeOffset;
|
|
@@ -20,7 +20,8 @@ const MESSAGE_IDS = {
|
|
|
20
20
|
function getProtocol(url) {
|
|
21
21
|
try {
|
|
22
22
|
return new URL(url).protocol;
|
|
23
|
-
|
|
23
|
+
// eslint-disable-next-line no-unused-vars
|
|
24
|
+
} catch (_) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -87,7 +88,7 @@ module.exports = {
|
|
|
87
88
|
*/
|
|
88
89
|
function check(node) {
|
|
89
90
|
const attributeValue = getResourceAttributeValue(node);
|
|
90
|
-
if (attributeValue && !attributeValue.
|
|
91
|
+
if (attributeValue && !attributeValue.parts.length) {
|
|
91
92
|
const protocol = getProtocol(attributeValue.value);
|
|
92
93
|
if (protocol === "http:") {
|
|
93
94
|
context.report({
|
package/lib/rules/quotes.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const { RULE_CATEGORY } = require("../constants");
|
|
11
|
+
const { getSourceCode } = require("./utils/source-code");
|
|
11
12
|
const { createVisitors } = require("./utils/visitors");
|
|
12
13
|
|
|
13
14
|
const MESSAGE_IDS = {
|
|
@@ -56,7 +57,7 @@ module.exports = {
|
|
|
56
57
|
: QUOTES_STYLES.DOUBLE;
|
|
57
58
|
const expectedQuote = SELECTED_STYLE === QUOTES_STYLES.DOUBLE ? `"` : `'`;
|
|
58
59
|
|
|
59
|
-
const sourceCode =
|
|
60
|
+
const sourceCode = getSourceCode(context);
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* @param {Range} range
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @typedef { import("../types").RuleModule } RuleModule
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
const { NodeTypes } = require("es-html-parser");
|
|
5
6
|
const { RULE_CATEGORY } = require("../constants");
|
|
6
7
|
const { findAttr } = require("./utils/node");
|
|
7
8
|
const { createVisitors } = require("./utils/visitors");
|
|
@@ -63,8 +64,8 @@ module.exports = {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
if (
|
|
66
|
-
method.value.
|
|
67
|
-
method.value.
|
|
67
|
+
method.value.parts &&
|
|
68
|
+
method.value.parts.some((part) => part.type !== NodeTypes.Part)
|
|
68
69
|
) {
|
|
69
70
|
return;
|
|
70
71
|
}
|
package/lib/rules/utils/node.js
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* @typedef { import("../../types").AnyNode } AnyNode
|
|
11
11
|
* @typedef { import("../../types").AttributeValue } AttributeValue
|
|
12
12
|
* @typedef { import("../../types").AttributeKey } AttributeKey
|
|
13
|
+
* @typedef { import("../../types").TemplateText } TemplateText
|
|
14
|
+
* @typedef { import("../../types").OpenTemplate } OpenTemplate
|
|
15
|
+
* @typedef { import("../../types").CloseTemplate } CloseTemplate
|
|
16
|
+
* @typedef { import("../../types").AnyPartNode } AnyPartNode
|
|
13
17
|
* @typedef { import("eslint").AST.Range } Range
|
|
14
18
|
* @typedef { import("eslint").AST.SourceLocation } SourceLocation
|
|
15
19
|
* @typedef { import("es-html-parser").AnyToken } AnyToken
|
|
@@ -17,6 +21,7 @@
|
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
const { NODE_TYPES } = require("@html-eslint/parser");
|
|
24
|
+
const { NodeTypes, TokenTypes } = require("es-html-parser");
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* @param {Tag | ScriptTag | StyleTag} node
|
|
@@ -58,22 +63,22 @@ function isRangesOverlap(rangeA, rangeB) {
|
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
|
-
* @param {(Text | CommentContent)['
|
|
66
|
+
* @param {(Text | CommentContent)['parts']} parts
|
|
62
67
|
* @param {Range} range
|
|
63
68
|
* @returns {boolean}
|
|
64
69
|
*/
|
|
65
|
-
function isOverlapWithTemplates(
|
|
66
|
-
return
|
|
67
|
-
.filter((
|
|
68
|
-
.some((
|
|
70
|
+
function isOverlapWithTemplates(parts, range) {
|
|
71
|
+
return parts
|
|
72
|
+
.filter((part) => part.type !== NodeTypes.Part)
|
|
73
|
+
.some((part) => isRangesOverlap(part.range, range));
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
/**
|
|
72
|
-
* @param {AttributeKey | AttributeValue} node
|
|
77
|
+
* @param {AttributeKey | AttributeValue | Text | CommentContent} node
|
|
73
78
|
* @returns {boolean}
|
|
74
79
|
*/
|
|
75
80
|
function hasTemplate(node) {
|
|
76
|
-
return node.
|
|
81
|
+
return node.parts.some((part) => part.type !== NodeTypes.Part);
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
/**
|
|
@@ -89,15 +94,15 @@ function splitToLineNodes(node) {
|
|
|
89
94
|
* @type {Line[]}
|
|
90
95
|
*/
|
|
91
96
|
const lineNodes = [];
|
|
92
|
-
const
|
|
97
|
+
const parts = node.parts || [];
|
|
93
98
|
/**
|
|
94
99
|
*
|
|
95
100
|
* @param {Range} range
|
|
96
101
|
*/
|
|
97
|
-
function
|
|
98
|
-
return
|
|
99
|
-
(
|
|
100
|
-
|
|
102
|
+
function hasTemplate(range) {
|
|
103
|
+
return parts.some(
|
|
104
|
+
(part) =>
|
|
105
|
+
part.type !== NodeTypes.Part && isRangesOverlap(part.range, range)
|
|
101
106
|
);
|
|
102
107
|
}
|
|
103
108
|
|
|
@@ -125,7 +130,7 @@ function splitToLineNodes(node) {
|
|
|
125
130
|
value,
|
|
126
131
|
range,
|
|
127
132
|
loc,
|
|
128
|
-
|
|
133
|
+
hasTemplate: hasTemplate(range),
|
|
129
134
|
};
|
|
130
135
|
|
|
131
136
|
start += value.length + 1;
|
|
@@ -166,6 +171,14 @@ function isScript(node) {
|
|
|
166
171
|
return node.type === NODE_TYPES.ScriptTag;
|
|
167
172
|
}
|
|
168
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @param {AnyNode} node
|
|
176
|
+
* @returns {node is StyleTag}
|
|
177
|
+
*/
|
|
178
|
+
function isStyle(node) {
|
|
179
|
+
return node.type === NODE_TYPES.StyleTag;
|
|
180
|
+
}
|
|
181
|
+
|
|
169
182
|
/**
|
|
170
183
|
* @param {AnyNode} node
|
|
171
184
|
* @returns {node is Comment}
|
|
@@ -183,7 +196,7 @@ function isText(node) {
|
|
|
183
196
|
}
|
|
184
197
|
|
|
185
198
|
/**
|
|
186
|
-
* @param {AnyNode | Line} node
|
|
199
|
+
* @param {AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate } node
|
|
187
200
|
* @returns {node is Line}
|
|
188
201
|
*/
|
|
189
202
|
function isLine(node) {
|
|
@@ -224,7 +237,7 @@ function findParent(node, predicate) {
|
|
|
224
237
|
/**
|
|
225
238
|
*
|
|
226
239
|
* @param {AnyToken[]} tokens
|
|
227
|
-
* @returns {((CommentContent | Text)['
|
|
240
|
+
* @returns {((CommentContent | Text)['parts'][number])[]}
|
|
228
241
|
*/
|
|
229
242
|
function getTemplateTokens(tokens) {
|
|
230
243
|
return (
|
|
@@ -232,10 +245,10 @@ function getTemplateTokens(tokens) {
|
|
|
232
245
|
.concat(
|
|
233
246
|
...tokens
|
|
234
247
|
// @ts-ignore
|
|
235
|
-
.map((token) => token["
|
|
248
|
+
.map((token) => token["parts"] || [])
|
|
236
249
|
)
|
|
237
250
|
// @ts-ignore
|
|
238
|
-
.filter((token) => token.
|
|
251
|
+
.filter((token) => token.type !== TokenTypes.Part)
|
|
239
252
|
);
|
|
240
253
|
}
|
|
241
254
|
|
|
@@ -251,6 +264,7 @@ module.exports = {
|
|
|
251
264
|
isText,
|
|
252
265
|
isLine,
|
|
253
266
|
isScript,
|
|
267
|
+
isStyle,
|
|
254
268
|
isOverlapWithTemplates,
|
|
255
269
|
codeToLines,
|
|
256
270
|
isRangesOverlap,
|
package/lib/types/ast.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export interface Text extends Parser.TextNode {
|
|
|
150
150
|
export interface Line {
|
|
151
151
|
type: "Line";
|
|
152
152
|
value: string;
|
|
153
|
-
|
|
153
|
+
hasTemplate: boolean;
|
|
154
154
|
range: eslint.AST.Range;
|
|
155
155
|
loc: eslint.AST.SourceLocation;
|
|
156
156
|
}
|
|
@@ -169,6 +169,15 @@ export interface TemplateLiteral extends estree.TemplateLiteral {
|
|
|
169
169
|
range: eslint.AST.Range;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
export type TemplateText = Text["parts"][number];
|
|
173
|
+
|
|
174
|
+
export type OpenTemplate = Exclude<Parser.TemplateNode<any>["open"], undefined>;
|
|
175
|
+
export type CloseTemplate = Exclude<
|
|
176
|
+
Parser.TemplateNode<any>["close"],
|
|
177
|
+
undefined
|
|
178
|
+
>;
|
|
179
|
+
export type AnyPartNode = Parser.PartNode<Parser.NodeTypes>;
|
|
180
|
+
|
|
172
181
|
export type AnyNode =
|
|
173
182
|
| Document
|
|
174
183
|
| Doctype
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-eslint/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "ESLint plugin for html",
|
|
5
5
|
"author": "yeonjuan",
|
|
6
6
|
"homepage": "https://github.com/yeonjuan/html-eslint#readme",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"test": "jest --coverage",
|
|
28
28
|
"ts": "tsc",
|
|
29
|
-
"lint": "eslint
|
|
29
|
+
"lint": "eslint",
|
|
30
30
|
"build": "tsc -p ./tsconfig.build.json"
|
|
31
31
|
},
|
|
32
32
|
"bugs": {
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"accessibility"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@html-eslint/template-parser": "^0.
|
|
49
|
-
"@html-eslint/template-syntax-parser": "^0.
|
|
48
|
+
"@html-eslint/template-parser": "^0.35.0",
|
|
49
|
+
"@html-eslint/template-syntax-parser": "^0.35.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@html-eslint/parser": "^0.
|
|
52
|
+
"@html-eslint/parser": "^0.35.0",
|
|
53
53
|
"@types/eslint": "^9.6.1",
|
|
54
54
|
"@types/estree": "^0.0.47",
|
|
55
|
-
"es-html-parser": "
|
|
56
|
-
"eslint": "^
|
|
55
|
+
"es-html-parser": "0.1.0",
|
|
56
|
+
"eslint": "^9",
|
|
57
57
|
"espree": "^10.3.0",
|
|
58
58
|
"typescript": "^5.7.2"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2493a6a72eba5e4fca3be33897050a4ea29712dd"
|
|
61
61
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace _exports {
|
|
2
|
-
export { RuleModule, Tag, Comment, Doctype, ScriptTag, StyleTag, Text,
|
|
2
|
+
export { RuleModule, Tag, Comment, Doctype, ScriptTag, StyleTag, Text, AnyNode, OpenTagEnd, CloseTag };
|
|
3
3
|
}
|
|
4
4
|
declare const _exports: RuleModule;
|
|
5
5
|
export = _exports;
|
|
@@ -10,10 +10,7 @@ type Doctype = import("../types").Doctype;
|
|
|
10
10
|
type ScriptTag = import("../types").ScriptTag;
|
|
11
11
|
type StyleTag = import("../types").StyleTag;
|
|
12
12
|
type Text = import("../types").Text;
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
childLast: NewlineNode | null;
|
|
17
|
-
shouldBeNewline: boolean;
|
|
18
|
-
};
|
|
13
|
+
type AnyNode = import("../types").AnyNode;
|
|
14
|
+
type OpenTagEnd = import("../types").OpenTagEnd;
|
|
15
|
+
type CloseTag = import("../types").CloseTag;
|
|
19
16
|
//# sourceMappingURL=element-newline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-newline.d.ts","sourceRoot":"","sources":["../../lib/rules/element-newline.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"element-newline.d.ts","sourceRoot":"","sources":["../../lib/rules/element-newline.js"],"names":[],"mappings":";;;wBAqEU,UAAU;;kBApEN,OAAO,UAAU,EAAE,UAAU;WAC7B,OAAO,UAAU,EAAE,GAAG;eACtB,OAAO,UAAU,EAAE,OAAO;eAC1B,OAAO,UAAU,EAAE,OAAO;iBAC1B,OAAO,UAAU,EAAE,SAAS;gBAC5B,OAAO,UAAU,EAAE,QAAQ;YAC3B,OAAO,UAAU,EAAE,IAAI;eACvB,OAAO,UAAU,EAAE,OAAO;kBAC1B,OAAO,UAAU,EAAE,UAAU;gBAC7B,OAAO,UAAU,EAAE,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace _exports {
|
|
2
|
-
export { RuleModule, AnyNode, Line, Tag, RuleListener, Context, Token, SourceCode, Range, SourceLocation, TemplateLiteral, IndentType, MessageId, IndentOptionInfo };
|
|
2
|
+
export { RuleModule, AnyNode, Line, Tag, RuleListener, Context, TemplateText, Token, SourceCode, Range, SourceLocation, TemplateLiteral, OpenTemplate, CloseTemplate, IndentType, MessageId, IndentOptionInfo };
|
|
3
3
|
}
|
|
4
4
|
declare const _exports: RuleModule;
|
|
5
5
|
export = _exports;
|
|
@@ -9,11 +9,14 @@ type Line = import("../../types").Line;
|
|
|
9
9
|
type Tag = import("../../types").Tag;
|
|
10
10
|
type RuleListener = import("../../types").RuleListener;
|
|
11
11
|
type Context = import("../../types").Context;
|
|
12
|
+
type TemplateText = import("../../types").TemplateText;
|
|
12
13
|
type Token = import("eslint").AST.Token;
|
|
13
14
|
type SourceCode = import("eslint").SourceCode;
|
|
14
15
|
type Range = import("eslint").AST.Range;
|
|
15
16
|
type SourceLocation = import("eslint").AST.SourceLocation;
|
|
16
17
|
type TemplateLiteral = import("../../types").TemplateLiteral;
|
|
18
|
+
type OpenTemplate = import("../../types").OpenTemplate;
|
|
19
|
+
type CloseTemplate = import("../../types").CloseTemplate;
|
|
17
20
|
type IndentType = {
|
|
18
21
|
TAB: "tab";
|
|
19
22
|
SPACE: "space";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../../lib/rules/indent/indent.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../../lib/rules/indent/indent.js"],"names":[],"mappings":";;;wBA0DU,UAAU;;kBAzDN,OAAO,aAAa,EAAE,UAAU;eAChC,OAAO,aAAa,EAAE,OAAO;YAC7B,OAAO,aAAa,EAAE,IAAI;WAC1B,OAAO,aAAa,EAAE,GAAG;oBACzB,OAAO,aAAa,EAAE,YAAY;eAClC,OAAO,aAAa,EAAE,OAAO;oBAC7B,OAAO,aAAa,EAAE,YAAY;aAClC,OAAO,QAAQ,EAAE,GAAG,CAAC,KAAK;kBAC1B,OAAO,QAAQ,EAAE,UAAU;aAC3B,OAAO,QAAQ,EAAE,GAAG,CAAC,KAAK;sBAC1B,OAAO,QAAQ,EAAE,GAAG,CAAC,cAAc;uBACnC,OAAO,aAAa,EAAE,eAAe;oBACrC,OAAO,aAAa,EAAE,YAAY;qBAClC,OAAO,aAAa,EAAE,aAAa;;SAInC,KAAK;WACL,OAAO;;;kBAEP,aAAa;;;gBAEb,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC;gBACvC,MAAM;gBACN,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-extra-spacing-attrs.d.ts","sourceRoot":"","sources":["../../lib/rules/no-extra-spacing-attrs.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"no-extra-spacing-attrs.d.ts","sourceRoot":"","sources":["../../lib/rules/no-extra-spacing-attrs.js"],"names":[],"mappings":";;;wBAmCU,UAAU;;kBAlCN,OAAO,UAAU,EAAE,UAAU;iBAC7B,OAAO,UAAU,EAAE,SAAS;kBAC5B,OAAO,UAAU,EAAE,UAAU;wBAC7B,OAAO,UAAU,EAAE,gBAAgB;uBACnC,OAAO,UAAU,EAAE,eAAe;0BAClC,OAAO,UAAU,EAAE,kBAAkB;oBACrC,OAAO,UAAU,EAAE,YAAY;yBAC/B,OAAO,UAAU,EAAE,iBAAiB;WACpC,OAAO,UAAU,EAAE,GAAG;gBACtB,OAAO,UAAU,EAAE,QAAQ;iBAC3B,OAAO,UAAU,EAAE,SAAS;eAC5B,OAAO,UAAU,EAAE,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-https.d.ts","sourceRoot":"","sources":["../../lib/rules/prefer-https.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"prefer-https.d.ts","sourceRoot":"","sources":["../../lib/rules/prefer-https.js"],"names":[],"mappings":";;;wBAmEU,UAAU;;kBAlEN,OAAO,UAAU,EAAE,UAAU;WAC7B,OAAO,UAAU,EAAE,GAAG;iBACtB,OAAO,UAAU,EAAE,SAAS;iBAC5B,OAAO,UAAU,EAAE,SAAS;sBAC5B,OAAO,UAAU,EAAE,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../lib/rules/quotes.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../lib/rules/quotes.js"],"names":[],"mappings":";;;wBA0BU,UAAU;;aAzBN,OAAO,QAAQ,EAAE,GAAG,CAAC,KAAK;kBAC1B,OAAO,UAAU,EAAE,UAAU;iBAC7B,OAAO,UAAU,EAAE,SAAS;WAC5B,OAAO,UAAU,EAAE,GAAG;iBACtB,OAAO,UAAU,EAAE,SAAS;gBAC5B,OAAO,UAAU,EAAE,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-form-method.d.ts","sourceRoot":"","sources":["../../lib/rules/require-form-method.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"require-form-method.d.ts","sourceRoot":"","sources":["../../lib/rules/require-form-method.js"],"names":[],"mappings":";;;wBAkBU,UAAU;;kBAjBN,OAAO,UAAU,EAAE,UAAU"}
|
|
@@ -9,6 +9,10 @@ export type Comment = import("../../types").Comment;
|
|
|
9
9
|
export type AnyNode = import("../../types").AnyNode;
|
|
10
10
|
export type AttributeValue = import("../../types").AttributeValue;
|
|
11
11
|
export type AttributeKey = import("../../types").AttributeKey;
|
|
12
|
+
export type TemplateText = import("../../types").TemplateText;
|
|
13
|
+
export type OpenTemplate = import("../../types").OpenTemplate;
|
|
14
|
+
export type CloseTemplate = import("../../types").CloseTemplate;
|
|
15
|
+
export type AnyPartNode = import("../../types").AnyPartNode;
|
|
12
16
|
export type Range = import("eslint").AST.Range;
|
|
13
17
|
export type SourceLocation = import("eslint").AST.SourceLocation;
|
|
14
18
|
export type AnyToken = import("es-html-parser").AnyToken;
|
|
@@ -69,21 +73,26 @@ export function isComment(node: AnyNode): node is Comment;
|
|
|
69
73
|
*/
|
|
70
74
|
export function isText(node: AnyNode): node is Text;
|
|
71
75
|
/**
|
|
72
|
-
* @param {AnyNode | Line} node
|
|
76
|
+
* @param {AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate } node
|
|
73
77
|
* @returns {node is Line}
|
|
74
78
|
*/
|
|
75
|
-
export function isLine(node: AnyNode | Line): node is Line;
|
|
79
|
+
export function isLine(node: AnyNode | Line | TemplateText | OpenTemplate | CloseTemplate): node is Line;
|
|
76
80
|
/**
|
|
77
81
|
* @param {AnyNode} node
|
|
78
82
|
* @returns {node is ScriptTag}
|
|
79
83
|
*/
|
|
80
84
|
export function isScript(node: AnyNode): node is ScriptTag;
|
|
81
85
|
/**
|
|
82
|
-
* @param {
|
|
86
|
+
* @param {AnyNode} node
|
|
87
|
+
* @returns {node is StyleTag}
|
|
88
|
+
*/
|
|
89
|
+
export function isStyle(node: AnyNode): node is StyleTag;
|
|
90
|
+
/**
|
|
91
|
+
* @param {(Text | CommentContent)['parts']} parts
|
|
83
92
|
* @param {Range} range
|
|
84
93
|
* @returns {boolean}
|
|
85
94
|
*/
|
|
86
|
-
export function isOverlapWithTemplates(
|
|
95
|
+
export function isOverlapWithTemplates(parts: (Text | CommentContent)["parts"], range: Range): boolean;
|
|
87
96
|
/**
|
|
88
97
|
* @param {string} source
|
|
89
98
|
* @returns {string[]}
|
|
@@ -99,12 +108,12 @@ export function isRangesOverlap(rangeA: Range, rangeB: Range): boolean;
|
|
|
99
108
|
/**
|
|
100
109
|
*
|
|
101
110
|
* @param {AnyToken[]} tokens
|
|
102
|
-
* @returns {((CommentContent | Text)['
|
|
111
|
+
* @returns {((CommentContent | Text)['parts'][number])[]}
|
|
103
112
|
*/
|
|
104
|
-
export function getTemplateTokens(tokens: AnyToken[]): ((CommentContent | Text)["
|
|
113
|
+
export function getTemplateTokens(tokens: AnyToken[]): ((CommentContent | Text)["parts"][number])[];
|
|
105
114
|
/**
|
|
106
|
-
* @param {AttributeKey | AttributeValue} node
|
|
115
|
+
* @param {AttributeKey | AttributeValue | Text | CommentContent} node
|
|
107
116
|
* @returns {boolean}
|
|
108
117
|
*/
|
|
109
|
-
export function hasTemplate(node: AttributeKey | AttributeValue): boolean;
|
|
118
|
+
export function hasTemplate(node: AttributeKey | AttributeValue | Text | CommentContent): boolean;
|
|
110
119
|
//# 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,EAAE,YAAY;
|
|
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,EAAE,YAAY;2BAClC,OAAO,aAAa,EAAE,YAAY;2BAClC,OAAO,aAAa,EAAE,YAAY;4BAClC,OAAO,aAAa,EAAE,aAAa;0BACnC,OAAO,aAAa,EAAE,WAAW;oBACjC,OAAO,QAAQ,EAAE,GAAG,CAAC,KAAK;6BAC1B,OAAO,QAAQ,EAAE,GAAG,CAAC,cAAc;uBACnC,OAAO,gBAAgB,EAAE,QAAQ;AAO/C;;;;GAIG;AACH,+BAJW,GAAG,GAAG,SAAS,GAAG,QAAQ,OAC1B,MAAM,GACJ,SAAS,GAAG,SAAS,CAMjC;AAED;;;;GAIG;AACH,wCAHW,GAAG,GAAG,SAAS,GAAG,QAAQ,GACxB,OAAO,CAInB;AAED;;;;GAIG;AACH,6CAHW,OAAO,GACL,OAAO,CAInB;AA+BD;;;;GAIG;AACH,uCAHW,IAAI,GAAG,cAAc,GACnB,IAAI,EAAE,CAwDlB;AAED;;;;;GAKG;AACH,sCAJW;IAAC,GAAG,EAAE,cAAc,CAAA;CAAC,SACrB;IAAC,GAAG,EAAE,cAAc,CAAA;CAAC,GACnB,cAAc,CAO1B;AA4DD;;;;GAIG;AACH,iCAJW,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,aACtB,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,GACxB,IAAI,GAAG,OAAO,CAgB1B;AA7ED;;;GAGG;AACH,4BAHW,OAAO,GACL,IAAI,IAAI,GAAG,CAIvB;AAkBD;;;GAGG;AACH,gCAHW,OAAO,GACL,IAAI,IAAI,OAAO,CAI3B;AAED;;;GAGG;AACH,6BAHW,OAAO,GACL,IAAI,IAAI,IAAI,CAIxB;AAED;;;GAGG;AACH,6BAHW,OAAO,GAAG,IAAI,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAC1D,IAAI,IAAI,IAAI,CAIxB;AAtCD;;;GAGG;AACH,+BAHW,OAAO,GACL,IAAI,IAAI,SAAS,CAI7B;AAED;;;GAGG;AACH,8BAHW,OAAO,GACL,IAAI,IAAI,QAAQ,CAI5B;AAnHD;;;;GAIG;AACH,8CAJW,CAAC,IAAI,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,SAChC,KAAK,GACH,OAAO,CAMnB;AAsID;;;GAGG;AACH,oCAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;AA/JD;;;;;GAKG;AACH,wCAJW,KAAK,UACL,KAAK,GACH,OAAO,CAInB;AA8KD;;;;GAIG;AACH,0CAHW,QAAQ,EAAE,GACR,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAaxD;AAjLD;;;GAGG;AACH,kCAHW,YAAY,GAAG,cAAc,GAAG,IAAI,GAAG,cAAc,GACnD,OAAO,CAInB"}
|
package/types/rules/indent.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare namespace _exports {
|
|
2
|
-
export { RuleModule, AnyNode, LineNode, BaseNode, TagNode, RuleListener, Token, SourceCode, TemplateLiteral, IndentType, MessageId };
|
|
3
|
-
}
|
|
4
|
-
declare const _exports: RuleModule;
|
|
5
|
-
export = _exports;
|
|
6
|
-
type RuleModule = import("../types").RuleModule;
|
|
7
|
-
type AnyNode = import("../types").AnyNode;
|
|
8
|
-
type LineNode = import("../types").LineNode;
|
|
9
|
-
type BaseNode = import("../types").BaseNode;
|
|
10
|
-
type TagNode = import("../types").TagNode;
|
|
11
|
-
type RuleListener = import("../types").RuleListener;
|
|
12
|
-
type Token = import("eslint").AST.Token;
|
|
13
|
-
type SourceCode = import("eslint").SourceCode;
|
|
14
|
-
type TemplateLiteral = import("estree").TemplateLiteral;
|
|
15
|
-
type IndentType = {
|
|
16
|
-
TAB: "tab";
|
|
17
|
-
SPACE: "space";
|
|
18
|
-
};
|
|
19
|
-
type MessageId = {
|
|
20
|
-
WRONG_INDENT: "wrongIndent";
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=indent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../lib/rules/indent.js"],"names":[],"mappings":";;;wBAyCU,UAAU;;kBAxCN,OAAO,UAAU,EAAE,UAAU;eAC7B,OAAO,UAAU,EAAE,OAAO;gBAC1B,OAAO,UAAU,EAAE,QAAQ;gBAC3B,OAAO,UAAU,EAAE,QAAQ;eAC3B,OAAO,UAAU,EAAE,OAAO;oBAC1B,OAAO,UAAU,EAAE,YAAY;aAC/B,OAAO,QAAQ,EAAE,GAAG,CAAC,KAAK;kBAC1B,OAAO,QAAQ,EAAE,UAAU;uBAC3B,OAAO,QAAQ,EAAE,eAAe;;SAEhC,KAAK;WACL,OAAO;;;kBAEP,aAAa"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type MaybeHTMLSettings = {
|
|
2
|
-
templateLiterals?: {
|
|
3
|
-
tags?: string[];
|
|
4
|
-
comments?: string[];
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export type HTMLSettings = {
|
|
8
|
-
templateLiterals: {
|
|
9
|
-
tags: RegExp[];
|
|
10
|
-
comments: RegExp[];
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../lib/types/settings.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gBAAgB,CAAC,EAAE;QACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,gBAAgB,EAAE;QAChB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC"}
|