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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c543a94f664746bb807384be228f6e83fcd7046f399f9c478e2c355cf26fa3c8
4
- data.tar.gz: c37a04f979ad17e79e35b8b6fa9d615cbedebcb1fce9188eb24335e046fa4400
3
+ metadata.gz: '041558922708cbcbc98072a22a57ee9c01292eabefc08d7c8ad2e289b89f159c'
4
+ data.tar.gz: b6de899716228d66c4a56a33e26e6dc2e55aa216e6a261ae82cef3f7c010b5a0
5
5
  SHA512:
6
- metadata.gz: 3bb877b34c79e5e3dd5c969b21bb1e756acc8968ae245e7cd1274dc880529647ca83283a0d3ea7576d446df94d37a7565b45082f4a75008e826f1bcc9245f16d
7
- data.tar.gz: bb23c43c6274d45fd5e9ea5cb9f73947357127fe9aa08c225438d436910357b32ca367fbe843827a3bddf4600159b4945c1bdd248805547a47a42657dd9e9cd2
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
- return unless link_with_empty_text_and_no_accessible_name?(node)
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 with empty text content requires an aria-label (WCAG 4.1.2)"
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 link_with_empty_text_and_no_accessible_name?(node)
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 false unless sexp
27
-
28
- call = extract_link_call(sexp)
29
- return false unless call
31
+ return unless sexp
30
32
 
31
- first_arg_empty_string?(call) && !aria_label_within?(call)
33
+ extract_link_call(sexp)
32
34
  end
33
35
 
34
36
  def extract_link_call(sexp)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module A11y
4
4
  module Lint
5
- VERSION = "0.5.1"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a11y-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdullah Hashim