@herb-tools/linter 0.8.4 → 0.8.6

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/dist/loader.js CHANGED
@@ -165,7 +165,7 @@ class Token {
165
165
  }
166
166
 
167
167
  // NOTE: This file is generated by the templates/template.rb script and should not
168
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/errors.ts.erb
168
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/core/src/errors.ts.erb
169
169
  class HerbError {
170
170
  type;
171
171
  message;
@@ -668,6 +668,40 @@ class MissingERBEndTagError extends HerbError {
668
668
  return output;
669
669
  }
670
670
  }
671
+ class ERBMultipleBlocksInTagError extends HerbError {
672
+ static from(data) {
673
+ return new ERBMultipleBlocksInTagError({
674
+ type: data.type,
675
+ message: data.message,
676
+ location: Location.from(data.location),
677
+ });
678
+ }
679
+ constructor(props) {
680
+ super(props.type, props.message, props.location);
681
+ }
682
+ toJSON() {
683
+ return {
684
+ ...super.toJSON(),
685
+ type: "ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR",
686
+ };
687
+ }
688
+ toMonacoDiagnostic() {
689
+ return {
690
+ line: this.location.start.line,
691
+ column: this.location.start.column,
692
+ endLine: this.location.end.line,
693
+ endColumn: this.location.end.column,
694
+ message: this.message,
695
+ severity: 'error'
696
+ };
697
+ }
698
+ treeInspect() {
699
+ let output = "";
700
+ output += `@ ERBMultipleBlocksInTagError ${this.location.treeInspectWithLabel()}\n`;
701
+ output += `└── message: "${this.message}"\n`;
702
+ return output;
703
+ }
704
+ }
671
705
  function fromSerializedError(error) {
672
706
  switch (error.type) {
673
707
  case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
@@ -681,6 +715,7 @@ function fromSerializedError(error) {
681
715
  case "RUBY_PARSE_ERROR": return RubyParseError.from(error);
682
716
  case "ERB_CONTROL_FLOW_SCOPE_ERROR": return ERBControlFlowScopeError.from(error);
683
717
  case "MISSINGERB_END_TAG_ERROR": return MissingERBEndTagError.from(error);
718
+ case "ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR": return ERBMultipleBlocksInTagError.from(error);
684
719
  default:
685
720
  throw new Error(`Unknown node type: ${error.type}`);
686
721
  }
@@ -695,7 +730,7 @@ function convertToUTF8(string) {
695
730
  }
696
731
 
697
732
  // NOTE: This file is generated by the templates/template.rb script and should not
698
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/nodes.ts.erb
733
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/core/src/nodes.ts.erb
699
734
  class Node {
700
735
  type;
701
736
  location;
@@ -2929,7 +2964,7 @@ class ParseResult extends Result {
2929
2964
  }
2930
2965
 
2931
2966
  // NOTE: This file is generated by the templates/template.rb script and should not
2932
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/node-type-guards.ts.erb
2967
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/core/src/node-type-guards.ts.erb
2933
2968
  /**
2934
2969
  * Type guard functions for AST nodes.
2935
2970
  * These functions provide type checking by combining both instanceof
@@ -3632,7 +3667,7 @@ function didyoumean(input, list, threshold) {
3632
3667
  }
3633
3668
 
3634
3669
  // NOTE: This file is generated by the templates/template.rb script and should not
3635
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/visitor.ts.erb
3670
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/core/src/visitor.ts.erb
3636
3671
  class Visitor {
3637
3672
  visit(node) {
3638
3673
  if (!node)
@@ -9577,6 +9612,9 @@ class HTMLNoDuplicateMetaNamesVisitor extends ControlFlowTrackingVisitor {
9577
9612
  else if (name === "http-equiv" && value) {
9578
9613
  metaTag.httpEquivValue = value;
9579
9614
  }
9615
+ else if (name === "media" && value) {
9616
+ metaTag.mediaValue = value;
9617
+ }
9580
9618
  });
9581
9619
  }
9582
9620
  }
@@ -9608,6 +9646,14 @@ class HTMLNoDuplicateMetaNamesVisitor extends ControlFlowTrackingVisitor {
9608
9646
  }
9609
9647
  }
9610
9648
  areMetaTagsDuplicate(meta1, meta2) {
9649
+ if (meta1.mediaValue && meta2.mediaValue) {
9650
+ if (meta1.mediaValue.toLowerCase() !== meta2.mediaValue.toLowerCase()) {
9651
+ return false;
9652
+ }
9653
+ }
9654
+ if ((meta1.mediaValue && !meta2.mediaValue) || (!meta1.mediaValue && meta2.mediaValue)) {
9655
+ return false;
9656
+ }
9611
9657
  if (meta1.nameValue && meta2.nameValue) {
9612
9658
  return meta1.nameValue.toLowerCase() === meta2.nameValue.toLowerCase();
9613
9659
  }
@@ -10312,10 +10358,25 @@ class HTMLTagNameLowercaseRule extends ParserRule {
10312
10358
  autofix(offense, result, _context) {
10313
10359
  if (!offense.autofixContext)
10314
10360
  return null;
10315
- const { node: { tag_name }, correctedTagName } = offense.autofixContext;
10316
- if (!tag_name)
10361
+ const { node, correctedTagName } = offense.autofixContext;
10362
+ if (!node.tag_name)
10317
10363
  return null;
10318
- tag_name.value = correctedTagName;
10364
+ node.tag_name.value = correctedTagName;
10365
+ const parentElement = findParent(result.value, node);
10366
+ if (!parentElement || !isHTMLElementNode(parentElement))
10367
+ return result;
10368
+ switch (node.type) {
10369
+ case "AST_HTML_OPEN_TAG_NODE":
10370
+ if (!parentElement.close_tag)
10371
+ break;
10372
+ const closeTag = parentElement.close_tag;
10373
+ closeTag.tag_name.value = correctedTagName;
10374
+ break;
10375
+ case "AST_HTML_CLOSE_TAG_NODE":
10376
+ const openTag = parentElement.open_tag;
10377
+ openTag.tag_name.value = correctedTagName;
10378
+ break;
10379
+ }
10319
10380
  return result;
10320
10381
  }
10321
10382
  }