Skip to content

Commit

Permalink
Renamed a number of rules that were equivalent to existing rules in t…
Browse files Browse the repository at this point in the history
…he eslint-plugin-jsx-a11y library for consistency between the two libs
  • Loading branch information
Erin Doyle committed Oct 13, 2018
1 parent 58e525f commit 3e9e4b5
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 47 deletions.
6 changes: 3 additions & 3 deletions docs/rules/valid-aria-role.md → docs/rules/aria-role.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,7 +16,7 @@ on additional required attributes, on the

## Passes

```js
```jsx harmony
// passes when there is a role and it is valid
<div role="button"></div>

Expand All @@ -26,7 +26,7 @@ on additional required attributes, on the

## Fails

```js
```jsx harmony
// fails when there is an invalid `role`
<div role="foo"></div>
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# no-unsupported-elements-use-aria
# aria-unsupported-elements


Certain reserved DOM elements do not support ARIA roles, states and properties.
Expand All @@ -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
<meta/>

// no problem when an illegal props is given to a non-reserved elemeent
Expand All @@ -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
<meta aria-hidden="false"/>
```

## See also

- Google Audit defs [AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-defs#ax_aria_12)
- Google Audit defs [AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-defs#ax_aria_12)
4 changes: 2 additions & 2 deletions docs/rules/hidden-uses-tabindex.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
<input aria-hidden="true" tabindex="-1"/>

Expand All @@ -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
<input aria-hidden="true"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,7 +13,7 @@ This rule takes the following options:

## Passes

```js
```jsx harmony
// passes when the `alt` does not contain redundant words
<img src="foo" alt="nice"/>

Expand All @@ -27,7 +27,7 @@ This rule takes the following options:

## Fails

```js
```jsx harmony
// fails when is a redundant alt message
<img src="foo" alt="bar image foo"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,22 +11,22 @@ keyboard users.

## Passes

```js
```jsx harmony
// passes when when there is an `onClick` with a `tabIndex`
<span tabindex="0"></span>
<span onClick={someFunction} tabindex="0"></span>

// passes when the element is hidden from aria
<span aria-hidden="true"></span>
<span onClick={someFunction} aria-hidden="true"></span>

// passes when the element is interactive
<button></button>
<button onClick={someFunction}></button>
```

## Fails

```js
```jsx harmony
// fails when there is an `onClick` with no `tabIndex`
<span></span>
<span onClick={someFunction}></span>
```

## See also
Expand Down
6 changes: 3 additions & 3 deletions docs/rules/label-uses-for.md → docs/rules/label-has-for.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +11,7 @@ the control using: `<label htmlFor={/* ID or name of control*/}>...</label>`.

## Passes

```js
```jsx harmony
// passes when the label is hidden
<label aria-hidden="true"></label>

Expand All @@ -24,7 +24,7 @@ the control using: `<label htmlFor={/* ID or name of control*/}>...</label>`.

## Fails

```js
```jsx harmony
// fails when a label is not hidden and has no `htmlFor`
<label></label>
```
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,25 +12,25 @@ users.

## Passes

```js
```jsx harmony
// passes when there is no `onMouseOver` or `onMouseOut`
<div></div>

// passes when there is `onMouseOver` but and `onFocus`
<div></div>
// passes when there is `onMouseOver` and `onFocus`
<div onMouseOver={someFunction} onFocus={someFunction}></div>

// passes when there is `onMouseOut` but and `onBlur`
<div></div>
// passes when there is `onMouseOut` and `onBlur`
<div onMouseOut={someFunction} onBlur={someFunction}></div>
```

## Fails

```js
```jsx harmony
// fails when there is `onMouseOver` but no `onFocus`
<div></div>
<div onMouseOver={someFunction}></div>

// fails when there is `onMouseOut` but no `onBlur`
<div></div>
<div onMouseOut={someFunction}></div>
```

## See also
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,25 +11,28 @@ consequences for keyboard only or screen reader users.

## Passes

```js
```jsx harmony
// passes when there is no `onChange` prop
<input/>

// passes when the element is aria-hidden
<input aria-hidden="true"/>
<input onChange={fn} aria-hidden="true"/>

// passes when the element is aria-disabled
<input aria-disabled="true"/>
<input onChange={fn} aria-disabled="true"/>

// passes when the element is aria-readonly
<input aria-readonly="true"/>
<input onChange={fn} aria-readonly="true"/>

// passes when there is an `onChange` prop and an `onBlur` prop
<input onChange={fn} onBlur={fn}/>
```

## Fails

```js
// fails when the `onChange` prop is present
<input/>
```jsx harmony
// fails when the `onChange` prop is present without an `onBlur` prop
<input onChange={fn}/>
```

## See also
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions src/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3e9e4b5

Please sign in to comment.