diff --git a/README.md b/README.md index 2679eca..486d788 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ linters: enabled: true GitHub::Accessibility::NoRedundantImageAlt: enabled: true + GitHub::Accessibility::NoTitleAttributeCounter: + enabled: true ``` ## Rules @@ -45,6 +47,7 @@ linters: - [GitHub::Accessibility::NoAriaLabelMisuse](./docs/rules/accessibility/no-aria-label-misuse.md) - [GitHub::Accessibility::NoPositiveTabIndex](./docs/rules/accessibility/no-positive-tab-index.md) - [GitHub::Accessibility::NoRedundantImageAlt](./docs/rules/accessibility/no-redundant-image-alt.md) +- [GitHub::Accessibility::NoTitleAttributeCounter](./docs/rules/accessibility/no-title-attribute-counter.md) ## Testing diff --git a/docs/rules/accessibility/no-title-attribute-counter.md b/docs/rules/accessibility/no-title-attribute-counter.md new file mode 100644 index 0000000..0da86fd --- /dev/null +++ b/docs/rules/accessibility/no-title-attribute-counter.md @@ -0,0 +1,39 @@ +# No title attribute counter + +## Rule Details + +The `title` attribute is strongly discouraged. The only exception is on an `" + @linter.run(processed_source) + + assert_empty @linter.offenses + end + + def test_does_not_autocorrect_when_ignores_are_correct + @file = <<~ERB + <%# erblint:counter GitHub::Accessibility::NoTitleAttributeCounter 1 %> + some website + ERB + + assert_equal @file, corrected_content + end + + def test_does_autocorrect_when_ignores_are_not_correct + @file = <<~ERB + <%# erblint:counter GitHub::Accessibility::NoTitleAttributeCounter 3 %> + some website + ERB + refute_equal @file, corrected_content + + expected_content = <<~ERB + <%# erblint:counter GitHub::Accessibility::NoTitleAttributeCounter 1 %> + some website + ERB + assert_equal expected_content, corrected_content + end +end