@herb-tools/linter 0.8.6 → 0.8.8

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 (82) hide show
  1. package/README.md +54 -2
  2. package/dist/herb-lint.js +17157 -31275
  3. package/dist/herb-lint.js.map +1 -1
  4. package/dist/index.cjs +473 -2113
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.js +468 -2115
  7. package/dist/index.js.map +1 -1
  8. package/dist/loader.cjs +6868 -11350
  9. package/dist/loader.cjs.map +1 -1
  10. package/dist/loader.js +6862 -11351
  11. package/dist/loader.js.map +1 -1
  12. package/dist/package.json +9 -8
  13. package/dist/src/cli/argument-parser.js +18 -2
  14. package/dist/src/cli/argument-parser.js.map +1 -1
  15. package/dist/src/cli/file-processor.js +1 -1
  16. package/dist/src/cli/file-processor.js.map +1 -1
  17. package/dist/src/cli.js +25 -10
  18. package/dist/src/cli.js.map +1 -1
  19. package/dist/src/custom-rule-loader.js +2 -2
  20. package/dist/src/custom-rule-loader.js.map +1 -1
  21. package/dist/src/linter.js +16 -3
  22. package/dist/src/linter.js.map +1 -1
  23. package/dist/src/rules/erb-strict-locals-comment-syntax.js +206 -0
  24. package/dist/src/rules/erb-strict-locals-comment-syntax.js.map +1 -0
  25. package/dist/src/rules/erb-strict-locals-required.js +38 -0
  26. package/dist/src/rules/erb-strict-locals-required.js.map +1 -0
  27. package/dist/src/rules/file-utils.js +21 -0
  28. package/dist/src/rules/file-utils.js.map +1 -0
  29. package/dist/src/rules/html-head-only-elements.js +2 -0
  30. package/dist/src/rules/html-head-only-elements.js.map +1 -1
  31. package/dist/src/rules/html-no-duplicate-attributes.js +91 -21
  32. package/dist/src/rules/html-no-duplicate-attributes.js.map +1 -1
  33. package/dist/src/rules/html-no-empty-headings.js +22 -36
  34. package/dist/src/rules/html-no-empty-headings.js.map +1 -1
  35. package/dist/src/rules/index.js +4 -0
  36. package/dist/src/rules/index.js.map +1 -1
  37. package/dist/src/rules/string-utils.js +72 -0
  38. package/dist/src/rules/string-utils.js.map +1 -0
  39. package/dist/src/rules.js +4 -0
  40. package/dist/src/rules.js.map +1 -1
  41. package/dist/src/types.js +6 -0
  42. package/dist/src/types.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/dist/types/cli/argument-parser.d.ts +3 -0
  45. package/dist/types/cli/file-processor.d.ts +1 -0
  46. package/dist/types/cli.d.ts +1 -1
  47. package/dist/types/linter.d.ts +5 -1
  48. package/dist/types/rules/erb-strict-locals-comment-syntax.d.ts +9 -0
  49. package/dist/types/rules/erb-strict-locals-required.d.ts +9 -0
  50. package/dist/types/rules/file-utils.d.ts +13 -0
  51. package/dist/types/rules/index.d.ts +4 -0
  52. package/dist/types/rules/string-utils.d.ts +15 -0
  53. package/dist/types/src/cli/argument-parser.d.ts +3 -0
  54. package/dist/types/src/cli/file-processor.d.ts +1 -0
  55. package/dist/types/src/cli.d.ts +1 -1
  56. package/dist/types/src/linter.d.ts +5 -1
  57. package/dist/types/src/rules/erb-strict-locals-comment-syntax.d.ts +9 -0
  58. package/dist/types/src/rules/erb-strict-locals-required.d.ts +9 -0
  59. package/dist/types/src/rules/file-utils.d.ts +13 -0
  60. package/dist/types/src/rules/index.d.ts +4 -0
  61. package/dist/types/src/rules/string-utils.d.ts +15 -0
  62. package/dist/types/src/types.d.ts +6 -0
  63. package/dist/types/types.d.ts +6 -0
  64. package/docs/rules/README.md +1 -0
  65. package/docs/rules/erb-strict-locals-comment-syntax.md +153 -0
  66. package/docs/rules/erb-strict-locals-required.md +107 -0
  67. package/package.json +9 -8
  68. package/src/cli/argument-parser.ts +21 -2
  69. package/src/cli/file-processor.ts +2 -1
  70. package/src/cli.ts +34 -11
  71. package/src/custom-rule-loader.ts +2 -2
  72. package/src/linter.ts +19 -3
  73. package/src/rules/erb-strict-locals-comment-syntax.ts +274 -0
  74. package/src/rules/erb-strict-locals-required.ts +52 -0
  75. package/src/rules/file-utils.ts +23 -0
  76. package/src/rules/html-head-only-elements.ts +1 -0
  77. package/src/rules/html-no-duplicate-attributes.ts +141 -26
  78. package/src/rules/html-no-empty-headings.ts +21 -44
  79. package/src/rules/index.ts +4 -0
  80. package/src/rules/string-utils.ts +72 -0
  81. package/src/rules.ts +4 -0
  82. package/src/types.ts +6 -0
