@herb-tools/linter 0.8.0 → 0.8.2
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 +42 -2
- package/dist/herb-lint.js +88 -17
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +70 -8
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +70 -8
- package/dist/loader.js.map +1 -1
- package/dist/package.json +7 -7
- package/dist/src/herb-disable-comment-utils.js.map +1 -1
- package/dist/src/linter-ignore.js +42 -0
- package/dist/src/linter-ignore.js.map +1 -0
- package/dist/src/linter.js +12 -0
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/html-head-only-elements.js +6 -1
- package/dist/src/rules/html-head-only-elements.js.map +1 -1
- package/dist/src/rules/rule-utils.js +2 -0
- package/dist/src/rules/rule-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/linter-ignore.d.ts +12 -0
- package/dist/types/rules/rule-utils.d.ts +1 -1
- package/dist/types/src/linter-ignore.d.ts +12 -0
- package/dist/types/src/rules/rule-utils.d.ts +1 -1
- package/docs/rules/html-head-only-elements.md +24 -2
- package/package.json +7 -7
- package/src/herb-disable-comment-utils.ts +3 -0
- package/src/linter-ignore.ts +50 -0
- package/src/linter.ts +14 -0
- package/src/rules/html-head-only-elements.ts +6 -1
- package/src/rules/rule-utils.ts +3 -1
package/README.md
CHANGED
|
@@ -36,6 +36,16 @@ For occasional use without installing:
|
|
|
36
36
|
npx @herb-tools/linter template.html.erb
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
### Preview Releases
|
|
40
|
+
|
|
41
|
+
Want to try unreleased features? Use pkg.pr.new to run the linter from any commit or PR:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx https://pkg.pr.new/@herb-tools/linter@{commit} template.html.erb
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Replace `{commit}` with a commit SHA (e.g., `0d2eabe`) or branch name (e.g., `main`). Find available previews at [pkg.pr.new/~/marcoroth/herb](https://pkg.pr.new/~/marcoroth/herb).
|
|
48
|
+
|
|
39
49
|
### Project Installation
|
|
40
50
|
|
|
41
51
|
:::code-group
|
|
@@ -209,7 +219,7 @@ npx @herb-tools/linter --format=simple --github
|
|
|
209
219
|
|
|
210
220
|
**Example: `--github` (GitHub annotations + detailed format)**
|
|
211
221
|
```
|
|
212
|
-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.
|
|
222
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.2::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
|
|
213
223
|
|
|
214
224
|
[error] Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
215
225
|
|
|
@@ -224,7 +234,7 @@ template.html.erb:3:3
|
|
|
224
234
|
|
|
225
235
|
**Example: `--format=simple --github` (GitHub annotations + simple format)**
|
|
226
236
|
```
|
|
227
|
-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.
|
|
237
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.2::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
|
|
228
238
|
|
|
229
239
|
template.html.erb:
|
|
230
240
|
3:3 ✗ Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
@@ -339,6 +349,36 @@ To disable all linting rules for a specific line, use `all`:
|
|
|
339
349
|
Inline disable comments only affect the line they appear on. Each line that needs linting disabled must have its own disable comment.
|
|
340
350
|
:::
|
|
341
351
|
|
|
352
|
+
### Disabling Linting for Entire Files <Badge type="info" text="v0.8.2+" />
|
|
353
|
+
|
|
354
|
+
You can disable linting for an entire file by adding the `ignore` directive anywhere in your template:
|
|
355
|
+
|
|
356
|
+
```erb
|
|
357
|
+
<%# herb:linter ignore %>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Example:**
|
|
361
|
+
|
|
362
|
+
:::code-group
|
|
363
|
+
```erb [ignored.html.erb]
|
|
364
|
+
<%# herb:linter ignore %>
|
|
365
|
+
|
|
366
|
+
<DIV>
|
|
367
|
+
<SPAN>This entire file will not be linted</SPAN>
|
|
368
|
+
</DIV>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
```erb [regular.html.erb]
|
|
372
|
+
<DIV>
|
|
373
|
+
<SPAN>This entire file will be linted</SPAN>
|
|
374
|
+
</DIV>
|
|
375
|
+
```
|
|
376
|
+
:::
|
|
377
|
+
|
|
378
|
+
::: warning Important
|
|
379
|
+
The `<%# herb:linter ignore %>` directive must be an exact match. Extra text or spacing will prevent it from working.
|
|
380
|
+
:::
|
|
381
|
+
|
|
342
382
|
## Configuration
|
|
343
383
|
|
|
344
384
|
Create a `.herb.yml` file in your project root to configure the linter:
|