Skip to content

Commit 6873cc0

Browse files
AlmeroSteynromaindso
authored andcommitted
ESLint Config: Upgrade eslint-plugin-jsx-a11y and activate more rules. (facebook#2163)
* ESLint Config: Upgrade eslint-plugin-jsx-a11y and activate more rules. * Try to fix Lerna * Update README.md * Remove html-has-lang * Update README.md
1 parent eaf5e53 commit 6873cc0

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

packages/eslint-config-react-app/README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Please refer to its documentation:
88

99
## Usage in Create React App Projects
1010

11-
The easiest way to use this configuration is with [Create React App](https://github.com/facebookincubator/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.**
11+
The easiest way to use this configuration is with [Create React App](https://github.com/facebookincubator/create-react-app), which includes it by default.
12+
13+
**You don’t need to install it separately in Create React App projects.**
1214

1315
## Usage Outside of Create React App
1416

@@ -17,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create
1719
First, install this package, ESLint and the necessary plugins.
1820

1921
```sh
20-
npm install --save-dev eslint-config-react-app babel-eslint@7.1.1 eslint@3.16.1 eslint-plugin-flowtype@2.21.0 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@4.0.0 eslint-plugin-react@6.4.1
22+
npm install --save-dev eslint-config-react-app babel-eslint@7.1.1 eslint@3.16.1 eslint-plugin-flowtype@2.21.0 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@5.0.1 eslint-plugin-react@6.4.1
2123
```
2224

2325
Then create a file named `.eslintrc` with following contents in the root folder of your project:
@@ -29,3 +31,37 @@ Then create a file named `.eslintrc` with following contents in the root folder
2931
```
3032

3133
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
34+
35+
## Accessibility Checks
36+
37+
The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin are activated:
38+
39+
- [accessible-emoji](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md)
40+
- [alt-text](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md)
41+
- [anchor-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md)
42+
- [aria-activedescendant-has-tabindex](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md)
43+
- [aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md)
44+
- [aria-proptypes](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md)
45+
- [aria-role](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
46+
- [aria-unsupported-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md)
47+
- [heading-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md)
48+
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md)
49+
- [iframe-has-title](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md)
50+
- [img-redundant-alt](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md)
51+
- [no-access-key](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)
52+
- [no-distracting-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md)
53+
- [no-redundant-roles](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md)
54+
- [role-has-required-aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md)
55+
- [role-supports-aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md)
56+
- [scope](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md)
57+
58+
If you want to enable even more accessibility rules, you can create an `.eslintrc` file in the root of your project with this content:
59+
60+
```json
61+
{
62+
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
63+
"plugins": ["jsx-a11y"]
64+
}
65+
```
66+
67+
However, if you are using [Create React App](https://github.com/facebookincubator/create-react-app) and have not ejected, any additional rules will only be displayed in the [IDE integrations](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor), but not in the browser or the terminal.

packages/eslint-config-react-app/index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,24 @@ module.exports = {
294294
'react/style-prop-object': 'warn',
295295

296296
// https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
297+
'jsx-a11y/accessible-emoji': 'warn',
298+
'jsx-a11y/alt-text': 'warn',
299+
'jsx-a11y/anchor-has-content': 'warn',
300+
'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
301+
'jsx-a11y/aria-props': 'warn',
302+
'jsx-a11y/aria-proptypes': 'warn',
297303
'jsx-a11y/aria-role': 'warn',
298-
'jsx-a11y/img-has-alt': 'warn',
304+
'jsx-a11y/aria-unsupported-elements': 'warn',
305+
'jsx-a11y/heading-has-content': 'warn',
306+
'jsx-a11y/href-no-hash': 'warn',
307+
'jsx-a11y/iframe-has-title': 'warn',
299308
'jsx-a11y/img-redundant-alt': 'warn',
300309
'jsx-a11y/no-access-key': 'warn',
310+
'jsx-a11y/no-distracting-elements': 'warn',
311+
'jsx-a11y/no-redundant-roles': 'warn',
312+
'jsx-a11y/role-has-required-aria-props': 'warn',
313+
'jsx-a11y/role-supports-aria-props': 'warn',
314+
'jsx-a11y/scope': 'warn',
301315

302316
// https://github.com/gajus/eslint-plugin-flowtype
303317
'flowtype/define-flow-type': 'warn',

packages/eslint-config-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"eslint": "^3.16.1",
1616
"eslint-plugin-flowtype": "^2.21.0",
1717
"eslint-plugin-import": "^2.0.1",
18-
"eslint-plugin-jsx-a11y": "^2.0.0 || ^3.0.0 || ^4.0.0",
18+
"eslint-plugin-jsx-a11y": "^5.0.0",
1919
"eslint-plugin-react": "^6.4.1"
2020
}
2121
}

packages/react-error-overlay/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
"devDependencies": {
4040
"babel-cli": "^6.24.1",
4141
"babel-eslint": "7.x",
42-
"babel-preset-react-app": "^2.2.0",
42+
"babel-preset-react-app": "^2.1.1",
4343
"cross-env": "^4.0.0",
4444
"eslint": "^3.16.1",
45-
"eslint-config-react-app": "^0.6.2",
45+
"eslint-config-react-app": "^0.6.1",
4646
"eslint-plugin-flowtype": "^2.21.0",
4747
"eslint-plugin-import": "^2.0.1",
48-
"eslint-plugin-jsx-a11y": "^4.0.0",
48+
"eslint-plugin-jsx-a11y": "^5.0.0",
4949
"eslint-plugin-react": "^6.4.1",
5050
"flow-bin": "^0.46.0",
5151
"jest": "19.x",

packages/react-scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"eslint-loader": "1.7.1",
4242
"eslint-plugin-flowtype": "2.21.0",
4343
"eslint-plugin-import": "2.0.1",
44-
"eslint-plugin-jsx-a11y": "4.0.0",
44+
"eslint-plugin-jsx-a11y": "5.0.1",
4545
"eslint-plugin-react": "6.4.1",
4646
"extract-text-webpack-plugin": "2.1.0",
4747
"file-loader": "0.11.1",

0 commit comments

Comments
 (0)