@herb-tools/linter 0.4.2 → 0.4.3

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.
Files changed (146) hide show
  1. package/README.md +16 -2
  2. package/dist/herb-lint.js +426 -116
  3. package/dist/herb-lint.js.map +1 -1
  4. package/dist/index.cjs +322 -61
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.js +317 -63
  7. package/dist/index.js.map +1 -1
  8. package/dist/package.json +4 -4
  9. package/dist/src/cli/file-processor.js +2 -4
  10. package/dist/src/cli/file-processor.js.map +1 -1
  11. package/dist/src/default-rules.js +6 -0
  12. package/dist/src/default-rules.js.map +1 -1
  13. package/dist/src/linter.js +37 -6
  14. package/dist/src/linter.js.map +1 -1
  15. package/dist/src/rules/erb-no-empty-tags.js +4 -3
  16. package/dist/src/rules/erb-no-empty-tags.js.map +1 -1
  17. package/dist/src/rules/erb-no-output-control-flow.js +4 -3
  18. package/dist/src/rules/erb-no-output-control-flow.js.map +1 -1
  19. package/dist/src/rules/erb-prefer-image-tag-helper.js +93 -0
  20. package/dist/src/rules/erb-prefer-image-tag-helper.js.map +1 -0
  21. package/dist/src/rules/erb-require-whitespace-inside-tags.js +4 -3
  22. package/dist/src/rules/erb-require-whitespace-inside-tags.js.map +1 -1
  23. package/dist/src/rules/erb-requires-trailing-newline.js +22 -0
  24. package/dist/src/rules/erb-requires-trailing-newline.js.map +1 -0
  25. package/dist/src/rules/html-anchor-require-href.js +4 -3
  26. package/dist/src/rules/html-anchor-require-href.js.map +1 -1
  27. package/dist/src/rules/html-aria-attribute-must-be-valid.js +4 -3
  28. package/dist/src/rules/html-aria-attribute-must-be-valid.js.map +1 -1
  29. package/dist/src/rules/html-aria-level-must-be-valid.js +27 -0
  30. package/dist/src/rules/html-aria-level-must-be-valid.js.map +1 -0
  31. package/dist/src/rules/html-aria-role-heading-requires-level.js +4 -3
  32. package/dist/src/rules/html-aria-role-heading-requires-level.js.map +1 -1
  33. package/dist/src/rules/html-aria-role-must-be-valid.js +4 -3
  34. package/dist/src/rules/html-aria-role-must-be-valid.js.map +1 -1
  35. package/dist/src/rules/html-attribute-double-quotes.js +4 -3
  36. package/dist/src/rules/html-attribute-double-quotes.js.map +1 -1
  37. package/dist/src/rules/html-attribute-values-require-quotes.js +4 -3
  38. package/dist/src/rules/html-attribute-values-require-quotes.js.map +1 -1
  39. package/dist/src/rules/html-boolean-attributes-no-value.js +4 -3
  40. package/dist/src/rules/html-boolean-attributes-no-value.js.map +1 -1
  41. package/dist/src/rules/html-img-require-alt.js +4 -3
  42. package/dist/src/rules/html-img-require-alt.js.map +1 -1
  43. package/dist/src/rules/html-no-block-inside-inline.js +4 -3
  44. package/dist/src/rules/html-no-block-inside-inline.js.map +1 -1
  45. package/dist/src/rules/html-no-duplicate-attributes.js +4 -3
  46. package/dist/src/rules/html-no-duplicate-attributes.js.map +1 -1
  47. package/dist/src/rules/html-no-duplicate-ids.js +4 -3
  48. package/dist/src/rules/html-no-duplicate-ids.js.map +1 -1
  49. package/dist/src/rules/html-no-empty-headings.js +4 -3
  50. package/dist/src/rules/html-no-empty-headings.js.map +1 -1
  51. package/dist/src/rules/html-no-nested-links.js +4 -3
  52. package/dist/src/rules/html-no-nested-links.js.map +1 -1
  53. package/dist/src/rules/html-tag-name-lowercase.js +4 -3
  54. package/dist/src/rules/html-tag-name-lowercase.js.map +1 -1
  55. package/dist/src/rules/index.js +3 -0
  56. package/dist/src/rules/index.js.map +1 -1
  57. package/dist/src/rules/rule-utils.js +125 -2
  58. package/dist/src/rules/rule-utils.js.map +1 -1
  59. package/dist/src/rules/svg-tag-name-capitalization.js +4 -3
  60. package/dist/src/rules/svg-tag-name-capitalization.js.map +1 -1
  61. package/dist/src/types.js +15 -1
  62. package/dist/src/types.js.map +1 -1
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/dist/types/linter.d.ts +20 -5
  65. package/dist/types/rules/erb-no-empty-tags.d.ts +4 -3
  66. package/dist/types/rules/erb-no-output-control-flow.d.ts +4 -3
  67. package/dist/types/rules/erb-prefer-image-tag-helper.d.ts +7 -0
  68. package/dist/types/rules/erb-require-whitespace-inside-tags.d.ts +4 -3
  69. package/dist/types/rules/erb-requires-trailing-newline.d.ts +6 -0
  70. package/dist/types/rules/html-anchor-require-href.d.ts +4 -3
  71. package/dist/types/rules/html-aria-attribute-must-be-valid.d.ts +4 -3
  72. package/dist/types/rules/html-aria-level-must-be-valid.d.ts +7 -0
  73. package/dist/types/rules/html-aria-role-heading-requires-level.d.ts +4 -3
  74. package/dist/types/rules/html-aria-role-must-be-valid.d.ts +4 -3
  75. package/dist/types/rules/html-attribute-double-quotes.d.ts +4 -3
  76. package/dist/types/rules/html-attribute-values-require-quotes.d.ts +4 -3
  77. package/dist/types/rules/html-boolean-attributes-no-value.d.ts +4 -3
  78. package/dist/types/rules/html-img-require-alt.d.ts +4 -3
  79. package/dist/types/rules/html-no-block-inside-inline.d.ts +4 -3
  80. package/dist/types/rules/html-no-duplicate-attributes.d.ts +4 -3
  81. package/dist/types/rules/html-no-duplicate-ids.d.ts +4 -3
  82. package/dist/types/rules/html-no-empty-headings.d.ts +4 -3
  83. package/dist/types/rules/html-no-nested-links.d.ts +4 -3
  84. package/dist/types/rules/html-tag-name-lowercase.d.ts +4 -3
  85. package/dist/types/rules/index.d.ts +3 -0
  86. package/dist/types/rules/rule-utils.d.ts +73 -4
  87. package/dist/types/rules/svg-tag-name-capitalization.d.ts +4 -3
  88. package/dist/types/src/linter.d.ts +20 -5
  89. package/dist/types/src/rules/erb-no-empty-tags.d.ts +4 -3
  90. package/dist/types/src/rules/erb-no-output-control-flow.d.ts +4 -3
  91. package/dist/types/src/rules/erb-prefer-image-tag-helper.d.ts +7 -0
  92. package/dist/types/src/rules/erb-require-whitespace-inside-tags.d.ts +4 -3
  93. package/dist/types/src/rules/erb-requires-trailing-newline.d.ts +6 -0
  94. package/dist/types/src/rules/html-anchor-require-href.d.ts +4 -3
  95. package/dist/types/src/rules/html-aria-attribute-must-be-valid.d.ts +4 -3
  96. package/dist/types/src/rules/html-aria-level-must-be-valid.d.ts +7 -0
  97. package/dist/types/src/rules/html-aria-role-heading-requires-level.d.ts +4 -3
  98. package/dist/types/src/rules/html-aria-role-must-be-valid.d.ts +4 -3
  99. package/dist/types/src/rules/html-attribute-double-quotes.d.ts +4 -3
  100. package/dist/types/src/rules/html-attribute-values-require-quotes.d.ts +4 -3
  101. package/dist/types/src/rules/html-boolean-attributes-no-value.d.ts +4 -3
  102. package/dist/types/src/rules/html-img-require-alt.d.ts +4 -3
  103. package/dist/types/src/rules/html-no-block-inside-inline.d.ts +4 -3
  104. package/dist/types/src/rules/html-no-duplicate-attributes.d.ts +4 -3
  105. package/dist/types/src/rules/html-no-duplicate-ids.d.ts +4 -3
  106. package/dist/types/src/rules/html-no-empty-headings.d.ts +4 -3
  107. package/dist/types/src/rules/html-no-nested-links.d.ts +4 -3
  108. package/dist/types/src/rules/html-tag-name-lowercase.d.ts +4 -3
  109. package/dist/types/src/rules/index.d.ts +3 -0
  110. package/dist/types/src/rules/rule-utils.d.ts +73 -4
  111. package/dist/types/src/rules/svg-tag-name-capitalization.d.ts +4 -3
  112. package/dist/types/src/types.d.ts +49 -6
  113. package/dist/types/types.d.ts +49 -6
  114. package/docs/rules/README.md +4 -1
  115. package/docs/rules/erb-prefer-image-tag-helper.md +65 -0
  116. package/docs/rules/erb-requires-trailing-newline.md +37 -0
  117. package/docs/rules/html-anchor-require-href.md +1 -1
  118. package/docs/rules/html-aria-level-must-be-valid.md +37 -0
  119. package/package.json +4 -4
  120. package/src/cli/file-processor.ts +2 -4
  121. package/src/default-rules.ts +6 -0
  122. package/src/linter.ts +42 -8
  123. package/src/rules/erb-no-empty-tags.ts +5 -4
  124. package/src/rules/erb-no-output-control-flow.ts +6 -4
  125. package/src/rules/erb-prefer-image-tag-helper.ts +124 -0
  126. package/src/rules/erb-require-whitespace-inside-tags.ts +5 -4
  127. package/src/rules/erb-requires-trailing-newline.ts +27 -0
  128. package/src/rules/html-anchor-require-href.ts +5 -4
  129. package/src/rules/html-aria-attribute-must-be-valid.ts +5 -5
  130. package/src/rules/html-aria-level-must-be-valid.ts +42 -0
  131. package/src/rules/html-aria-role-heading-requires-level.ts +5 -4
  132. package/src/rules/html-aria-role-must-be-valid.ts +5 -4
  133. package/src/rules/html-attribute-double-quotes.ts +5 -4
  134. package/src/rules/html-attribute-values-require-quotes.ts +5 -4
  135. package/src/rules/html-boolean-attributes-no-value.ts +5 -4
  136. package/src/rules/html-img-require-alt.ts +5 -4
  137. package/src/rules/html-no-block-inside-inline.ts +5 -4
  138. package/src/rules/html-no-duplicate-attributes.ts +5 -4
  139. package/src/rules/html-no-duplicate-ids.ts +5 -5
  140. package/src/rules/html-no-empty-headings.ts +5 -4
  141. package/src/rules/html-no-nested-links.ts +5 -4
  142. package/src/rules/html-tag-name-lowercase.ts +5 -4
  143. package/src/rules/index.ts +3 -0
  144. package/src/rules/rule-utils.ts +156 -4
  145. package/src/rules/svg-tag-name-capitalization.ts +5 -4
  146. package/src/types.ts +60 -6
