From 3e9e4b50f30e6107a4cd41d09f2e41213c1eb048 Mon Sep 17 00:00:00 2001 From: Erin Doyle Date: Sat, 13 Oct 2018 09:45:13 -0400 Subject: [PATCH] Renamed a number of rules that were equivalent to existing rules in the eslint-plugin-jsx-a11y library for consistency between the two libs --- .../{valid-aria-role.md => aria-role.md} | 6 +++--- ...e-aria.md => aria-unsupported-elements.md} | 10 +++++----- docs/rules/hidden-uses-tabindex.md | 4 ++-- ...{redundant-alt.md => img-redundant-alt.md} | 6 +++--- ...index.md => interactive-supports-focus.md} | 14 +++++++------- .../{label-uses-for.md => label-has-for.md} | 6 +++--- ...nts.md => mouse-events-have-key-events.md} | 18 +++++++++--------- ...-onblur-not-onchange.md => no-onchange.md} | 19 +++++++++++-------- .../{valid-aria-role.js => aria-role.js} | 0 ...e-aria.js => aria-unsupported-elements.js} | 0 ...{redundant-alt.js => img-redundant-alt.js} | 0 src/rules/index.js | 14 +++++++------- ...index.js => interactive-supports-focus.js} | 0 .../{label-uses-for.js => label-has-for.js} | 0 ...nts.js => mouse-events-have-key-events.js} | 0 ...-onblur-not-onchange.js => no-onchange.js} | 0 16 files changed, 50 insertions(+), 47 deletions(-) rename docs/rules/{valid-aria-role.md => aria-role.md} (95%) rename docs/rules/{no-unsupported-elements-use-aria.md => aria-unsupported-elements.md} (79%) rename docs/rules/{redundant-alt.md => img-redundant-alt.md} (95%) rename docs/rules/{onclick-uses-tabindex.md => interactive-supports-focus.md} (68%) rename docs/rules/{label-uses-for.md => label-has-for.md} (93%) rename docs/rules/{mouse-events-map-to-key-events.md => mouse-events-have-key-events.md} (65%) rename docs/rules/{use-onblur-not-onchange.md => no-onchange.md} (61%) rename src/rules/{valid-aria-role.js => aria-role.js} (100%) rename src/rules/{no-unsupported-elements-use-aria.js => aria-unsupported-elements.js} (100%) rename src/rules/{redundant-alt.js => img-redundant-alt.js} (100%) rename src/rules/{onclick-uses-tabindex.js => interactive-supports-focus.js} (100%) rename src/rules/{label-uses-for.js => label-has-for.js} (100%) rename src/rules/{mouse-events-map-to-key-events.js => mouse-events-have-key-events.js} (100%) rename src/rules/{use-onblur-not-onchange.js => no-onchange.js} (100%) diff --git a/docs/rules/valid-aria-role.md b/docs/rules/aria-role.md similarity index 95% rename from docs/rules/valid-aria-role.md rename to docs/rules/aria-role.md index 1c638e8..8d38cac 100644 --- a/docs/rules/valid-aria-role.md +++ b/docs/rules/aria-role.md @@ -1,4 +1,4 @@ -# valid-aria-role +# aria-role The ARIA roles model requires that elements with a role attribute use a valid, non-abstract ARIA role. Each non-abstract ARIA role is mapped on to a known set @@ -16,7 +16,7 @@ on additional required attributes, on the ## Passes -```js +```jsx harmony // passes when there is a role and it is valid
@@ -26,7 +26,7 @@ on additional required attributes, on the ## Fails -```js +```jsx harmony // fails when there is an invalid `role`
``` diff --git a/docs/rules/no-unsupported-elements-use-aria.md b/docs/rules/aria-unsupported-elements.md similarity index 79% rename from docs/rules/no-unsupported-elements-use-aria.md rename to docs/rules/aria-unsupported-elements.md index 530a518..0fe85ad 100644 --- a/docs/rules/no-unsupported-elements-use-aria.md +++ b/docs/rules/aria-unsupported-elements.md @@ -1,4 +1,4 @@ -# no-unsupported-elements-use-aria +# aria-unsupported-elements Certain reserved DOM elements do not support ARIA roles, states and properties. @@ -14,8 +14,8 @@ This is often because they are not visible, for example `meta`, `html`, `script` ## Passes These elements are passed by this rule -```js -// no problem when the reserver element is not given an illegal prop +```jsx harmony +// no problem when the reserved element is not given an illegal prop // no problem when an illegal props is given to a non-reserved elemeent @@ -25,11 +25,11 @@ These elements are passed by this rule ## Fails These elements are *not* passed by this rule -```js +```jsx harmony // warns when the element should not be given any ARIA attributes ``` ## See also - - Google Audit defs [AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-defs#ax_aria_12) \ No newline at end of file + - Google Audit defs [AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-defs#ax_aria_12) diff --git a/docs/rules/hidden-uses-tabindex.md b/docs/rules/hidden-uses-tabindex.md index c410cc8..cdbb531 100644 --- a/docs/rules/hidden-uses-tabindex.md +++ b/docs/rules/hidden-uses-tabindex.md @@ -12,7 +12,7 @@ in a hidden tab stop for screen reader users. ## Passes -```js +```jsx harmony // passes when an interactive element is aria-hidden and has tabindex="-1" @@ -25,7 +25,7 @@ in a hidden tab stop for screen reader users. ## Fails -```js +```jsx harmony // fails when an interactive element is hidden but has no tabindex diff --git a/docs/rules/redundant-alt.md b/docs/rules/img-redundant-alt.md similarity index 95% rename from docs/rules/redundant-alt.md rename to docs/rules/img-redundant-alt.md index 7b0c575..2370da4 100644 --- a/docs/rules/redundant-alt.md +++ b/docs/rules/img-redundant-alt.md @@ -1,4 +1,4 @@ -# redundant-alt +# img-redundant-alt Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce `img` elements as an image. There is no need to use @@ -13,7 +13,7 @@ This rule takes the following options: ## Passes -```js +```jsx harmony // passes when the `alt` does not contain redundant words nice @@ -27,7 +27,7 @@ This rule takes the following options: ## Fails -```js +```jsx harmony // fails when is a redundant alt message bar image foo diff --git a/docs/rules/onclick-uses-tabindex.md b/docs/rules/interactive-supports-focus.md similarity index 68% rename from docs/rules/onclick-uses-tabindex.md rename to docs/rules/interactive-supports-focus.md index ca8d5b9..c32aedb 100644 --- a/docs/rules/onclick-uses-tabindex.md +++ b/docs/rules/interactive-supports-focus.md @@ -1,4 +1,4 @@ -# onclick-uses-tabindex +# interactive-supports-focus Enforce that elements that have an `onClick` handler also have a `tabIndex` property. If not, they will not be navigable by @@ -11,22 +11,22 @@ keyboard users. ## Passes -```js +```jsx harmony // passes when when there is an `onClick` with a `tabIndex` - + // passes when the element is hidden from aria - + // passes when the element is interactive - + ``` ## Fails -```js +```jsx harmony // fails when there is an `onClick` with no `tabIndex` - + ``` ## See also diff --git a/docs/rules/label-uses-for.md b/docs/rules/label-has-for.md similarity index 93% rename from docs/rules/label-uses-for.md rename to docs/rules/label-has-for.md index b43d59f..14455fc 100644 --- a/docs/rules/label-uses-for.md +++ b/docs/rules/label-has-for.md @@ -1,4 +1,4 @@ -# label-uses-for +# label-has-for Enforce label tags have `htmlFor` attribute. Form controls using a `label` to identify them must have only one label that is programmatically associated with @@ -11,7 +11,7 @@ the control using: ``. ## Passes -```js +```jsx harmony // passes when the label is hidden @@ -24,7 +24,7 @@ the control using: ``. ## Fails -```js +```jsx harmony // fails when a label is not hidden and has no `htmlFor` ``` diff --git a/docs/rules/mouse-events-map-to-key-events.md b/docs/rules/mouse-events-have-key-events.md similarity index 65% rename from docs/rules/mouse-events-map-to-key-events.md rename to docs/rules/mouse-events-have-key-events.md index e9c85b4..3de9850 100644 --- a/docs/rules/mouse-events-map-to-key-events.md +++ b/docs/rules/mouse-events-have-key-events.md @@ -1,4 +1,4 @@ -# mouse-events-map-to-key-events +# mouse-events-have-key-events Enforce `onMouseOver`/`onMouseOut` are accompanied by `onFocus`/`onBlur`. Coding for the keyboard is important for users with @@ -12,25 +12,25 @@ users. ## Passes -```js +```jsx harmony // passes when there is no `onMouseOver` or `onMouseOut`
-// passes when there is `onMouseOver` but and `onFocus` -
+// passes when there is `onMouseOver` and `onFocus` +
-// passes when there is `onMouseOut` but and `onBlur` -
+// passes when there is `onMouseOut` and `onBlur` +
``` ## Fails -```js +```jsx harmony // fails when there is `onMouseOver` but no `onFocus` -
+
// fails when there is `onMouseOut` but no `onBlur` -
+
``` ## See also diff --git a/docs/rules/use-onblur-not-onchange.md b/docs/rules/no-onchange.md similarity index 61% rename from docs/rules/use-onblur-not-onchange.md rename to docs/rules/no-onchange.md index 19d54b6..ef9471d 100644 --- a/docs/rules/use-onblur-not-onchange.md +++ b/docs/rules/no-onchange.md @@ -1,4 +1,4 @@ -# use-onblur-not-onchange +# no-onchange Enforce usage of onBlur over onChange for accessibility. onBlur must be used instead of onChange, unless absolutely necessary and it causes no negative @@ -11,25 +11,28 @@ consequences for keyboard only or screen reader users. ## Passes -```js +```jsx harmony // passes when there is no `onChange` prop // passes when the element is aria-hidden - + // passes when the element is aria-disabled - + // passes when the element is aria-readonly - + + +// passes when there is an `onChange` prop and an `onBlur` prop + ``` ## Fails -```js -// fails when the `onChange` prop is present - +```jsx harmony +// fails when the `onChange` prop is present without an `onBlur` prop + ``` ## See also diff --git a/src/rules/valid-aria-role.js b/src/rules/aria-role.js similarity index 100% rename from src/rules/valid-aria-role.js rename to src/rules/aria-role.js diff --git a/src/rules/no-unsupported-elements-use-aria.js b/src/rules/aria-unsupported-elements.js similarity index 100% rename from src/rules/no-unsupported-elements-use-aria.js rename to src/rules/aria-unsupported-elements.js diff --git a/src/rules/redundant-alt.js b/src/rules/img-redundant-alt.js similarity index 100% rename from src/rules/redundant-alt.js rename to src/rules/img-redundant-alt.js diff --git a/src/rules/index.js b/src/rules/index.js index 50cdbd3..b413bbb 100644 --- a/src/rules/index.js +++ b/src/rules/index.js @@ -3,17 +3,17 @@ export default { 'button-role-space': require('./button-role-space').default, 'hidden-uses-tabindex': require('./hidden-uses-tabindex').default, 'img-uses-alt': require('./img-uses-alt').default, - 'label-uses-for': require('./label-uses-for').default, - 'mouse-events-map-to-key-events': require('./mouse-events-map-to-key-events').default, + 'label-has-for': require('./label-has-for').default, + 'mouse-events-have-key-events': require('./mouse-events-have-key-events').default, 'onclick-uses-role': require('./onclick-uses-role').default, - 'onclick-uses-tabindex': require('./onclick-uses-tabindex').default, + 'interactive-supports-focus': require('./interactive-supports-focus').default, 'no-access-key': require('./no-access-key').default, 'no-hash-ref': require('./no-hash-ref').default, - 'redundant-alt': require('./redundant-alt').default, - 'use-onblur-not-onchange': require('./use-onblur-not-onchange').default, - 'valid-aria-role': require('./valid-aria-role').default, + 'img-redundant-alt': require('./img-redundant-alt').default, + 'no-onchange': require('./no-onchange').default, + 'aria-role': require('./aria-role').default, 'tabindex-no-positive': require('./tabindex-no-positive').default, 'tabindex-uses-button': require('./tabindex-uses-button').default, - 'no-unsupported-elements-use-aria': require('./no-unsupported-elements-use-aria').default + 'aria-unsupported-elements': require('./aria-unsupported-elements').default }; diff --git a/src/rules/onclick-uses-tabindex.js b/src/rules/interactive-supports-focus.js similarity index 100% rename from src/rules/onclick-uses-tabindex.js rename to src/rules/interactive-supports-focus.js diff --git a/src/rules/label-uses-for.js b/src/rules/label-has-for.js similarity index 100% rename from src/rules/label-uses-for.js rename to src/rules/label-has-for.js diff --git a/src/rules/mouse-events-map-to-key-events.js b/src/rules/mouse-events-have-key-events.js similarity index 100% rename from src/rules/mouse-events-map-to-key-events.js rename to src/rules/mouse-events-have-key-events.js diff --git a/src/rules/use-onblur-not-onchange.js b/src/rules/no-onchange.js similarity index 100% rename from src/rules/use-onblur-not-onchange.js rename to src/rules/no-onchange.js