@herb-tools/linter 0.8.3 → 0.8.5
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 +3 -3
- package/dist/herb-lint.js +183 -36
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +68 -7
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +68 -7
- package/dist/loader.js.map +1 -1
- package/dist/package.json +7 -7
- package/dist/src/cli.js +2 -8
- package/dist/src/cli.js.map +1 -1
- package/dist/src/rules/html-no-duplicate-meta-names.js +11 -0
- package/dist/src/rules/html-no-duplicate-meta-names.js.map +1 -1
- package/dist/src/rules/html-tag-name-lowercase.js +22 -5
- package/dist/src/rules/html-tag-name-lowercase.js.map +1 -1
- package/package.json +7 -7
- package/src/cli.ts +1 -7
- package/src/rules/html-no-duplicate-meta-names.ts +13 -0
- package/src/rules/html-tag-name-lowercase.ts +22 -5
package/dist/loader.cjs
CHANGED
|
@@ -186,7 +186,7 @@ class Token {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
189
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
189
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/javascript/packages/core/src/errors.ts.erb
|
|
190
190
|
class HerbError {
|
|
191
191
|
type;
|
|
192
192
|
message;
|
|
@@ -689,6 +689,40 @@ class MissingERBEndTagError extends HerbError {
|
|
|
689
689
|
return output;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
+
class ERBMultipleBlocksInTagError extends HerbError {
|
|
693
|
+
static from(data) {
|
|
694
|
+
return new ERBMultipleBlocksInTagError({
|
|
695
|
+
type: data.type,
|
|
696
|
+
message: data.message,
|
|
697
|
+
location: Location.from(data.location),
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
constructor(props) {
|
|
701
|
+
super(props.type, props.message, props.location);
|
|
702
|
+
}
|
|
703
|
+
toJSON() {
|
|
704
|
+
return {
|
|
705
|
+
...super.toJSON(),
|
|
706
|
+
type: "ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR",
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
toMonacoDiagnostic() {
|
|
710
|
+
return {
|
|
711
|
+
line: this.location.start.line,
|
|
712
|
+
column: this.location.start.column,
|
|
713
|
+
endLine: this.location.end.line,
|
|
714
|
+
endColumn: this.location.end.column,
|
|
715
|
+
message: this.message,
|
|
716
|
+
severity: 'error'
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
treeInspect() {
|
|
720
|
+
let output = "";
|
|
721
|
+
output += `@ ERBMultipleBlocksInTagError ${this.location.treeInspectWithLabel()}\n`;
|
|
722
|
+
output += `└── message: "${this.message}"\n`;
|
|
723
|
+
return output;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
692
726
|
function fromSerializedError(error) {
|
|
693
727
|
switch (error.type) {
|
|
694
728
|
case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
|
|
@@ -702,6 +736,7 @@ function fromSerializedError(error) {
|
|
|
702
736
|
case "RUBY_PARSE_ERROR": return RubyParseError.from(error);
|
|
703
737
|
case "ERB_CONTROL_FLOW_SCOPE_ERROR": return ERBControlFlowScopeError.from(error);
|
|
704
738
|
case "MISSINGERB_END_TAG_ERROR": return MissingERBEndTagError.from(error);
|
|
739
|
+
case "ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR": return ERBMultipleBlocksInTagError.from(error);
|
|
705
740
|
default:
|
|
706
741
|
throw new Error(`Unknown node type: ${error.type}`);
|
|
707
742
|
}
|
|
@@ -716,7 +751,7 @@ function convertToUTF8(string) {
|
|
|
716
751
|
}
|
|
717
752
|
|
|
718
753
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
719
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
754
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/javascript/packages/core/src/nodes.ts.erb
|
|
720
755
|
class Node {
|
|
721
756
|
type;
|
|
722
757
|
location;
|
|
@@ -2950,7 +2985,7 @@ class ParseResult extends Result {
|
|
|
2950
2985
|
}
|
|
2951
2986
|
|
|
2952
2987
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2953
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
2988
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
2954
2989
|
/**
|
|
2955
2990
|
* Type guard functions for AST nodes.
|
|
2956
2991
|
* These functions provide type checking by combining both instanceof
|
|
@@ -3653,7 +3688,7 @@ function didyoumean(input, list, threshold) {
|
|
|
3653
3688
|
}
|
|
3654
3689
|
|
|
3655
3690
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
3656
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
3691
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/javascript/packages/core/src/visitor.ts.erb
|
|
3657
3692
|
class Visitor {
|
|
3658
3693
|
visit(node) {
|
|
3659
3694
|
if (!node)
|
|
@@ -9598,6 +9633,9 @@ class HTMLNoDuplicateMetaNamesVisitor extends ControlFlowTrackingVisitor {
|
|
|
9598
9633
|
else if (name === "http-equiv" && value) {
|
|
9599
9634
|
metaTag.httpEquivValue = value;
|
|
9600
9635
|
}
|
|
9636
|
+
else if (name === "media" && value) {
|
|
9637
|
+
metaTag.mediaValue = value;
|
|
9638
|
+
}
|
|
9601
9639
|
});
|
|
9602
9640
|
}
|
|
9603
9641
|
}
|
|
@@ -9629,6 +9667,14 @@ class HTMLNoDuplicateMetaNamesVisitor extends ControlFlowTrackingVisitor {
|
|
|
9629
9667
|
}
|
|
9630
9668
|
}
|
|
9631
9669
|
areMetaTagsDuplicate(meta1, meta2) {
|
|
9670
|
+
if (meta1.mediaValue && meta2.mediaValue) {
|
|
9671
|
+
if (meta1.mediaValue.toLowerCase() !== meta2.mediaValue.toLowerCase()) {
|
|
9672
|
+
return false;
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
if ((meta1.mediaValue && !meta2.mediaValue) || (!meta1.mediaValue && meta2.mediaValue)) {
|
|
9676
|
+
return false;
|
|
9677
|
+
}
|
|
9632
9678
|
if (meta1.nameValue && meta2.nameValue) {
|
|
9633
9679
|
return meta1.nameValue.toLowerCase() === meta2.nameValue.toLowerCase();
|
|
9634
9680
|
}
|
|
@@ -10333,10 +10379,25 @@ class HTMLTagNameLowercaseRule extends ParserRule {
|
|
|
10333
10379
|
autofix(offense, result, _context) {
|
|
10334
10380
|
if (!offense.autofixContext)
|
|
10335
10381
|
return null;
|
|
10336
|
-
const { node
|
|
10337
|
-
if (!tag_name)
|
|
10382
|
+
const { node, correctedTagName } = offense.autofixContext;
|
|
10383
|
+
if (!node.tag_name)
|
|
10338
10384
|
return null;
|
|
10339
|
-
tag_name.value = correctedTagName;
|
|
10385
|
+
node.tag_name.value = correctedTagName;
|
|
10386
|
+
const parentElement = findParent(result.value, node);
|
|
10387
|
+
if (!parentElement || !isHTMLElementNode(parentElement))
|
|
10388
|
+
return result;
|
|
10389
|
+
switch (node.type) {
|
|
10390
|
+
case "AST_HTML_OPEN_TAG_NODE":
|
|
10391
|
+
if (!parentElement.close_tag)
|
|
10392
|
+
break;
|
|
10393
|
+
const closeTag = parentElement.close_tag;
|
|
10394
|
+
closeTag.tag_name.value = correctedTagName;
|
|
10395
|
+
break;
|
|
10396
|
+
case "AST_HTML_CLOSE_TAG_NODE":
|
|
10397
|
+
const openTag = parentElement.open_tag;
|
|
10398
|
+
openTag.tag_name.value = correctedTagName;
|
|
10399
|
+
break;
|
|
10400
|
+
}
|
|
10340
10401
|
return result;
|
|
10341
10402
|
}
|
|
10342
10403
|
}
|