@html-eslint/eslint-plugin 0.15.0 → 0.16.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/README.md +14 -6
- package/lib/rules/no-extra-spacing-attrs.js +33 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
An ESLint plugin which provides lint rules for HTML.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
|
|
5
|
+
1. [Getting Started](https://yeonjuan.github.io/html-eslint/docs/getting-started)
|
|
6
|
+
- [Installation](https://yeonjuan.github.io/html-eslint/docs/getting-started#installation)
|
|
7
|
+
- [Configuration](https://yeonjuan.github.io/html-eslint/docs/getting-started#configuration)
|
|
8
|
+
- [Editor Configuration](https://yeonjuan.github.io/html-eslint/docs/getting-started#editor-configuration)
|
|
9
|
+
- [VSCode](https://yeonjuan.github.io/html-eslint/docs/getting-started#vscode)
|
|
10
|
+
1. [Recommended Configs](https://yeonjuan.github.io/html-eslint/docs/getting-started#recommended-configs)
|
|
11
|
+
1. [Rules](https://yeonjuan.github.io/html-eslint/docs/rules)
|
|
12
|
+
1. [CLI](https://yeonjuan.github.io/html-eslint/docs/cli)
|
|
13
|
+
1. [Playground](https://yeonjuan.github.io/html-eslint/playground)
|
|
14
|
+
1. [License](#License)
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
Distributed under the MIT License.
|
|
@@ -8,6 +8,7 @@ const MESSAGE_IDS = {
|
|
|
8
8
|
EXTRA_BETWEEN: "unexpectedBetween",
|
|
9
9
|
EXTRA_AFTER: "unexpectedAfter",
|
|
10
10
|
EXTRA_BEFORE: "unexpectedBefore",
|
|
11
|
+
MISSING_BEFORE: "missingBefore",
|
|
11
12
|
MISSING_BEFORE_SELF_CLOSE: "missingBeforeSelfClose",
|
|
12
13
|
EXTRA_BEFORE_SELF_CLOSE: "unexpectedBeforeSelfClose",
|
|
13
14
|
};
|
|
@@ -30,6 +31,9 @@ module.exports = {
|
|
|
30
31
|
{
|
|
31
32
|
type: "object",
|
|
32
33
|
properties: {
|
|
34
|
+
disallowMissing: {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
},
|
|
33
37
|
enforceBeforeSelfClose: {
|
|
34
38
|
type: "boolean",
|
|
35
39
|
},
|
|
@@ -44,11 +48,13 @@ module.exports = {
|
|
|
44
48
|
"Missing space before self closing",
|
|
45
49
|
[MESSAGE_IDS.EXTRA_BEFORE_SELF_CLOSE]:
|
|
46
50
|
"Unexpected extra spaces before self closing",
|
|
51
|
+
[MESSAGE_IDS.MISSING_BEFORE]: "Missing space before attribute",
|
|
47
52
|
},
|
|
48
53
|
},
|
|
49
54
|
create(context) {
|
|
50
55
|
const enforceBeforeSelfClose = !!(context.options[0] || {})
|
|
51
56
|
.enforceBeforeSelfClose;
|
|
57
|
+
const disallowMissing = !!(context.options[0] || {}).disallowMissing;
|
|
52
58
|
|
|
53
59
|
function checkExtraSpacesBetweenAttrs(attrs) {
|
|
54
60
|
attrs.forEach((current, index, attrs) => {
|
|
@@ -69,6 +75,14 @@ module.exports = {
|
|
|
69
75
|
return fixer.removeRange([current.range[1] + 1, after.range[0]]);
|
|
70
76
|
},
|
|
71
77
|
});
|
|
78
|
+
} else if (disallowMissing && spacesBetween < 1) {
|
|
79
|
+
context.report({
|
|
80
|
+
loc: after.loc,
|
|
81
|
+
messageId: MESSAGE_IDS.MISSING_BEFORE,
|
|
82
|
+
fix(fixer) {
|
|
83
|
+
return fixer.insertTextAfter(current, " ");
|
|
84
|
+
},
|
|
85
|
+
});
|
|
72
86
|
}
|
|
73
87
|
});
|
|
74
88
|
}
|
|
@@ -167,24 +181,25 @@ module.exports = {
|
|
|
167
181
|
if (node.attributes.length) {
|
|
168
182
|
checkExtraSpaceBefore(node.openStart, node.attributes[0]);
|
|
169
183
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
if (node.openEnd) {
|
|
185
|
+
const isSelfClosing = node.openEnd.value === "/>";
|
|
186
|
+
|
|
187
|
+
if (node.attributes && node.attributes.length > 0) {
|
|
188
|
+
checkExtraSpaceAfter(
|
|
189
|
+
node.openEnd,
|
|
190
|
+
node.attributes[node.attributes.length - 1],
|
|
191
|
+
isSelfClosing
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
checkExtraSpacesBetweenAttrs(node.attributes);
|
|
196
|
+
if (
|
|
197
|
+
node.attributes.length === 0 &&
|
|
198
|
+
isSelfClosing &&
|
|
199
|
+
enforceBeforeSelfClose
|
|
200
|
+
) {
|
|
201
|
+
checkSpaceBeforeSelfClosing(node.openStart, node.openEnd);
|
|
202
|
+
}
|
|
188
203
|
}
|
|
189
204
|
},
|
|
190
205
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-eslint/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "ESLint plugin for html",
|
|
5
5
|
"author": "yeonjuan",
|
|
6
6
|
"homepage": "https://github.com/yeonjuan/html-eslint#readme",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"accessibility"
|
|
41
41
|
],
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@html-eslint/parser": "^0.
|
|
43
|
+
"@html-eslint/parser": "^0.16.0",
|
|
44
44
|
"@types/eslint": "^7.2.10",
|
|
45
45
|
"@types/estree": "^0.0.47",
|
|
46
46
|
"es-html-parser": "^0.0.8",
|
|
47
47
|
"typescript": "^4.4.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a866203b2c65d63b3f101b16c8d7d1a3bde32c75"
|
|
50
50
|
}
|