Skip to content

Commit 5da76fc

Browse files
committed
Linter: group a11y-related rules
1 parent ee6b125 commit 5da76fc

File tree

69 files changed

+317
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+317
-312
lines changed

docs/docs/blog/whats-new-in-herb-v0-8.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ This release brings a total of 14 new linter rules to help you write better HTML
250250
- [`html-head-only-elements`](/linter/rules/html-head-only-elements.md) <br/>
251251
Require head-scoped elements inside `<head>`.
252252

253-
- [`html-input-require-autocomplete`](/linter/rules/html-input-require-autocomplete.md) <br/>
253+
- [`html-input-require-autocomplete`](/linter/rules/a11y-input-require-autocomplete.md) <br/>
254254
Require `autocomplete` attributes on `<input>` tags.
255255

256256
- [`html-no-duplicate-meta-names`](/linter/rules/html-no-duplicate-meta-names.md) <br/>

docs/docs/blog/whats-new-in-herb-v0-9.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ This release also introduces two new rule categories: **`erb-safety-*`** rules e
441441

442442
- [`html-allowed-script-type`](/linter/rules/html-allowed-script-type.md)<br/>Restrict allowed `type` attributes on `<script>` tags
443443
- [`html-details-has-summary`](/linter/rules/html-details-has-summary.md)<br/>Require `<summary>` inside `<details>` elements
444-
- [`html-no-abstract-roles`](/linter/rules/html-no-abstract-roles.md)<br/>Disallow abstract ARIA roles
445-
- [`html-no-aria-hidden-on-body`](/linter/rules/html-no-aria-hidden-on-body.md)<br/>Disallow `aria-hidden` on `<body>`
444+
- [`html-no-abstract-roles`](/linter/rules/a11y-no-abstract-roles.md)<br/>Disallow abstract ARIA roles
445+
- [`html-no-aria-hidden-on-body`](/linter/rules/a11y-no-aria-hidden-on-body.md)<br/>Disallow `aria-hidden` on `<body>`
446446
- [`html-require-closing-tags`](/linter/rules/html-require-closing-tags.md)<br/>Require explicit closing tags
447447

448448
##### Turbo Rules

docs/docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ linter:
104104
severity: warning # Options: error, warning, info, hint
105105

106106
# Rule with file pattern restrictions
107-
html-img-require-alt:
107+
a11y-img-require-alt:
108108
# Only apply this rule to files matching these patterns
109109
only:
110110
- 'app/views/**/*'

