erblint-github 0.0.3 → 0.0.4

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: 46d00ab6d8c5bc82e5ea9e42c316037af0509e6f16a107cfd7762c21bac5c762
4
- data.tar.gz: 87f2785cf56cd632f122eb9ddb2e369298902737e281ca75de514fffa45de514
3
+ metadata.gz: b0131492978be048178906ad4c49f6b1a4106423fcbe025a0305198f7529099d
4
+ data.tar.gz: 2313987a98f5c675f567be062a916e0d6e063bc1eaa0996f7ebc7c926afba399
5
5
  SHA512:
6
- metadata.gz: efd49409b7c581f29c45bcc884279bfcff48baefa63ec7e53e028980589b33a87fa655e20a39bb919167cb078e27a6e07ab3c7f4323eec7b02f6d258e1a7f489
7
- data.tar.gz: 24a5f6882e6795950545a47fb87c6e8950fc588976ffaa2c7135f9b363a642743f45ebc2e37ff9748360292249b5e36003c89dc8ec3adc6c77499ea12bc9336e
6
+ metadata.gz: 720cc4ead1c378475a94db0680c282d344902884014fea5696653ad29939931cd5e240d11abe9c2719d4d8b6291f133f0c6b98b957616c081624166072472e8c
7
+ data.tar.gz: 63d7a414967f00ceae11b1ef7c10c86b308089a58736b087dff511e47a0dd83492adda87ae9ee6505691a428b90ba01e903fcb20bd35a20c12d8af1f30823c48
data/README.md CHANGED
@@ -25,10 +25,14 @@ require "erblint-github/linters"
25
25
  linters:
26
26
  GitHub::Accessibility::AvoidBothDisabledAndAriaDisabled:
27
27
  enabled: true
28
+ GitHub::Accessibility::IframeHasTitle:
29
+ enabled: true
28
30
  GitHub::Accessibility::ImageHasAlt:
29
31
  enabled: true
30
32
  GitHub::Accessibility::NoAriaLabelMisuse:
31
33
  enabled: true
34
+ GitHub::Accessibility::NoPositiveTabIndex:
35
+ enabled: true
32
36
  GitHub::Accessibility::NoRedundantImageAlt:
33
37
  enabled: true
34
38
  ```
@@ -36,8 +40,10 @@ linters:
36
40
  ## Rules
37
41
 
38
42
  - [GitHub::Accessibility::AvoidBothDisabledAndAriaDisabled](./docs/rules/accessibility/avoid-both-disabled-and-aria-disabled.md)
43
+ - [GitHub::Accessibility::IframeHasTitle](./docs/rules/accessibility/iframe-has-title.md)
39
44
  - [GitHub::Accessibility::ImageHasAlt](./docs/rules/accessibility/image-has-alt.md)
40
45
  - [GitHub::Accessibility::NoAriaLabelMisuse](./docs/rules/accessibility/no-aria-label-misuse.md)
46
+ - [GitHub::Accessibility::NoPositiveTabIndex](./docs/rules/accessibility/no-positive-tab-index.md)
41
47
  - [GitHub::Accessibility::NoRedundantImageAlt](./docs/rules/accessibility/no-redundant-image-alt.md)
42
48
 
43
49
  ## Testing
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../custom_helpers"
4
+
5
+ module ERBLint
6
+ module Linters
7
+ module GitHub
8
+ module Accessibility
9
+ class IframeHasTitle < Linter
10
+ include ERBLint::Linters::CustomHelpers
11
+ include LinterRegistry
12
+
13
+ MESSAGE = "<iframe> with meaningful content should have a title attribute that identifies the content."\
14
+ " If <iframe> has no meaningful content, hide it from assistive technology with `aria-hidden='true'`."\
15
+
16
+ def run(processed_source)
17
+ tags(processed_source).each do |tag|
18
+ next if tag.name != "iframe"
19
+ next if tag.closing?
20
+
21
+ title = possible_attribute_values(tag, "title")
22
+
23
+ generate_offense(self.class, processed_source, tag) if title.empty? && !aria_hidden?(tag)
24
+ end
25
+
26
+ rule_disabled?(processed_source)
27
+ end
28
+
29
+ private
30
+
31
+ def aria_hidden?(tag)
32
+ tag.attributes["aria-hidden"]&.value&.present?
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../custom_helpers"
4
+
5
+ module ERBLint
6
+ module Linters
7
+ module GitHub
8
+ module Accessibility
9
+ class NoPositiveTabIndex < Linter
10
+ include ERBLint::Linters::CustomHelpers
11
+ include LinterRegistry
12
+
13
+ MESSAGE = "Do not use positive tabindex as it is error prone and can severely disrupt navigation experience for keyboard users"
14
+
15
+ def run(processed_source)
16
+ tags(processed_source).each do |tag|
17
+ next if tag.closing?
18
+ next unless tag.attributes["tabindex"]&.value.to_i.positive?
19
+
20
+ generate_offense(self.class, processed_source, tag)
21
+ end
22
+
23
+ rule_disabled?(processed_source)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erblint-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-29 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb_lint
@@ -106,8 +106,10 @@ files:
106
106
  - lib/erblint-github/linters.rb
107
107
  - lib/erblint-github/linters/custom_helpers.rb
108
108
  - lib/erblint-github/linters/github/accessibility/avoid_both_disabled_and_aria_disabled.rb
109
+ - lib/erblint-github/linters/github/accessibility/iframe_has_title.rb
109
110
  - lib/erblint-github/linters/github/accessibility/image_has_alt.rb
110
111
  - lib/erblint-github/linters/github/accessibility/no_aria_label_misuse.rb
112
+ - lib/erblint-github/linters/github/accessibility/no_positive_tab_index.rb
111
113
  - lib/erblint-github/linters/github/accessibility/no_redundant_image_alt.rb
112
114
  - lib/tasks/docs.rake
113
115
  homepage: https://github.com/github/erblint-github