@html-eslint/eslint-plugin 0.35.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 +25 -18
- package/lib/rules/id-naming-convention.js +10 -4
- package/lib/rules/indent/indent-level.js +1 -1
- package/lib/rules/indent/indent.js +26 -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 +23 -23
- 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 -200
- 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 -16
- 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 -32
- 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 -119
- 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
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("
|
|
5
|
-
* @typedef { import("../types").StyleTag } StyleTag
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").ScriptTag } ScriptTag
|
|
4
|
+
* @typedef { import("@html-eslint/types").StyleTag } StyleTag
|
|
6
5
|
*
|
|
7
6
|
* @typedef {Object} Option
|
|
8
7
|
* @property {string} tag
|
|
9
8
|
* @property {string} attr
|
|
10
|
-
* @property {string
|
|
9
|
+
* @property {string} [value]
|
|
10
|
+
*
|
|
11
|
+
* @typedef { import("../types").RuleModule<Option[]> } RuleModule
|
|
12
|
+
*
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
const { NODE_TYPES } = require("@html-eslint/parser");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
*
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
*
|
|
4
|
+
* @typedef {Object} Option
|
|
5
|
+
* @property {"always" | "never"} [Option.selfClosing]
|
|
6
|
+
* @property {string[]} [Option.selfClosingCustomPatterns]
|
|
7
|
+
* @typedef { import("../types").RuleModule<[Option]> } RuleModule
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
const { RULE_CATEGORY, VOID_ELEMENTS } = require("../constants");
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
*
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
4
|
+
*
|
|
5
|
+
* @typedef {Object} Option
|
|
6
|
+
* @property {string[]} [Option.allowClass]
|
|
7
|
+
* @property {string[]} [Option.allowId]
|
|
8
|
+
* @typedef { import("../types").RuleModule<[Option]> } RuleModule
|
|
9
|
+
*
|
|
5
10
|
*/
|
|
6
11
|
|
|
7
12
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
*
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
*
|
|
4
|
+
* @typedef {Object} Option
|
|
5
|
+
* @property {string[]} [Option.substitute]
|
|
6
|
+
*
|
|
7
|
+
* @typedef { import("../types").RuleModule<[Option]> } RuleModule
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -56,12 +60,9 @@ module.exports = {
|
|
|
56
60
|
}
|
|
57
61
|
if (!hasAltAttrAndValue(node, substitute)) {
|
|
58
62
|
context.report({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
end: node.openEnd.loc.end,
|
|
63
|
-
},
|
|
64
|
-
range: [node.openStart.range[0], node.openEnd.range[1]],
|
|
63
|
+
loc: {
|
|
64
|
+
start: node.openStart.loc.start,
|
|
65
|
+
end: node.openEnd.loc.end,
|
|
65
66
|
},
|
|
66
67
|
messageId: MESSAGE_IDS.MISSING_ALT,
|
|
67
68
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("../types").
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("../types").RuleModule } RuleModule
|
|
2
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -41,12 +41,9 @@ module.exports = {
|
|
|
41
41
|
const langAttr = findAttr(node, "lang");
|
|
42
42
|
if (!langAttr) {
|
|
43
43
|
context.report({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
end: node.openEnd.loc.end,
|
|
48
|
-
},
|
|
49
|
-
range: [node.openStart.range[0], node.openEnd.range[1]],
|
|
44
|
+
loc: {
|
|
45
|
+
start: node.openStart.loc.start,
|
|
46
|
+
end: node.openEnd.loc.end,
|
|
50
47
|
},
|
|
51
48
|
messageId: MESSAGE_IDS.MISSING,
|
|
52
49
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("../types").
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
4
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("../types").
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
4
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
5
5
|
*/
|
|
6
6
|
const { RULE_CATEGORY } = require("../constants");
|
|
7
7
|
const { filter } = require("./utils/array");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("../types").
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
4
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
*
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
4
|
+
*
|
|
5
|
+
* @typedef {string[]} Option
|
|
6
|
+
*
|
|
7
|
+
* @typedef { import("../types").RuleModule<[Option]> } RuleModule
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
10
|
const { RULE_CATEGORY } = require("../constants");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("
|
|
5
|
-
* @typedef { import("../types").
|
|
2
|
+
* @typedef { import("@html-eslint/types").Tag } Tag
|
|
3
|
+
* @typedef { import("@html-eslint/types").Text } Text
|
|
4
|
+
* @typedef { import("@html-eslint/types").AnyNode } AnyNode
|
|
5
|
+
* @typedef { import("../types").RuleModule<[]> } RuleModule
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const { RULE_CATEGORY } = require("../constants");
|
package/lib/rules/sort-attrs.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("
|
|
3
|
-
* @typedef { import("
|
|
4
|
-
* @typedef { import("
|
|
5
|
-
*
|
|
2
|
+
* @typedef { import("../types").RuleFixer } RuleFixer
|
|
3
|
+
* @typedef { import("@html-eslint/types").Attribute } Attribute
|
|
4
|
+
* @typedef { import("@html-eslint/types").Text } Text
|
|
5
|
+
*
|
|
6
|
+
* @typedef {Object} Option
|
|
7
|
+
* @property {string[]} [Option.priority]
|
|
8
|
+
* @typedef { import("../types").RuleModule<[Option]> } RuleModule
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
11
|
const { hasTemplate } = require("./utils/node");
|
|
@@ -53,7 +56,7 @@ module.exports = {
|
|
|
53
56
|
/**
|
|
54
57
|
* @type {string[]}
|
|
55
58
|
*/
|
|
56
|
-
const priority = option.priority;
|
|
59
|
+
const priority = option.priority || [];
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* @param {Attribute} attrA
|
|
@@ -165,12 +168,9 @@ module.exports = {
|
|
|
165
168
|
const first = unsorted[0];
|
|
166
169
|
const last = unsorted[unsorted.length - 1];
|
|
167
170
|
context.report({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
start: first.loc.start,
|
|
172
|
-
end: last.loc.end,
|
|
173
|
-
},
|
|
171
|
+
loc: {
|
|
172
|
+
start: first.loc.start,
|
|
173
|
+
end: last.loc.end,
|
|
174
174
|
},
|
|
175
175
|
messageId: MESSAGE_IDS.UNSORTED,
|
|
176
176
|
fix(fixer) {
|
package/lib/rules/utils/node.js
CHANGED
|
@@ -1,23 +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("
|
|
14
|
-
* @typedef { import("
|
|
15
|
-
* @typedef { import("
|
|
16
|
-
* @typedef { import("../../types").AnyPartNode } AnyPartNode
|
|
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
|
|
17
17
|
* @typedef { import("eslint").AST.Range } Range
|
|
18
18
|
* @typedef { import("eslint").AST.SourceLocation } SourceLocation
|
|
19
19
|
* @typedef { import("es-html-parser").AnyToken } AnyToken
|
|
20
|
-
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
const { NODE_TYPES } = require("@html-eslint/parser");
|
|
@@ -156,7 +155,7 @@ function getLocBetween(before, after) {
|
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
/**
|
|
159
|
-
* @param {
|
|
158
|
+
* @param {BaseNode} node
|
|
160
159
|
* @returns {node is Tag}
|
|
161
160
|
*/
|
|
162
161
|
function isTag(node) {
|
|
@@ -164,7 +163,7 @@ function isTag(node) {
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
|
-
* @param {
|
|
166
|
+
* @param {BaseNode} node
|
|
168
167
|
* @returns {node is ScriptTag}
|
|
169
168
|
*/
|
|
170
169
|
function isScript(node) {
|
|
@@ -172,7 +171,7 @@ function isScript(node) {
|
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
/**
|
|
175
|
-
* @param {
|
|
174
|
+
* @param {BaseNode} node
|
|
176
175
|
* @returns {node is StyleTag}
|
|
177
176
|
*/
|
|
178
177
|
function isStyle(node) {
|
|
@@ -180,7 +179,7 @@ function isStyle(node) {
|
|
|
180
179
|
}
|
|
181
180
|
|
|
182
181
|
/**
|
|
183
|
-
* @param {
|
|
182
|
+
* @param {BaseNode} node
|
|
184
183
|
* @returns {node is Comment}
|
|
185
184
|
*/
|
|
186
185
|
function isComment(node) {
|
|
@@ -188,7 +187,7 @@ function isComment(node) {
|
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
/**
|
|
191
|
-
* @param {
|
|
190
|
+
* @param {BaseNode} node
|
|
192
191
|
* @returns {node is Text}
|
|
193
192
|
*/
|
|
194
193
|
function isText(node) {
|
|
@@ -196,7 +195,7 @@ function isText(node) {
|
|
|
196
195
|
}
|
|
197
196
|
|
|
198
197
|
/**
|
|
199
|
-
* @param {
|
|
198
|
+
* @param {BaseNode} node
|
|
200
199
|
* @returns {node is Line}
|
|
201
200
|
*/
|
|
202
201
|
function isLine(node) {
|
|
@@ -214,7 +213,7 @@ function codeToLines(source) {
|
|
|
214
213
|
}
|
|
215
214
|
|
|
216
215
|
/**
|
|
217
|
-
* @param {
|
|
216
|
+
* @param {AnyNode} node
|
|
218
217
|
* @param {(node: AnyNode) => boolean} predicate
|
|
219
218
|
* @returns {null | AnyNode}
|
|
220
219
|
*/
|
|
@@ -224,7 +223,8 @@ function findParent(node, predicate) {
|
|
|
224
223
|
}
|
|
225
224
|
if (
|
|
226
225
|
node.type === "TaggedTemplateExpression" ||
|
|
227
|
-
node.type === "TemplateLiteral"
|
|
226
|
+
node.type === "TemplateLiteral" ||
|
|
227
|
+
node.type === "TemplateElement"
|
|
228
228
|
) {
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
@@ -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,213 +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 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
|
-
|
|
181
|
-
export type AnyNode =
|
|
182
|
-
| Document
|
|
183
|
-
| Doctype
|
|
184
|
-
| DoctypeOpen
|
|
185
|
-
| DoctypeClose
|
|
186
|
-
| DoctypeAttribute
|
|
187
|
-
| Comment
|
|
188
|
-
| CommentOpen
|
|
189
|
-
| CommentClose
|
|
190
|
-
| CommentContent
|
|
191
|
-
| Tag
|
|
192
|
-
| OpenTagStart
|
|
193
|
-
| OpenTagEnd
|
|
194
|
-
| CloseTag
|
|
195
|
-
| ScriptTag
|
|
196
|
-
| OpenScriptTagStart
|
|
197
|
-
| OpenScriptTagEnd
|
|
198
|
-
| ScriptTagContent
|
|
199
|
-
| CloseScriptTag
|
|
200
|
-
| StyleTag
|
|
201
|
-
| OpenStyleTagStart
|
|
202
|
-
| OpenStyleTagEnd
|
|
203
|
-
| StyleTagContent
|
|
204
|
-
| CloseStyleTag
|
|
205
|
-
| Attribute
|
|
206
|
-
| AttributeKey
|
|
207
|
-
| AttributeValue
|
|
208
|
-
| AttributeValueWrapperEnd
|
|
209
|
-
| AttributeValueWrapperStart
|
|
210
|
-
| Text
|
|
211
|
-
| Line
|
|
212
|
-
| TaggedTemplateExpression
|
|
213
|
-
| TemplateLiteral;
|
package/lib/types/index.d.ts
CHANGED