package/README.md CHANGED
@@ -192,6 +192,54 @@ npx @herb-tools/linter template.html.erb --format=simple --github
192
192
  npx @herb-tools/linter template.html.erb --no-github
193
193
  ```
194
194
 
195
+ **Exit Behavior:** <Badge type="info" text="v0.8.7+" />
196
+ ```bash
197
+ # Exit with error code when warnings or higher are present
198
+ npx @herb-tools/linter template.html.erb --fail-level warning
199
+
200
+ # Exit with error code when info diagnostics or higher are present
201
+ npx @herb-tools/linter template.html.erb --fail-level info
202
+
203
+ # Exit with error code when any diagnostic (including hints) is present
204
+ npx @herb-tools/linter template.html.erb --fail-level hint
205
+ ```
206
+
207
+ By default, the linter exits with code `1` only when errors are present. The `--fail-level` option allows you to control this behavior for CI/CD pipelines where you want stricter enforcement. Valid values are: `error` (default), `warning`, `info`, `hint`.
208
+
209
+ This can also be configured in `.herb.yml`:
210
+ ```yaml [.herb.yml]
211
+ linter:
212
+ failLevel: warning
213
+ ```
214
+
215
+ The CLI flag takes precedence over the configuration file.
216
+
217
+ **Autofix:**
218
+
219
+ Automatically fix auto-correctable offenses:
220
+ ```bash
221
+ npx @herb-tools/linter --fix
222
+ ```
223
+
224
+ Also apply unsafe auto-fixes (implies `--fix`):
225
+ ```bash
226
+ npx @herb-tools/linter --fix-unsafely
227
+ ```
228
+
229
+ The `--fix` flag automatically corrects offenses that have safe, deterministic fixes (like formatting issues). The `--fix-unsafely` flag additionally applies fixes that may change code behavior or require manual review after application.
230
+
231
+ **Safe fixes** (`--fix`):
232
+ - Formatting corrections (whitespace, quotes, trailing newlines)
233
+ - Syntax normalization (tag casing, attribute formatting)
234
+
235
+ **Unsafe fixes** (`--fix-unsafely`):
236
+ - Changes that may alter runtime behavior
237
+ - Insertions that require manual completion (e.g., adding empty strict locals declarations)
238
+
239
+ ::: warning
240
+ Always review changes made by `--fix-unsafely` before committing. These fixes are intentionally separated because they may require additional manual adjustments.
241
+ :::
242
+
195
243
  **Help and Version:**
196
244
  ```bash
197
245
  # Show help
@@ -219,7 +267,7 @@ npx @herb-tools/linter --format=simple --github
219
267
 
220
268
  **Example: `--github` (GitHub annotations + detailed format)**
221
269
  ```
222
- ::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.6::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
270
+ ::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.8::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
223
271
 
224
272
  [error] Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
225
273
 
@@ -234,7 +282,7 @@ template.html.erb:3:3
234
282
 
235
283
  **Example: `--format=simple --github` (GitHub annotations + simple format)**
236
284
  ```
237
- ::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.6::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
285
+ ::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.8::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
238
286
 
239
287
  template.html.erb:
240
288
  3:3 ✗ Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
@@ -393,6 +441,10 @@ npx @herb-tools/linter --init
393
441
  linter:
394
442
  enabled: true
395
443
 
444
+ # # Exit with error code when diagnostics of this severity or higher are present
445
+ # # Valid values: error (default), warning, info, hint
446
+ # failLevel: warning
447
+
396
448
  # Additional glob patterns to include (additive to defaults)
397
449
  include:
398
450
  - '**/*.xml.erb'