package/README.md CHANGED
@@ -22,11 +22,25 @@ The linter is automatically integrated into the [Herb Language Server](https://h
22
22
  By default, all rules are enabled. You can customize the rules by passing a custom set to the Linter constructor:
23
23
 
24
24
  ```typescript
25
+ import { Herb } from "@herb-tools/node-wasm"
25
26
  import { Linter, HTMLTagNameLowercaseRule } from "@herb-tools/linter"
26
27
 
28
+ await Herb.load()
29
+
27
30
  // Only run specific rules
28
- const linter = new Linter([HTMLTagNameLowercaseRule])
31
+ const linter = new Linter(Herb, [HTMLTagNameLowercaseRule])
29
32
 
30
33
  // Run with no rules (disabled)
31
- const linter = new Linter([])
34
+ const linter = new Linter(Herb, [])
35
+
36
+ // Lint source code
37
+ const result = linter.lint(sourceCode)
32
38
  ```
39
+
40
+ The Linter supports three types of rules:
41
+
42
+ - **Parser/AST Rules**: Semantic validation using the parsed document tree
43
+ - **Lexer Rules**: Token-based validation using the lexer output
44
+ - **Source Rules**: Raw text validation using the original source code
45
+
46
+ Each rule type uses its own visitor pattern for clean, extensible implementations.