@html-eslint/eslint-plugin 0.35.0-alpha.0 → 0.35.1
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/attrs-newline.js +11 -7
- package/lib/rules/element-newline.js +172 -160
- package/lib/rules/id-naming-convention.js +10 -4
- package/lib/rules/indent/indent-level.js +1 -1
- package/lib/rules/indent/indent.js +28 -15
- package/lib/rules/lowercase.js +4 -4
- package/lib/rules/max-element-depth.js +8 -5
- package/lib/rules/no-abstract-roles.js +4 -4
- package/lib/rules/no-accesskey-attrs.js +4 -4
- package/lib/rules/no-aria-hidden-body.js +1 -1
- package/lib/rules/no-duplicate-attrs.js +4 -4
- package/lib/rules/no-duplicate-id.js +5 -5
- package/lib/rules/no-extra-spacing-attrs.js +18 -12
- package/lib/rules/no-extra-spacing-text.js +8 -5
- package/lib/rules/no-heading-inside-button.js +1 -1
- package/lib/rules/no-inline-styles.js +1 -1
- package/lib/rules/no-invalid-role.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +8 -5
- package/lib/rules/no-multiple-h1.js +2 -2
- package/lib/rules/no-nested-interactive.js +2 -2
- package/lib/rules/no-non-scalable-viewport.js +1 -1
- package/lib/rules/no-obsolete-tags.js +1 -1
- package/lib/rules/no-positive-tabindex.js +4 -4
- package/lib/rules/no-restricted-attr-values.js +5 -5
- package/lib/rules/no-restricted-attrs.js +8 -7
- package/lib/rules/no-script-style-type.js +4 -4
- package/lib/rules/no-skip-heading-levels.js +2 -2
- package/lib/rules/no-target-blank.js +1 -1
- package/lib/rules/no-trailing-spaces.js +3 -3
- package/lib/rules/prefer-https.js +5 -5
- package/lib/rules/quotes.js +7 -5
- package/lib/rules/require-attrs.js +7 -5
- package/lib/rules/require-button-type.js +1 -1
- package/lib/rules/require-closing-tags.js +6 -2
- package/lib/rules/require-doctype.js +1 -1
- package/lib/rules/require-explicit-size.js +8 -3
- package/lib/rules/require-form-method.js +1 -1
- package/lib/rules/require-frame-title.js +1 -1
- package/lib/rules/require-img-alt.js +9 -8
- package/lib/rules/require-input-label.js +2 -2
- package/lib/rules/require-lang.js +4 -7
- package/lib/rules/require-li-container.js +1 -1
- package/lib/rules/require-meta-charset.js +3 -3
- package/lib/rules/require-meta-description.js +3 -3
- package/lib/rules/require-meta-viewport.js +3 -3
- package/lib/rules/require-open-graph-protocol.js +6 -3
- package/lib/rules/require-title.js +4 -4
- package/lib/rules/sort-attrs.js +11 -11
- package/lib/rules/utils/node.js +31 -19
- package/lib/rules/utils/settings.js +3 -3
- package/lib/rules/utils/source-code.js +1 -1
- package/lib/rules/utils/visitors.js +1 -1
- package/lib/types/ast.d.ts +4 -194
- package/lib/types/index.d.ts +1 -1
- package/lib/types/rule.d.ts +41 -10
- package/package.json +11 -20
- package/types/configs/recommended.d.ts +0 -20
- package/types/configs/recommended.d.ts.map +0 -1
- package/types/constants/index.d.ts +0 -5
- package/types/constants/index.d.ts.map +0 -1
- package/types/constants/obsolete-tags.d.ts +0 -3
- package/types/constants/obsolete-tags.d.ts.map +0 -1
- package/types/constants/rule-category.d.ts +0 -5
- package/types/constants/rule-category.d.ts.map +0 -1
- package/types/constants/svg-camel-case-attributes.d.ts +0 -3
- package/types/constants/svg-camel-case-attributes.d.ts.map +0 -1
- package/types/constants/void-elements.d.ts +0 -3
- package/types/constants/void-elements.d.ts.map +0 -1
- package/types/index.d.ts +0 -14
- package/types/index.d.ts.map +0 -1
- package/types/rules/attrs-newline.d.ts +0 -13
- package/types/rules/attrs-newline.d.ts.map +0 -1
- package/types/rules/element-newline.d.ts +0 -19
- package/types/rules/element-newline.d.ts.map +0 -1
- package/types/rules/id-naming-convention.d.ts +0 -10
- package/types/rules/id-naming-convention.d.ts.map +0 -1
- package/types/rules/indent/indent-level.d.ts +0 -55
- package/types/rules/indent/indent-level.d.ts.map +0 -1
- package/types/rules/indent/indent.d.ts +0 -30
- package/types/rules/indent/indent.d.ts.map +0 -1
- package/types/rules/indent/index.d.ts +0 -3
- package/types/rules/indent/index.d.ts.map +0 -1
- package/types/rules/index.d.ts +0 -51
- package/types/rules/index.d.ts.map +0 -1
- package/types/rules/lowercase.d.ts +0 -10
- package/types/rules/lowercase.d.ts.map +0 -1
- package/types/rules/max-element-depth.d.ts +0 -10
- package/types/rules/max-element-depth.d.ts.map +0 -1
- package/types/rules/no-abstract-roles.d.ts +0 -10
- package/types/rules/no-abstract-roles.d.ts.map +0 -1
- package/types/rules/no-accesskey-attrs.d.ts +0 -10
- package/types/rules/no-accesskey-attrs.d.ts.map +0 -1
- package/types/rules/no-aria-hidden-body.d.ts +0 -7
- package/types/rules/no-aria-hidden-body.d.ts.map +0 -1
- package/types/rules/no-duplicate-attrs.d.ts +0 -10
- package/types/rules/no-duplicate-attrs.d.ts.map +0 -1
- package/types/rules/no-duplicate-id.d.ts +0 -11
- package/types/rules/no-duplicate-id.d.ts.map +0 -1
- package/types/rules/no-extra-spacing-attrs.d.ts +0 -18
- package/types/rules/no-extra-spacing-attrs.d.ts.map +0 -1
- package/types/rules/no-extra-spacing-text.d.ts +0 -13
- package/types/rules/no-extra-spacing-text.d.ts.map +0 -1
- package/types/rules/no-heading-inside-button.d.ts +0 -7
- package/types/rules/no-heading-inside-button.d.ts.map +0 -1
- package/types/rules/no-inline-styles.d.ts +0 -7
- package/types/rules/no-inline-styles.d.ts.map +0 -1
- package/types/rules/no-invalid-role.d.ts +0 -7
- package/types/rules/no-invalid-role.d.ts.map +0 -1
- package/types/rules/no-multiple-empty-lines.d.ts +0 -11
- package/types/rules/no-multiple-empty-lines.d.ts.map +0 -1
- package/types/rules/no-multiple-h1.d.ts +0 -8
- package/types/rules/no-multiple-h1.d.ts.map +0 -1
- package/types/rules/no-nested-interactive.d.ts +0 -8
- package/types/rules/no-nested-interactive.d.ts.map +0 -1
- package/types/rules/no-non-scalable-viewport.d.ts +0 -7
- package/types/rules/no-non-scalable-viewport.d.ts.map +0 -1
- package/types/rules/no-obsolete-tags.d.ts +0 -7
- package/types/rules/no-obsolete-tags.d.ts.map +0 -1
- package/types/rules/no-positive-tabindex.d.ts +0 -10
- package/types/rules/no-positive-tabindex.d.ts.map +0 -1
- package/types/rules/no-restricted-attr-values.d.ts +0 -16
- package/types/rules/no-restricted-attr-values.d.ts.map +0 -1
- package/types/rules/no-restricted-attrs.d.ts +0 -16
- package/types/rules/no-restricted-attrs.d.ts.map +0 -1
- package/types/rules/no-script-style-type.d.ts +0 -10
- package/types/rules/no-script-style-type.d.ts.map +0 -1
- package/types/rules/no-skip-heading-levels.d.ts +0 -8
- package/types/rules/no-skip-heading-levels.d.ts.map +0 -1
- package/types/rules/no-target-blank.d.ts +0 -7
- package/types/rules/no-target-blank.d.ts.map +0 -1
- package/types/rules/no-trailing-spaces.d.ts +0 -9
- package/types/rules/no-trailing-spaces.d.ts.map +0 -1
- package/types/rules/prefer-https.d.ts +0 -11
- package/types/rules/prefer-https.d.ts.map +0 -1
- package/types/rules/quotes.d.ts +0 -12
- package/types/rules/quotes.d.ts.map +0 -1
- package/types/rules/require-attrs.d.ts +0 -15
- package/types/rules/require-attrs.d.ts.map +0 -1
- package/types/rules/require-button-type.d.ts +0 -7
- package/types/rules/require-button-type.d.ts.map +0 -1
- package/types/rules/require-closing-tags.d.ts +0 -8
- package/types/rules/require-closing-tags.d.ts.map +0 -1
- package/types/rules/require-doctype.d.ts +0 -7
- package/types/rules/require-doctype.d.ts.map +0 -1
- package/types/rules/require-explicit-size.d.ts +0 -9
- package/types/rules/require-explicit-size.d.ts.map +0 -1
- package/types/rules/require-form-method.d.ts +0 -7
- package/types/rules/require-form-method.d.ts.map +0 -1
- package/types/rules/require-frame-title.d.ts +0 -7
- package/types/rules/require-frame-title.d.ts.map +0 -1
- package/types/rules/require-img-alt.d.ts +0 -8
- package/types/rules/require-img-alt.d.ts.map +0 -1
- package/types/rules/require-input-label.d.ts +0 -8
- package/types/rules/require-input-label.d.ts.map +0 -1
- package/types/rules/require-lang.d.ts +0 -7
- package/types/rules/require-lang.d.ts.map +0 -1
- package/types/rules/require-li-container.d.ts +0 -7
- package/types/rules/require-li-container.d.ts.map +0 -1
- package/types/rules/require-meta-charset.d.ts +0 -9
- package/types/rules/require-meta-charset.d.ts.map +0 -1
- package/types/rules/require-meta-description.d.ts +0 -9
- package/types/rules/require-meta-description.d.ts.map +0 -1
- package/types/rules/require-meta-viewport.d.ts +0 -9
- package/types/rules/require-meta-viewport.d.ts.map +0 -1
- package/types/rules/require-open-graph-protocol.d.ts +0 -9
- package/types/rules/require-open-graph-protocol.d.ts.map +0 -1
- package/types/rules/require-title.d.ts +0 -10
- package/types/rules/require-title.d.ts.map +0 -1
- package/types/rules/sort-attrs.d.ts +0 -10
- package/types/rules/sort-attrs.d.ts.map +0 -1
- package/types/rules/utils/array.d.ts +0 -17
- package/types/rules/utils/array.d.ts.map +0 -1
- package/types/rules/utils/naming.d.ts +0 -25
- package/types/rules/utils/naming.d.ts.map +0 -1
- package/types/rules/utils/node.d.ts +0 -111
- package/types/rules/utils/node.d.ts.map +0 -1
- package/types/rules/utils/settings.d.ts +0 -19
- package/types/rules/utils/settings.d.ts.map +0 -1
- package/types/rules/utils/source-code.d.ts +0 -9
- package/types/rules/utils/source-code.d.ts.map +0 -1
- package/types/rules/utils/visitors.d.ts +0 -10
- package/types/rules/utils/visitors.d.ts.map +0 -1
package/lib/rules/utils/node.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("
|
|
5
|
-
* @typedef { import("
|
|
2
|
+
* @typedef { import("@html-eslint/types").Attribute } Attribute
|
|
3
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
4
|
+
* @typedef { import("@html-eslint/types").ScriptTag } ScriptTag
|
|
5
|
+
* @typedef { import("@html-eslint/types").StyleTag } StyleTag
|
|
6
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
6
7
|
* @typedef { import("../../types").Line } Line
|
|
7
|
-
* @typedef { import("../../types").
|
|
8
|
-
* @typedef { import("
|
|
9
|
-
* @typedef { import("
|
|
10
|
-
* @typedef { import("
|
|
11
|
-
* @typedef { import("
|
|
12
|
-
* @typedef { import("
|
|
13
|
-
* @typedef { import("
|
|
8
|
+
* @typedef { import("../../types").BaseNode } BaseNode
|
|
9
|
+
* @typedef { import("@html-eslint/types").Text } Text
|
|
10
|
+
* @typedef { import("@html-eslint/types").CommentContent } CommentContent
|
|
11
|
+
* @typedef { import("@html-eslint/types").Comment } Comment
|
|
12
|
+
* @typedef { import("@html-eslint/types").AttributeValue } AttributeValue
|
|
13
|
+
* @typedef { import("@html-eslint/types").AttributeKey } AttributeKey
|
|
14
|
+
* @typedef { import("@html-eslint/types").TemplateText } TemplateText
|
|
15
|
+
* @typedef { import("@html-eslint/types").OpenTemplate } OpenTemplate
|
|
16
|
+
* @typedef { import("@html-eslint/types").CloseTemplate } CloseTemplate
|
|
14
17
|
* @typedef { import("eslint").AST.Range } Range
|
|
15
18
|
* @typedef { import("eslint").AST.SourceLocation } SourceLocation
|
|
16
19
|
* @typedef { import("es-html-parser").AnyToken } AnyToken
|
|
17
|
-
|
|
18
20
|
*/
|
|
19
21
|
|
|
20
22
|
const { NODE_TYPES } = require("@html-eslint/parser");
|
|
@@ -153,7 +155,7 @@ function getLocBetween(before, after) {
|
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
|
-
* @param {
|
|
158
|
+
* @param {BaseNode} node
|
|
157
159
|
* @returns {node is Tag}
|
|
158
160
|
*/
|
|
159
161
|
function isTag(node) {
|
|
@@ -161,7 +163,7 @@ function isTag(node) {
|
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
/**
|
|
164
|
-
* @param {
|
|
166
|
+
* @param {BaseNode} node
|
|
165
167
|
* @returns {node is ScriptTag}
|
|
166
168
|
*/
|
|
167
169
|
function isScript(node) {
|
|
@@ -169,7 +171,15 @@ function isScript(node) {
|
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
/**
|
|
172
|
-
* @param {
|
|
174
|
+
* @param {BaseNode} node
|
|
175
|
+
* @returns {node is StyleTag}
|
|
176
|
+
*/
|
|
177
|
+
function isStyle(node) {
|
|
178
|
+
return node.type === NODE_TYPES.StyleTag;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @param {BaseNode} node
|
|
173
183
|
* @returns {node is Comment}
|
|
174
184
|
*/
|
|
175
185
|
function isComment(node) {
|
|
@@ -177,7 +187,7 @@ function isComment(node) {
|
|
|
177
187
|
}
|
|
178
188
|
|
|
179
189
|
/**
|
|
180
|
-
* @param {
|
|
190
|
+
* @param {BaseNode} node
|
|
181
191
|
* @returns {node is Text}
|
|
182
192
|
*/
|
|
183
193
|
function isText(node) {
|
|
@@ -185,7 +195,7 @@ function isText(node) {
|
|
|
185
195
|
}
|
|
186
196
|
|
|
187
197
|
/**
|
|
188
|
-
* @param {
|
|
198
|
+
* @param {BaseNode} node
|
|
189
199
|
* @returns {node is Line}
|
|
190
200
|
*/
|
|
191
201
|
function isLine(node) {
|
|
@@ -203,7 +213,7 @@ function codeToLines(source) {
|
|
|
203
213
|
}
|
|
204
214
|
|
|
205
215
|
/**
|
|
206
|
-
* @param {
|
|
216
|
+
* @param {AnyNode} node
|
|
207
217
|
* @param {(node: AnyNode) => boolean} predicate
|
|
208
218
|
* @returns {null | AnyNode}
|
|
209
219
|
*/
|
|
@@ -213,7 +223,8 @@ function findParent(node, predicate) {
|
|
|
213
223
|
}
|
|
214
224
|
if (
|
|
215
225
|
node.type === "TaggedTemplateExpression" ||
|
|
216
|
-
node.type === "TemplateLiteral"
|
|
226
|
+
node.type === "TemplateLiteral" ||
|
|
227
|
+
node.type === "TemplateElement"
|
|
217
228
|
) {
|
|
218
229
|
return null;
|
|
219
230
|
}
|
|
@@ -253,6 +264,7 @@ module.exports = {
|
|
|
253
264
|
isText,
|
|
254
265
|
isLine,
|
|
255
266
|
isScript,
|
|
267
|
+
isStyle,
|
|
256
268
|
isOverlapWithTemplates,
|
|
257
269
|
codeToLines,
|
|
258
270
|
isRangesOverlap,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import("../../types").MaybeHTMLSettings} MaybeHTMLSettings
|
|
3
3
|
* @typedef {import("../../types").HTMLSettings} HTMLSettings
|
|
4
|
-
* @typedef {import("../../types").Context} Context
|
|
5
|
-
* @typedef {import("
|
|
6
|
-
* @typedef {import("
|
|
4
|
+
* @typedef {import("../../types").Context<any[]>} Context
|
|
5
|
+
* @typedef {import("@html-eslint/types").TaggedTemplateExpression} TaggedTemplateExpression
|
|
6
|
+
* @typedef {import("@html-eslint/types").TemplateLiteral} TemplateLiteral
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const { getSourceCode } = require("../utils/source-code");
|
package/lib/types/ast.d.ts
CHANGED
|
@@ -1,207 +1,17 @@
|
|
|
1
|
-
import * as Parser from "es-html-parser";
|
|
2
1
|
import eslint from "eslint";
|
|
3
|
-
import * as estree from "estree";
|
|
4
|
-
|
|
5
|
-
export interface Document extends Parser.DocumentNode {
|
|
6
|
-
parent: null;
|
|
7
|
-
children: Array<Tag | Text | Comment | Doctype | ScriptTag | StyleTag>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Doctype extends Parser.DoctypeNode {
|
|
11
|
-
parent: Document | Tag;
|
|
12
|
-
open: DoctypeOpen;
|
|
13
|
-
close: DoctypeClose;
|
|
14
|
-
attributes: Array<DoctypeAttribute>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface DoctypeOpen extends Parser.DoctypeOpenNode {
|
|
18
|
-
parent: Doctype;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface DoctypeClose extends Parser.DoctypeCloseNode {
|
|
22
|
-
parent: Doctype;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface DoctypeAttribute extends Parser.DoctypeAttributeNode {
|
|
26
|
-
parent: Doctype;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface Comment extends Parser.CommentNode {
|
|
30
|
-
parent: Tag | Document;
|
|
31
|
-
open: CommentOpen;
|
|
32
|
-
close: CommentClose;
|
|
33
|
-
value: CommentContent;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface CommentOpen extends Parser.CommentOpenNode {
|
|
37
|
-
parent: Comment;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface CommentClose extends Parser.CommentCloseNode {
|
|
41
|
-
parent: Comment;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface CommentContent extends Parser.CommentContentNode {
|
|
45
|
-
parent: Comment;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Tag extends Parser.TagNode {
|
|
49
|
-
parent: Document | Tag;
|
|
50
|
-
openStart: OpenTagStart;
|
|
51
|
-
openEnd: OpenTagEnd;
|
|
52
|
-
attributes: Array<Attribute>;
|
|
53
|
-
close?: CloseTag;
|
|
54
|
-
children: Array<Tag | Text | StyleTag | ScriptTag>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface OpenTagStart extends Parser.OpenTagStartNode {
|
|
58
|
-
parent: Tag;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface OpenTagEnd extends Parser.OpenTagEndNode {
|
|
62
|
-
parent: Tag;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface CloseTag extends Parser.CloseTagNode {
|
|
66
|
-
parent: Tag;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface ScriptTag extends Parser.ScriptTagNode {
|
|
70
|
-
parent: Document | Tag;
|
|
71
|
-
attributes: Array<Attribute>;
|
|
72
|
-
openStart: OpenScriptTagStart;
|
|
73
|
-
openEnd: OpenScriptTagEnd;
|
|
74
|
-
value?: ScriptTagContent;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface OpenScriptTagStart extends Parser.OpenScriptTagStartNode {
|
|
78
|
-
parent: ScriptTag;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface OpenScriptTagEnd extends Parser.OpenScriptTagEndNode {
|
|
82
|
-
parent: ScriptTag;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface CloseScriptTag extends Parser.CloseScriptTagNode {
|
|
86
|
-
parent: ScriptTag;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface ScriptTagContent extends Parser.ScriptTagContentNode {
|
|
90
|
-
parent: ScriptTag;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface StyleTag extends Parser.StyleTagNode {
|
|
94
|
-
parent: Document | Tag;
|
|
95
|
-
attributes: Array<Attribute>;
|
|
96
|
-
openStart: OpenStyleTagStart;
|
|
97
|
-
openEnd: OpenStyleTagEnd;
|
|
98
|
-
value?: StyleTagContent;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface OpenStyleTagStart extends Parser.OpenStyleTagStartNode {
|
|
102
|
-
parent: StyleTag;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface OpenStyleTagEnd extends Parser.OpenStyleTagEndNode {
|
|
106
|
-
parent: StyleTag;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface CloseStyleTag extends Parser.CloseStyleTagNode {
|
|
110
|
-
parent: StyleTag;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface StyleTagContent extends Parser.StyleTagContentNode {
|
|
114
|
-
parent: StyleTag;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface Attribute extends Parser.AttributeNode {
|
|
118
|
-
parent: Tag;
|
|
119
|
-
key: AttributeKey;
|
|
120
|
-
value?: AttributeValue;
|
|
121
|
-
startWrapper?: AttributeValueWrapperStart;
|
|
122
|
-
endWrapper?: AttributeValueWrapperEnd;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface AttributeKey extends Parser.AttributeKeyNode {
|
|
126
|
-
parent: Attribute;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface AttributeValue extends Parser.AttributeValueNode {
|
|
130
|
-
parent: Attribute;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface AttributeValueWrapperStart
|
|
134
|
-
extends Parser.AttributeValueWrapperStartNode {
|
|
135
|
-
parent: Attribute;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface AttributeValueWrapperEnd
|
|
139
|
-
extends Parser.AttributeValueWrapperEndNode {
|
|
140
|
-
parent: Attribute;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface Text extends Parser.TextNode {
|
|
144
|
-
parent: Document | Tag;
|
|
145
|
-
}
|
|
146
2
|
|
|
147
3
|
/**
|
|
148
4
|
* This is not a node generated by es-html-parser; it is created by utils's splitToLineNodes.
|
|
149
5
|
*/
|
|
150
|
-
export interface Line {
|
|
6
|
+
export interface Line extends BaseNode {
|
|
151
7
|
type: "Line";
|
|
152
8
|
value: string;
|
|
153
9
|
hasTemplate: boolean;
|
|
154
|
-
range: eslint.AST.Range;
|
|
155
|
-
loc: eslint.AST.SourceLocation;
|
|
156
10
|
}
|
|
157
11
|
|
|
158
|
-
export interface
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
loc: eslint.AST.SourceLocation;
|
|
12
|
+
export interface BaseNode {
|
|
13
|
+
parent?: BaseNode | null;
|
|
14
|
+
type: string;
|
|
162
15
|
range: eslint.AST.Range;
|
|
163
|
-
quasi: TemplateLiteral;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export interface TemplateLiteral extends estree.TemplateLiteral {
|
|
167
|
-
parent: estree.Node | null;
|
|
168
16
|
loc: eslint.AST.SourceLocation;
|
|
169
|
-
range: eslint.AST.Range;
|
|
170
17
|
}
|
|
171
|
-
|
|
172
|
-
export type TemplateText = Text["parts"][number];
|
|
173
|
-
|
|
174
|
-
export type AnyNode =
|
|
175
|
-
| Document
|
|
176
|
-
| Doctype
|
|
177
|
-
| DoctypeOpen
|
|
178
|
-
| DoctypeClose
|
|
179
|
-
| DoctypeAttribute
|
|
180
|
-
| Comment
|
|
181
|
-
| CommentOpen
|
|
182
|
-
| CommentClose
|
|
183
|
-
| CommentContent
|
|
184
|
-
| Tag
|
|
185
|
-
| OpenTagStart
|
|
186
|
-
| OpenTagEnd
|
|
187
|
-
| CloseTag
|
|
188
|
-
| ScriptTag
|
|
189
|
-
| OpenScriptTagStart
|
|
190
|
-
| OpenScriptTagEnd
|
|
191
|
-
| ScriptTagContent
|
|
192
|
-
| CloseScriptTag
|
|
193
|
-
| StyleTag
|
|
194
|
-
| OpenStyleTagStart
|
|
195
|
-
| OpenStyleTagEnd
|
|
196
|
-
| StyleTagContent
|
|
197
|
-
| CloseStyleTag
|
|
198
|
-
| Attribute
|
|
199
|
-
| AttributeKey
|
|
200
|
-
| AttributeValue
|
|
201
|
-
| AttributeValueWrapperEnd
|
|
202
|
-
| AttributeValueWrapperStart
|
|
203
|
-
| Text
|
|
204
|
-
| Line
|
|
205
|
-
| TaggedTemplateExpression
|
|
206
|
-
| TemplateLiteral
|
|
207
|
-
| Parser.TemplateNode;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/rule.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import eslint from "eslint";
|
|
2
|
-
import * as AST from "
|
|
2
|
+
import * as AST from "@html-eslint/types";
|
|
3
|
+
import * as estree from "estree";
|
|
4
|
+
import { Line } from "./ast";
|
|
5
|
+
|
|
6
|
+
type AnyNodeAndLine = AST.AnyNode | Line;
|
|
3
7
|
|
|
4
8
|
type PostFix<T, S extends string> = {
|
|
5
9
|
[K in keyof T as `${K & string}${S}`]: T[K];
|
|
@@ -44,12 +48,36 @@ interface BaseRuleListener {
|
|
|
44
48
|
TemplateLiteral?: (node: AST.TemplateLiteral) => void;
|
|
45
49
|
}
|
|
46
50
|
|
|
51
|
+
interface RuleFix {
|
|
52
|
+
range: eslint.AST.Range;
|
|
53
|
+
text: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface RuleFixer {
|
|
57
|
+
insertTextAfter(nodeOrToken: AnyNodeAndLine, text: string): RuleFix;
|
|
58
|
+
|
|
59
|
+
insertTextAfterRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
60
|
+
|
|
61
|
+
insertTextBefore(nodeOrToken: AnyNodeAndLine, text: string): RuleFix;
|
|
62
|
+
|
|
63
|
+
insertTextBeforeRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
64
|
+
|
|
65
|
+
remove(nodeOrToken: AnyNodeAndLine): RuleFix;
|
|
66
|
+
|
|
67
|
+
removeRange(range: eslint.AST.Range): RuleFix;
|
|
68
|
+
|
|
69
|
+
replaceText(nodeOrToken: AnyNodeAndLine, text: string): RuleFix;
|
|
70
|
+
|
|
71
|
+
replaceTextRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type ReportFixFunction = (
|
|
75
|
+
fixer: RuleFixer
|
|
76
|
+
) => IterableIterator<RuleFix> | readonly RuleFix[] | RuleFix | null;
|
|
77
|
+
|
|
47
78
|
interface ReportDescriptorOptionsBase {
|
|
48
79
|
data?: { [key: string]: string };
|
|
49
|
-
|
|
50
|
-
fix?:
|
|
51
|
-
| null
|
|
52
|
-
| ((fixer: RuleFixer) => null | Fix | IterableIterator<Fix> | Fix[]);
|
|
80
|
+
fix?: null | ReportFixFunction;
|
|
53
81
|
}
|
|
54
82
|
|
|
55
83
|
type SuggestionDescriptorMessage = { desc: string } | { messageId: string };
|
|
@@ -65,19 +93,22 @@ type ReportDescriptor = ReportDescriptorMessage &
|
|
|
65
93
|
ReportDescriptorOptions;
|
|
66
94
|
type ReportDescriptorMessage = { message: string } | { messageId: string };
|
|
67
95
|
type ReportDescriptorLocation = {
|
|
68
|
-
node?: BaseNode;
|
|
69
|
-
loc?:
|
|
96
|
+
node?: estree.BaseNode;
|
|
97
|
+
loc?: eslint.AST.SourceLocation;
|
|
70
98
|
line?: number;
|
|
71
99
|
column?: number;
|
|
72
100
|
};
|
|
73
101
|
|
|
74
|
-
export interface Context extends
|
|
102
|
+
export interface Context<Options extends unknown[]>
|
|
103
|
+
extends Omit<eslint.Rule.RuleContext, "report"> {
|
|
75
104
|
report(descriptor: ReportDescriptor): void;
|
|
105
|
+
options: Options;
|
|
76
106
|
}
|
|
77
107
|
|
|
78
108
|
export type RuleListener = BaseRuleListener &
|
|
79
109
|
PostFix<BaseRuleListener, ":exit">;
|
|
80
110
|
|
|
81
|
-
export interface RuleModule extends
|
|
82
|
-
create(context: Context): RuleListener;
|
|
111
|
+
export interface RuleModule<Options extends unknown[]> {
|
|
112
|
+
create(context: Context<Options>): RuleListener;
|
|
113
|
+
meta: eslint.Rule.RuleMetaData;
|
|
83
114
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-eslint/eslint-plugin",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"description": "ESLint plugin for html",
|
|
5
5
|
"author": "yeonjuan",
|
|
6
6
|
"homepage": "https://github.com/yeonjuan/html-eslint#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
10
|
-
"directories": {
|
|
11
|
-
"lib": "lib",
|
|
12
|
-
"test": "__tests__",
|
|
13
|
-
"types": "types"
|
|
14
|
-
},
|
|
15
10
|
"files": [
|
|
16
|
-
"lib"
|
|
17
|
-
"types"
|
|
11
|
+
"lib"
|
|
18
12
|
],
|
|
19
13
|
"publishConfig": {
|
|
20
14
|
"access": "public"
|
|
@@ -25,16 +19,12 @@
|
|
|
25
19
|
},
|
|
26
20
|
"scripts": {
|
|
27
21
|
"test": "jest --coverage",
|
|
28
|
-
"ts": "tsc",
|
|
29
|
-
"lint": "eslint"
|
|
30
|
-
"build": "tsc -p ./tsconfig.build.json"
|
|
22
|
+
"ts": "tsc --noEmit",
|
|
23
|
+
"lint": "eslint ."
|
|
31
24
|
},
|
|
32
25
|
"bugs": {
|
|
33
26
|
"url": "https://github.com/yeonjuan/html-eslint/issues"
|
|
34
27
|
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
|
37
|
-
},
|
|
38
28
|
"keywords": [
|
|
39
29
|
"eslint",
|
|
40
30
|
"eslintplugin",
|
|
@@ -45,17 +35,18 @@
|
|
|
45
35
|
"accessibility"
|
|
46
36
|
],
|
|
47
37
|
"dependencies": {
|
|
48
|
-
"@html-eslint/template-parser": "^0.35.
|
|
49
|
-
"@html-eslint/template-syntax-parser": "^0.35.
|
|
38
|
+
"@html-eslint/template-parser": "^0.35.1",
|
|
39
|
+
"@html-eslint/template-syntax-parser": "^0.35.1"
|
|
50
40
|
},
|
|
51
41
|
"devDependencies": {
|
|
52
|
-
"@html-eslint/parser": "^0.35.
|
|
42
|
+
"@html-eslint/parser": "^0.35.1",
|
|
43
|
+
"@html-eslint/types": "^0.35.1",
|
|
53
44
|
"@types/eslint": "^9.6.1",
|
|
54
45
|
"@types/estree": "^0.0.47",
|
|
55
|
-
"es-html-parser": "0.1.
|
|
56
|
-
"eslint": "^9",
|
|
46
|
+
"es-html-parser": "0.1.1",
|
|
47
|
+
"eslint": "^9.21.0",
|
|
57
48
|
"espree": "^10.3.0",
|
|
58
49
|
"typescript": "^5.7.2"
|
|
59
50
|
},
|
|
60
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b11e32e8205e808f8b2712e082d1ece37b5191aa"
|
|
61
52
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export let rules: {
|
|
2
|
-
"@html-eslint/require-lang": string;
|
|
3
|
-
"@html-eslint/require-img-alt": string;
|
|
4
|
-
"@html-eslint/require-doctype": string;
|
|
5
|
-
"@html-eslint/require-title": string;
|
|
6
|
-
"@html-eslint/no-multiple-h1": string;
|
|
7
|
-
"@html-eslint/no-extra-spacing-attrs": string;
|
|
8
|
-
"@html-eslint/attrs-newline": string;
|
|
9
|
-
"@html-eslint/element-newline": (string | {
|
|
10
|
-
inline: string[];
|
|
11
|
-
})[];
|
|
12
|
-
"@html-eslint/no-duplicate-id": string;
|
|
13
|
-
"@html-eslint/indent": string;
|
|
14
|
-
"@html-eslint/require-li-container": string;
|
|
15
|
-
"@html-eslint/quotes": string;
|
|
16
|
-
"@html-eslint/no-obsolete-tags": string;
|
|
17
|
-
"@html-eslint/require-closing-tags": string;
|
|
18
|
-
"@html-eslint/no-duplicate-attrs": string;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=recommended.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../lib/configs/recommended.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/constants/index.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obsolete-tags.d.ts","sourceRoot":"","sources":["../../lib/constants/obsolete-tags.js"],"names":[],"mappings":"wBACW,MAAM,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rule-category.d.ts","sourceRoot":"","sources":["../../lib/constants/rule-category.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svg-camel-case-attributes.d.ts","sourceRoot":"","sources":["../../lib/constants/svg-camel-case-attributes.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"void-elements.d.ts","sourceRoot":"","sources":["../../lib/constants/void-elements.js"],"names":[],"mappings":"wBAAW,MAAM,EAAE"}
|
package/types/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export = plugin;
|
|
2
|
-
/**
|
|
3
|
-
* @type {{configs: {recommended: typeof recommended,"flat/recommended": import("eslint").Linter.FlatConfig , rules: typeof rules}}}
|
|
4
|
-
*/
|
|
5
|
-
declare const plugin: {
|
|
6
|
-
configs: {
|
|
7
|
-
recommended: typeof recommended;
|
|
8
|
-
"flat/recommended": import("eslint").Linter.FlatConfig;
|
|
9
|
-
rules: typeof rules;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
import recommended = require("./configs/recommended");
|
|
13
|
-
import rules = require("./rules");
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.js"],"names":[],"mappings":";AAIA;;GAEG;AACH,sBAFU;IAAC,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,WAAW,CAAC;QAAA,kBAAkB,EAAE,OAAO,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAE;QAAC,KAAK,EAAE,OAAO,KAAK,CAAA;KAAC,CAAA;CAAC,CAQjI"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare namespace _exports {
|
|
2
|
-
export { RuleFixer, RuleModule, MessageId };
|
|
3
|
-
}
|
|
4
|
-
declare const _exports: RuleModule;
|
|
5
|
-
export = _exports;
|
|
6
|
-
type RuleFixer = import("eslint").Rule.RuleFixer;
|
|
7
|
-
type RuleModule = import("../types").RuleModule;
|
|
8
|
-
type MessageId = {
|
|
9
|
-
CLOSE_STYLE_WRONG: "closeStyleWrong";
|
|
10
|
-
NEWLINE_MISSING: "newlineMissing";
|
|
11
|
-
NEWLINE_UNEXPECTED: "newlineUnexpected";
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=attrs-newline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attrs-newline.d.ts","sourceRoot":"","sources":["../../lib/rules/attrs-newline.js"],"names":[],"mappings":";;;wBAuBU,UAAU;;iBAtBN,OAAO,QAAQ,EAAE,IAAI,CAAC,SAAS;kBAC/B,OAAO,UAAU,EAAE,UAAU;;uBAG7B,iBAAiB;qBACjB,gBAAgB;wBAChB,mBAAmB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare namespace _exports {
|
|
2
|
-
export { RuleModule, Tag, Comment, Doctype, ScriptTag, StyleTag, Text, NewlineNode, NodeMeta };
|
|
3
|
-
}
|
|
4
|
-
declare const _exports: RuleModule;
|
|
5
|
-
export = _exports;
|
|
6
|
-
type RuleModule = import("../types").RuleModule;
|
|
7
|
-
type Tag = import("../types").Tag;
|
|
8
|
-
type Comment = import("../types").Comment;
|
|
9
|
-
type Doctype = import("../types").Doctype;
|
|
10
|
-
type ScriptTag = import("../types").ScriptTag;
|
|
11
|
-
type StyleTag = import("../types").StyleTag;
|
|
12
|
-
type Text = import("../types").Text;
|
|
13
|
-
type NewlineNode = Tag | Doctype | ScriptTag | StyleTag | Text;
|
|
14
|
-
type NodeMeta = {
|
|
15
|
-
childFirst: NewlineNode | null;
|
|
16
|
-
childLast: NewlineNode | null;
|
|
17
|
-
shouldBeNewline: boolean;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=element-newline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-newline.d.ts","sourceRoot":"","sources":["../../lib/rules/element-newline.js"],"names":[],"mappings":";;;wBAmEU,UAAU;;kBAlEN,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;mBACvB,GAAG,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI;gBAC5C;IACR,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare namespace _exports {
|
|
2
|
-
export { RuleModule, Tag, ScriptTag, StyleTag };
|
|
3
|
-
}
|
|
4
|
-
declare const _exports: RuleModule;
|
|
5
|
-
export = _exports;
|
|
6
|
-
type RuleModule = import("../types").RuleModule;
|
|
7
|
-
type Tag = import("../types").Tag;
|
|
8
|
-
type ScriptTag = import("../types").ScriptTag;
|
|
9
|
-
type StyleTag = import("../types").StyleTag;
|
|
10
|
-
//# sourceMappingURL=id-naming-convention.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|