a11y-lint 0.5.1 → 0.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/a11y/lint/rules/link_missing_accessible_name.rb +14 -12
- data/lib/a11y/lint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '041558922708cbcbc98072a22a57ee9c01292eabefc08d7c8ad2e289b89f159c'
|
|
4
|
+
data.tar.gz: b6de899716228d66c4a56a33e26e6dc2e55aa216e6a261ae82cef3f7c010b5a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7792835cc5123bc0832ca308ab88e28e51662f6ea1fc597458a5fcd96145e7135d9ad01c486f6efe6436b8f7453f44c8ef4f086bf76d6de7b8fdba271c122d4
|
|
7
|
+
data.tar.gz: 2d22327769cc721c03056845c6f13e46ef35a62b265b67114d5dc85eb6f8c656b1bcc3cf3d5d4e7a52fcde4fb7a2de25972ce822006fda0d78f558ade625aa68
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-03-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `LinkMissingAccessibleName` rule: detect block-style `link_to` calls missing an `aria-label`
|
|
15
|
+
|
|
10
16
|
## [0.5.1] - 2026-03-31
|
|
11
17
|
|
|
12
18
|
### Fixed
|
|
@@ -6,29 +6,31 @@ module A11y
|
|
|
6
6
|
module Lint
|
|
7
7
|
module Rules
|
|
8
8
|
# Checks that link_to / external_link_to calls with empty text
|
|
9
|
-
# include an aria-label (WCAG 4.1.2).
|
|
9
|
+
# or block content include an aria-label (WCAG 4.1.2).
|
|
10
10
|
class LinkMissingAccessibleName < Rule
|
|
11
11
|
LINK_METHODS = %w[link_to external_link_to].freeze
|
|
12
12
|
|
|
13
13
|
def check(node)
|
|
14
|
-
|
|
14
|
+
code = node.ruby_code
|
|
15
|
+
return unless code
|
|
16
|
+
|
|
17
|
+
clean_code = code.sub(/\s+do\s*\z/, "")
|
|
18
|
+
is_block = clean_code != code
|
|
19
|
+
call = parse_link_call(clean_code)
|
|
20
|
+
return unless call
|
|
21
|
+
return if aria_label_within?(call)
|
|
22
|
+
return unless first_arg_empty_string?(call) || is_block
|
|
15
23
|
|
|
16
|
-
"link
|
|
24
|
+
"link missing an accessible name requires an aria-label (WCAG 4.1.2)"
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
private
|
|
20
28
|
|
|
21
|
-
def
|
|
22
|
-
code = node.ruby_code
|
|
23
|
-
return false unless code
|
|
24
|
-
|
|
29
|
+
def parse_link_call(code)
|
|
25
30
|
sexp = Ripper.sexp(code)
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
call = extract_link_call(sexp)
|
|
29
|
-
return false unless call
|
|
31
|
+
return unless sexp
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
extract_link_call(sexp)
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
def extract_link_call(sexp)
|
data/lib/a11y/lint/version.rb
CHANGED