@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.
- package/README.md +54 -2
- package/dist/herb-lint.js +17157 -31275
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +473 -2113
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +468 -2115
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +6868 -11350
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +6862 -11351
- package/dist/loader.js.map +1 -1
- package/dist/package.json +9 -8
- package/dist/src/cli/argument-parser.js +18 -2
- package/dist/src/cli/argument-parser.js.map +1 -1
- package/dist/src/cli/file-processor.js +1 -1
- package/dist/src/cli/file-processor.js.map +1 -1
- package/dist/src/cli.js +25 -10
- package/dist/src/cli.js.map +1 -1
- package/dist/src/custom-rule-loader.js +2 -2
- package/dist/src/custom-rule-loader.js.map +1 -1
- package/dist/src/linter.js +16 -3
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/erb-strict-locals-comment-syntax.js +206 -0
- package/dist/src/rules/erb-strict-locals-comment-syntax.js.map +1 -0
- package/dist/src/rules/erb-strict-locals-required.js +38 -0
- package/dist/src/rules/erb-strict-locals-required.js.map +1 -0
- package/dist/src/rules/file-utils.js +21 -0
- package/dist/src/rules/file-utils.js.map +1 -0
- package/dist/src/rules/html-head-only-elements.js +2 -0
- package/dist/src/rules/html-head-only-elements.js.map +1 -1
- package/dist/src/rules/html-no-duplicate-attributes.js +91 -21
- package/dist/src/rules/html-no-duplicate-attributes.js.map +1 -1
- package/dist/src/rules/html-no-empty-headings.js +22 -36
- package/dist/src/rules/html-no-empty-headings.js.map +1 -1
- package/dist/src/rules/index.js +4 -0
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/string-utils.js +72 -0
- package/dist/src/rules/string-utils.js.map +1 -0
- package/dist/src/rules.js +4 -0
- package/dist/src/rules.js.map +1 -1
- package/dist/src/types.js +6 -0
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/cli/argument-parser.d.ts +3 -0
- package/dist/types/cli/file-processor.d.ts +1 -0
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/linter.d.ts +5 -1
- package/dist/types/rules/erb-strict-locals-comment-syntax.d.ts +9 -0
- package/dist/types/rules/erb-strict-locals-required.d.ts +9 -0
- package/dist/types/rules/file-utils.d.ts +13 -0
- package/dist/types/rules/index.d.ts +4 -0
- package/dist/types/rules/string-utils.d.ts +15 -0
- package/dist/types/src/cli/argument-parser.d.ts +3 -0
- package/dist/types/src/cli/file-processor.d.ts +1 -0
- package/dist/types/src/cli.d.ts +1 -1
- package/dist/types/src/linter.d.ts +5 -1
- package/dist/types/src/rules/erb-strict-locals-comment-syntax.d.ts +9 -0
- package/dist/types/src/rules/erb-strict-locals-required.d.ts +9 -0
- package/dist/types/src/rules/file-utils.d.ts +13 -0
- package/dist/types/src/rules/index.d.ts +4 -0
- package/dist/types/src/rules/string-utils.d.ts +15 -0
- package/dist/types/src/types.d.ts +6 -0
- package/dist/types/types.d.ts +6 -0
- package/docs/rules/README.md +1 -0
- package/docs/rules/erb-strict-locals-comment-syntax.md +153 -0
- package/docs/rules/erb-strict-locals-required.md +107 -0
- package/package.json +9 -8
- package/src/cli/argument-parser.ts +21 -2
- package/src/cli/file-processor.ts +2 -1
- package/src/cli.ts +34 -11
- package/src/custom-rule-loader.ts +2 -2
- package/src/linter.ts +19 -3
- package/src/rules/erb-strict-locals-comment-syntax.ts +274 -0
- package/src/rules/erb-strict-locals-required.ts +52 -0
- package/src/rules/file-utils.ts +23 -0
- package/src/rules/html-head-only-elements.ts +1 -0
- package/src/rules/html-no-duplicate-attributes.ts +141 -26
- package/src/rules/html-no-empty-headings.ts +21 -44
- package/src/rules/index.ts +4 -0
- package/src/rules/string-utils.ts +72 -0
- package/src/rules.ts +4 -0
- 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.
|
|
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.
|
|
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'
|