@herb-tools/linter 0.6.1 → 0.7.0
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 +60 -16
- package/dist/herb-lint.js +364 -181
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +321 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +270 -89
- package/dist/index.js.map +1 -1
- package/dist/package.json +11 -5
- package/dist/src/cli/argument-parser.js +11 -6
- package/dist/src/cli/argument-parser.js.map +1 -1
- package/dist/src/cli/file-processor.js +5 -6
- package/dist/src/cli/file-processor.js.map +1 -1
- package/dist/src/cli/formatters/detailed-formatter.js +3 -5
- package/dist/src/cli/formatters/detailed-formatter.js.map +1 -1
- package/dist/src/cli/formatters/github-actions-formatter.js +55 -11
- package/dist/src/cli/formatters/github-actions-formatter.js.map +1 -1
- package/dist/src/cli/index.js +1 -0
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/output-manager.js +23 -5
- package/dist/src/cli/output-manager.js.map +1 -1
- package/dist/src/cli/summary-reporter.js +2 -11
- package/dist/src/cli/summary-reporter.js.map +1 -1
- package/dist/src/cli.js +88 -4
- package/dist/src/cli.js.map +1 -1
- package/dist/src/default-rules.js +8 -4
- package/dist/src/default-rules.js.map +1 -1
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/erb-prefer-image-tag-helper.js +1 -1
- package/dist/src/rules/erb-prefer-image-tag-helper.js.map +1 -1
- package/dist/src/rules/html-boolean-attributes-no-value.js +8 -8
- package/dist/src/rules/html-boolean-attributes-no-value.js.map +1 -1
- package/dist/src/rules/html-no-empty-attributes.js +56 -0
- package/dist/src/rules/html-no-empty-attributes.js.map +1 -0
- package/dist/src/rules/html-no-positive-tab-index.js +1 -1
- package/dist/src/rules/html-no-positive-tab-index.js.map +1 -1
- package/dist/src/rules/html-no-underscores-in-attribute-names.js +36 -0
- package/dist/src/rules/html-no-underscores-in-attribute-names.js.map +1 -0
- package/dist/src/rules/index.js +3 -0
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/rule-utils.js +11 -7
- package/dist/src/rules/rule-utils.js.map +1 -1
- package/dist/src/rules/svg-tag-name-capitalization.js +2 -2
- package/dist/src/rules/svg-tag-name-capitalization.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/cli/argument-parser.d.ts +2 -1
- package/dist/types/cli/file-processor.d.ts +6 -1
- package/dist/types/cli/formatters/github-actions-formatter.d.ts +6 -1
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/output-manager.d.ts +1 -0
- package/dist/types/cli.d.ts +20 -5
- package/dist/types/linter.d.ts +7 -7
- package/dist/types/rules/html-no-empty-attributes.d.ts +7 -0
- package/dist/types/rules/html-no-underscores-in-attribute-names.d.ts +7 -0
- package/dist/types/rules/index.d.ts +3 -0
- package/dist/types/rules/rule-utils.d.ts +7 -5
- package/dist/types/src/cli/argument-parser.d.ts +2 -1
- package/dist/types/src/cli/file-processor.d.ts +6 -1
- package/dist/types/src/cli/formatters/github-actions-formatter.d.ts +6 -1
- package/dist/types/src/cli/index.d.ts +1 -0
- package/dist/types/src/cli/output-manager.d.ts +1 -0
- package/dist/types/src/cli.d.ts +20 -5
- package/dist/types/src/linter.d.ts +7 -7
- package/dist/types/src/rules/html-no-empty-attributes.d.ts +7 -0
- package/dist/types/src/rules/html-no-underscores-in-attribute-names.d.ts +7 -0
- package/dist/types/src/rules/index.d.ts +3 -0
- package/dist/types/src/rules/rule-utils.d.ts +7 -5
- package/docs/rules/README.md +2 -0
- package/docs/rules/html-img-require-alt.md +0 -2
- package/docs/rules/html-no-empty-attributes.md +77 -0
- package/docs/rules/html-no-underscores-in-attribute-names.md +45 -0
- package/package.json +11 -5
- package/src/cli/argument-parser.ts +15 -7
- package/src/cli/file-processor.ts +11 -7
- package/src/cli/formatters/detailed-formatter.ts +5 -7
- package/src/cli/formatters/github-actions-formatter.ts +64 -11
- package/src/cli/index.ts +2 -0
- package/src/cli/output-manager.ts +27 -5
- package/src/cli/summary-reporter.ts +3 -11
- package/src/cli.ts +125 -20
- package/src/default-rules.ts +8 -4
- package/src/linter.ts +6 -6
- package/src/rules/erb-no-silent-tag-in-attribute-name.ts +1 -1
- package/src/rules/erb-prefer-image-tag-helper.ts +2 -2
- package/src/rules/erb-require-whitespace-inside-tags.ts +2 -2
- package/src/rules/html-attribute-double-quotes.ts +1 -1
- package/src/rules/html-boolean-attributes-no-value.ts +9 -11
- package/src/rules/html-no-empty-attributes.ts +75 -0
- package/src/rules/html-no-positive-tab-index.ts +1 -1
- package/src/rules/html-no-underscores-in-attribute-names.ts +58 -0
- package/src/rules/html-tag-name-lowercase.ts +1 -1
- package/src/rules/index.ts +3 -0
- package/src/rules/rule-utils.ts +15 -11
- package/src/rules/svg-tag-name-capitalization.ts +2 -2
package/README.md
CHANGED
|
@@ -122,10 +122,15 @@ npx @herb-tools/linter template.html.erb --json
|
|
|
122
122
|
# or
|
|
123
123
|
npx @herb-tools/linter template.html.erb --format json
|
|
124
124
|
|
|
125
|
-
# Use GitHub Actions output format
|
|
125
|
+
# Use GitHub Actions output format with detailed preview (default)
|
|
126
|
+
# (This is enabled automatically when the GITHUB_ACTIONS environment variable is set)
|
|
126
127
|
npx @herb-tools/linter template.html.erb --github
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
|
|
129
|
+
# Combine GitHub Actions output with simple format
|
|
130
|
+
npx @herb-tools/linter template.html.erb --format=simple --github
|
|
131
|
+
|
|
132
|
+
# Combine GitHub Actions output with detailed format (explicit)
|
|
133
|
+
npx @herb-tools/linter template.html.erb --format=detailed --github
|
|
129
134
|
```
|
|
130
135
|
|
|
131
136
|
**Display Options:**
|
|
@@ -144,6 +149,12 @@ npx @herb-tools/linter template.html.erb --no-wrap-lines
|
|
|
144
149
|
|
|
145
150
|
# Enable line truncation (mutually exclusive with line wrapping)
|
|
146
151
|
npx @herb-tools/linter template.html.erb --truncate-lines --no-wrap-lines
|
|
152
|
+
|
|
153
|
+
# Combine GitHub Actions annotations with different formats
|
|
154
|
+
npx @herb-tools/linter template.html.erb --format=simple --github
|
|
155
|
+
|
|
156
|
+
# Disable GitHub Actions annotations (even in GitHub Actions environment)
|
|
157
|
+
npx @herb-tools/linter template.html.erb --no-github
|
|
147
158
|
```
|
|
148
159
|
|
|
149
160
|
**Help and Version:**
|
|
@@ -157,21 +168,53 @@ npx @herb-tools/linter --version
|
|
|
157
168
|
|
|
158
169
|
#### GitHub Actions Output Format
|
|
159
170
|
|
|
160
|
-
The linter supports GitHub Actions annotation format with the `--github` flag, which
|
|
171
|
+
The linter supports GitHub Actions annotation format with the `--github` flag, which can be combined with `--format=simple` or `--format=detailed`. The `--github` flag adds GitHub Actions annotations that GitHub can parse to create inline annotations in pull requests, while also showing the regular format output for local debugging.
|
|
172
|
+
|
|
173
|
+
::: tip Tip: Running in GitHub Actions
|
|
174
|
+
When the `GITHUB_ACTIONS` environment variable is set (as in GitHub Actions), GitHub Actions annotations are enabled by default. You can disable them with `--no-github` if needed.
|
|
175
|
+
:::
|
|
161
176
|
|
|
162
177
|
```bash
|
|
163
|
-
|
|
178
|
+
# GitHub Actions annotations + detailed format (default)
|
|
179
|
+
npx @herb-tools/linter --github
|
|
180
|
+
|
|
181
|
+
# GitHub Actions annotations + simple format (minimal local output)
|
|
182
|
+
npx @herb-tools/linter --format=simple --github
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example: `--github` (GitHub annotations + detailed format)**
|
|
164
186
|
```
|
|
187
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.7.0::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
|
|
188
|
+
|
|
189
|
+
[error] Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
190
|
+
|
|
191
|
+
template.html.erb:3:3
|
|
165
192
|
|
|
166
|
-
|
|
193
|
+
1 │ <div>
|
|
194
|
+
2 │ <span>Test content</span>
|
|
195
|
+
→ 3 │ <img src="test.jpg">
|
|
196
|
+
│ ~~~
|
|
197
|
+
4 │ </div>
|
|
167
198
|
```
|
|
168
|
-
|
|
169
|
-
|
|
199
|
+
|
|
200
|
+
**Example: `--format=simple --github` (GitHub annotations + simple format)**
|
|
170
201
|
```
|
|
202
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.7.0::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
|
|
171
203
|
|
|
172
|
-
|
|
204
|
+
template.html.erb:
|
|
205
|
+
3:3 ✗ Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
206
|
+
```
|
|
173
207
|
|
|
174
|
-
|
|
208
|
+
The GitHub Actions annotations include:
|
|
209
|
+
- **Embedded plain-text code previews** (with `%0A` for newlines) that GitHub renders in PR comments
|
|
210
|
+
- **`title` property** showing the rule code and linter version for better traceability
|
|
211
|
+
- **Full error context** for debugging directly in GitHub's UI
|
|
212
|
+
|
|
213
|
+
The regular format output provides colorful syntax highlighting for local terminal debugging.
|
|
214
|
+
|
|
215
|
+
This approach is ideal for CI/CD workflows as it provides both GitHub integration and local debugging:
|
|
216
|
+
|
|
217
|
+
```yaml [.github/workflows/herb.yml]
|
|
175
218
|
name: Herb Lint
|
|
176
219
|
on: [push, pull_request]
|
|
177
220
|
|
|
@@ -180,8 +223,9 @@ jobs:
|
|
|
180
223
|
runs-on: ubuntu-latest
|
|
181
224
|
steps:
|
|
182
225
|
- uses: actions/checkout@v4
|
|
183
|
-
|
|
184
|
-
-
|
|
226
|
+
|
|
227
|
+
- name: Run Herb Linter
|
|
228
|
+
run: npx @herb-tools/linter
|
|
185
229
|
```
|
|
186
230
|
|
|
187
231
|
#### JSON Output Format
|
|
@@ -232,11 +276,11 @@ npx @herb-tools/linter template.html.erb --json
|
|
|
232
276
|
|
|
233
277
|
JSON output fields:
|
|
234
278
|
- `offenses`: Array of linting offenses with location and severity
|
|
235
|
-
- `summary`: Statistics about the linting run (null on errors)
|
|
236
|
-
- `timing`: Timing information with ISO timestamp (null with `--no-timing`)
|
|
279
|
+
- `summary`: Statistics about the linting run (`null` on errors)
|
|
280
|
+
- `timing`: Timing information with ISO timestamp (`null` with `--no-timing`)
|
|
237
281
|
- `completed`: Whether the linter ran successfully on files
|
|
238
|
-
- `clean`: Whether there were no offenses (null when `completed=false`)
|
|
239
|
-
- `message`: Error or informational message (null on success)
|
|
282
|
+
- `clean`: Whether there were no offenses (`null` when `completed=false`)
|
|
283
|
+
- `message`: Error or informational message (`null` on success)
|
|
240
284
|
|
|
241
285
|
### Language Server Integration
|
|
242
286
|
|