javascript/packages/config/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ export class Config {
633633
* await Config.mutateConfigFile('/path/to/.herb.yml', {
634634
* linter: {
635635
* rules: {
636-
* 'html-img-require-alt': { enabled: false }
636+
* 'a11y-img-require-alt': { enabled: false }
637637
* }
638638
* }
639639
* })

javascript/packages/config/test/config.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe("@herb-tools/config", () => {
217217
version: 0.9.2
218218
linter:
219219
rules:
220-
html-img-require-alt:
220+
a11y-img-require-alt:
221221
enabled: false
222222
`
223223

@@ -231,7 +231,7 @@ describe("@herb-tools/config", () => {
231231

232232
const updatedYaml = Config.applyMutationToYamlString(existingYaml, mutation)
233233

234-
expect(updatedYaml).toContain("html-img-require-alt:")
234+
expect(updatedYaml).toContain("a11y-img-require-alt:")
235235
expect(updatedYaml).toContain("html-tag-name-lowercase:")
236236
})
237237

javascript/packages/formatter/test/herb-disable-comment-formatting.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe("herb:disable comment formatting", () => {
306306

307307
test("keeps herb:disable comment on same line as tag name in multiline opening tag", () => {
308308
expectFormattedToMatch(dedent`
309-
<a <%# herb:disable html-anchor-require-href %>
309+
<a <%# herb:disable a11y-anchor-require-href %>
310310
class="btn btn-secondary no-donate-btn"
311311
aria-label="Close"
312312
data-dismiss="modal"

javascript/packages/linter/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ npx @herb-tools/linter --format=simple --github
267267

268268
**Example: `--github` (GitHub annotations + detailed format)**
269269
```
270-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.9.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
270+
::error file=template.html.erb,line=3,col=3,title=a11y-img-require-alt • @herb-tools/linter@0.9.2::Missing required `alt` attribute on `<img>` tag [a11y-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
271271
272-
[error] Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
272+
[error] Missing required `alt` attribute on `<img>` tag [a11y-img-require-alt]
273273
274274
template.html.erb:3:3
275275
@@ -282,10 +282,10 @@ template.html.erb:3:3
282282

283283
**Example: `--format=simple --github` (GitHub annotations + simple format)**
284284
```
285-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.9.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
285+
::error file=template.html.erb,line=3,col=3,title=a11y-img-require-alt • @herb-tools/linter@0.9.2::Missing required `alt` attribute on `<img>` tag [a11y-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
286286
287287
template.html.erb:
288-
3:3 ✗ Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
288+
3:3 ✗ Missing required `alt` attribute on `<img>` tag [a11y-img-require-alt]
289289
```
290290

291291
The GitHub Actions annotations include:
@@ -472,7 +472,7 @@ Apply rules to specific files using `include`, `only`, and `exclude` patterns:
472472
linter:
473473
rules:
474474
# Apply rule only to component files
475-
html-img-require-alt:
475+
a11y-img-require-alt:
476476
include:
477477
- 'app/components/**/*'
478478
exclude:

javascript/packages/linter/docs/rules/README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ This page contains documentation for all Herb Linter rules.
44

55
## Available Rules
66

7+
- [`a11y-anchor-require-href`](./a11y-anchor-require-href.md) - Requires an href attribute on anchor tags
8+
- [`a11y-aria-attribute-must-be-valid`](./a11y-aria-attribute-must-be-valid.md) - Disallow invalid or unknown `aria-*` attributes.
9+
- [`a11y-aria-label-is-well-formatted`](./a11y-aria-label-is-well-formatted.md) - `aria-label` must be well-formatted
10+
- [`a11y-aria-level-must-be-valid`](./a11y-aria-level-must-be-valid.md) - `aria-level` must be between 1 and 6
11+
- [`a11y-aria-role-heading-requires-level`](./a11y-aria-role-heading-requires-level.md) - Requires `aria-level` when supplying a `role`
12+
- [`a11y-aria-role-must-be-valid`](./a11y-aria-role-must-be-valid.md) - The `role` attribute must have a valid WAI-ARIA Role.
13+
- [`a11y-avoid-both-disabled-and-aria-disabled`](./a11y-avoid-both-disabled-and-aria-disabled.md) - Avoid using both `disabled` and `aria-disabled` attributes
14+
- [`a11y-iframe-has-title`](./a11y-iframe-has-title.md) - `iframe` elements must have a `title` attribute
15+
- [`a11y-img-require-alt`](./a11y-img-require-alt.md) - Requires `alt` attributes on `<img>` tags
16+
- [`a11y-input-require-autocomplete`](./a11y-input-require-autocomplete.md) - Require `autocomplete` attributes on `<input>` tags.
17+
- [`a11y-navigation-has-label`](./a11y-navigation-has-label.md) - Navigation landmarks must have accessible labels
18+
- [`a11y-no-abstract-roles`](./a11y-no-abstract-roles.md) - No abstract ARIA roles
19+
- [`a11y-no-aria-hidden-on-body`](./a11y-no-aria-hidden-on-body.md) - No `aria-hidden` on `<body>`
20+
- [`a11y-no-aria-hidden-on-focusable`](./a11y-no-aria-hidden-on-focusable.md) - Focusable elements should not have `aria-hidden="true"`
21+
- [`a11y-no-empty-headings`](./a11y-no-empty-headings.md) - Headings must not be empty
22+
- [`a11y-no-nested-links`](./a11y-no-nested-links.md) - Prevents nested anchor tags
23+
- [`a11y-no-positive-tab-index`](./a11y-no-positive-tab-index.md) - Avoid positive `tabindex` values
24+
- [`a11y-no-title-attribute`](./a11y-no-title-attribute.md) - Avoid using the `title` attribute
725
- [`actionview-no-silent-helper`](./actionview-no-silent-helper.md) - Disallow silent ERB tags for Action View helpers
826
- [`actionview-no-silent-render`](./actionview-no-silent-render.md) - Disallow calling `render` without outputting the result
927
- [`actionview-no-void-element-content`](./actionview-no-void-element-content.md) - Disallow content arguments for void Action View elements
@@ -43,38 +61,22 @@ This page contains documentation for all Herb Linter rules.
4361
- [`herb-disable-comment-unnecessary`](./herb-disable-comment-unnecessary.md) - Detect unnecessary `herb:disable` comments.
4462
- [`herb-disable-comment-valid-rule-name`](./herb-disable-comment-valid-rule-name.md) - Validate rule names in `herb:disable` comments.
4563
- [`html-allowed-script-type`](./html-allowed-script-type.md) - Restrict allowed `type` attributes for `<script>` tags
46-
- [`html-anchor-require-href`](./html-anchor-require-href.md) - Requires an href attribute on anchor tags
47-
- [`html-aria-attribute-must-be-valid`](./html-aria-attribute-must-be-valid.md) - Disallow invalid or unknown `aria-*` attributes.
48-
- [`html-aria-label-is-well-formatted`](./html-aria-label-is-well-formatted.md) - `aria-label` must be well-formatted
49-
- [`html-aria-level-must-be-valid`](./html-aria-level-must-be-valid.md) - `aria-level` must be between 1 and 6
50-
- [`html-aria-role-heading-requires-level`](./html-aria-role-heading-requires-level.md) - Requires `aria-level` when supplying a `role`
51-
- [`html-aria-role-must-be-valid`](./html-aria-role-must-be-valid.md) - The `role` attribute must have a valid WAI-ARIA Role.
5264
- [`html-attribute-double-quotes`](./html-attribute-double-quotes.md) - Enforces double quotes for attribute values
5365
- [`html-attribute-equals-spacing`](./html-attribute-equals-spacing.md) - No whitespace around `=` in HTML attributes
5466
- [`html-attribute-values-require-quotes`](./html-attribute-values-require-quotes.md) - Requires quotes around attribute values
55-
- [`html-avoid-both-disabled-and-aria-disabled`](./html-avoid-both-disabled-and-aria-disabled.md) - Avoid using both `disabled` and `aria-disabled` attributes
5667
- [`html-body-only-elements`](./html-body-only-elements.md) - Require content elements inside `<body>`.
5768
- [`html-boolean-attributes-no-value`](./html-boolean-attributes-no-value.md) - Prevents values on boolean attributes
5869
- [`html-details-has-summary`](./html-details-has-summary.md) - Require `<summary>` in `<details>` elements
5970
- [`html-head-only-elements`](./html-head-only-elements.md) - Require head-scoped elements inside `<head>`.
60-
- [`html-iframe-has-title`](./html-iframe-has-title.md) - `iframe` elements must have a `title` attribute
61-
- [`html-img-require-alt`](./html-img-require-alt.md) - Requires `alt` attributes on `<img>` tags
62-
- [`html-input-require-autocomplete`](./html-input-require-autocomplete.md) - Require `autocomplete` attributes on `<input>` tags.
63-
- [`html-navigation-has-label`](./html-navigation-has-label.md) - Navigation landmarks must have accessible labels
64-
- [`html-no-abstract-roles`](./html-no-abstract-roles.md) - No abstract ARIA roles
65-
- [`html-no-aria-hidden-on-body`](./html-no-aria-hidden-on-body.md) - No `aria-hidden` on `<body>`
66-
- [`html-no-aria-hidden-on-focusable`](./html-no-aria-hidden-on-focusable.md) - Focusable elements should not have `aria-hidden="true"`
6771
- [`html-no-block-inside-inline`](./html-no-block-inside-inline.md) - Prevents block-level elements inside inline elements
6872
- [`html-no-duplicate-attributes`](./html-no-duplicate-attributes.md) - Prevents duplicate attributes on HTML elements
6973
- [`html-no-duplicate-ids`](./html-no-duplicate-ids.md) - Prevents duplicate IDs within a document
7074
- [`html-no-duplicate-meta-names`](./html-no-duplicate-meta-names.md) - Duplicate `<meta>` name attributes are not allowed.
7175
- [`html-no-empty-attributes`](./html-no-empty-attributes.md) - Attributes must not have empty values
72-
- [`html-no-nested-links`](./html-no-nested-links.md) - Prevents nested anchor tags
73-
- [`html-no-positive-tab-index`](./html-no-positive-tab-index.md) - Avoid positive `tabindex` values
7476
- [`html-no-self-closing`](./html-no-self-closing.md) - Disallow self closing tags
7577
- [`html-no-space-in-tag`](./html-no-space-in-tag.md) - Disallow spaces in HTML tags
76-
- [`html-no-title-attribute`](./html-no-title-attribute.md) - Avoid using the `title` attribute
7778
- [`html-no-underscores-in-attribute-names`](./html-no-underscores-in-attribute-names.md) - Disallow underscores in HTML attribute names
79+
- [`html-require-closing-tags`](./html-require-closing-tags.md) - Require closing tags for non-void elements
7880
- [`html-require-script-nonce`](./html-require-script-nonce.md) - Require `nonce` attribute on script tags and helpers
7981
- [`html-tag-name-lowercase`](./html-tag-name-lowercase.md) - Enforces lowercase tag names in HTML
8082
- [`parser-no-errors`](./parser-no-errors.md) - Disallow parser errors in HTML+ERB documents

javascript/packages/linter/docs/rules/html-anchor-require-href.md renamed to javascript/packages/linter/docs/rules/a11y-anchor-require-href.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linter Rule: Require `href` attribute on `<a>` tags
22

3-
**Rule:** `html-anchor-require-href`
3+
**Rule:** `a11y-anchor-require-href`
44

55
## Description
66

javascript/packages/linter/docs/rules/html-aria-attribute-must-be-valid.md renamed to javascript/packages/linter/docs/rules/a11y-aria-attribute-must-be-valid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linter Rule: Disallow invalid or unknown `aria-*` attributes.
22

3-
**Rule:** `html-aria-attribute-must-be-valid`
3+
**Rule:** `a11y-aria-attribute-must-be-valid`
44

55
## Description
66

0 commit comments

Comments
 (0)