@reteps/tree-sitter-htmlmustache 0.3.0 → 0.3.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/cli/out/main.js +51 -1
- package/package.json +1 -1
package/cli/out/main.js
CHANGED
|
@@ -2243,6 +2243,55 @@ function collectAttributes(node, conditions, out) {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
2246
|
+
function checkUnescapedEntities(rootNode) {
|
|
2247
|
+
const errors = [];
|
|
2248
|
+
function visit(node) {
|
|
2249
|
+
if (node.type === "text") {
|
|
2250
|
+
if (node.text === "&") {
|
|
2251
|
+
errors.push({
|
|
2252
|
+
node,
|
|
2253
|
+
message: 'Unescaped "&" in text content \u2014 use & instead',
|
|
2254
|
+
severity: "warning",
|
|
2255
|
+
fix: [{
|
|
2256
|
+
startIndex: node.startIndex,
|
|
2257
|
+
endIndex: node.endIndex,
|
|
2258
|
+
newText: "&"
|
|
2259
|
+
}],
|
|
2260
|
+
fixDescription: "Replace & with &"
|
|
2261
|
+
});
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
if (node.text.includes(">")) {
|
|
2265
|
+
const fixes = [];
|
|
2266
|
+
let searchFrom = 0;
|
|
2267
|
+
const text2 = node.text;
|
|
2268
|
+
while (true) {
|
|
2269
|
+
const idx = text2.indexOf(">", searchFrom);
|
|
2270
|
+
if (idx === -1) break;
|
|
2271
|
+
fixes.push({
|
|
2272
|
+
startIndex: node.startIndex + idx,
|
|
2273
|
+
endIndex: node.startIndex + idx + 1,
|
|
2274
|
+
newText: ">"
|
|
2275
|
+
});
|
|
2276
|
+
searchFrom = idx + 1;
|
|
2277
|
+
}
|
|
2278
|
+
errors.push({
|
|
2279
|
+
node,
|
|
2280
|
+
message: 'Unescaped ">" in text content \u2014 use > instead',
|
|
2281
|
+
severity: "warning",
|
|
2282
|
+
fix: fixes,
|
|
2283
|
+
fixDescription: "Replace > with >"
|
|
2284
|
+
});
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
for (const child of node.children) {
|
|
2289
|
+
visit(child);
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
visit(rootNode);
|
|
2293
|
+
return errors;
|
|
2294
|
+
}
|
|
2246
2295
|
function checkDuplicateAttributes(rootNode) {
|
|
2247
2296
|
const errors = [];
|
|
2248
2297
|
function visit(node) {
|
|
@@ -2339,7 +2388,8 @@ function collectErrors(tree) {
|
|
|
2339
2388
|
...checkUnquotedMustacheAttributes(tree.rootNode),
|
|
2340
2389
|
...checkConsecutiveSameNameSections(tree.rootNode, sourceText),
|
|
2341
2390
|
...checkSelfClosingNonVoidTags(tree.rootNode),
|
|
2342
|
-
...checkDuplicateAttributes(tree.rootNode)
|
|
2391
|
+
...checkDuplicateAttributes(tree.rootNode),
|
|
2392
|
+
...checkUnescapedEntities(tree.rootNode)
|
|
2343
2393
|
];
|
|
2344
2394
|
for (const error of mustacheChecks) {
|
|
2345
2395
|
errors.push({
|