From 03b41b5c26818bbc9021c73d4462d90064dda34a Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Wed, 26 Oct 2022 20:06:32 -0500 Subject: [PATCH] docs: automate docs with eslint-doc-generator --- .eslintrc | 14 -- README.md | 149 +++++++----------- docs/rules/accessible-emoji.md | 6 +- docs/rules/alt-text.md | 26 ++- docs/rules/anchor-ambiguous-text.md | 10 +- docs/rules/anchor-has-content.md | 8 +- docs/rules/anchor-is-valid.md | 8 +- .../aria-activedescendant-has-tabindex.md | 6 +- docs/rules/aria-props.md | 6 +- docs/rules/aria-proptypes.md | 6 +- docs/rules/aria-role.md | 8 +- docs/rules/aria-unsupported-elements.md | 6 +- docs/rules/autocomplete-valid.md | 12 +- docs/rules/click-events-have-key-events.md | 6 +- docs/rules/control-has-associated-label.md | 8 +- docs/rules/heading-has-content.md | 8 +- docs/rules/html-has-lang.md | 6 +- docs/rules/iframe-has-title.md | 6 +- docs/rules/img-redundant-alt.md | 8 +- docs/rules/interactive-supports-focus.md | 16 +- docs/rules/label-has-associated-control.md | 8 +- docs/rules/label-has-for.md | 10 +- docs/rules/lang.md | 4 +- docs/rules/media-has-caption.md | 8 +- docs/rules/mouse-events-have-key-events.md | 6 +- docs/rules/no-access-key.md | 6 +- docs/rules/no-autofocus.md | 8 +- docs/rules/no-distracting-elements.md | 8 +- ...eractive-element-to-noninteractive-role.md | 10 +- .../no-noninteractive-element-interactions.md | 14 +- ...interactive-element-to-interactive-role.md | 11 +- docs/rules/no-noninteractive-tabindex.md | 14 +- docs/rules/no-onchange.md | 6 +- docs/rules/no-redundant-roles.md | 12 +- docs/rules/no-static-element-interactions.md | 13 +- docs/rules/prefer-tag-over-role.md | 4 +- docs/rules/role-has-required-aria-props.md | 6 +- docs/rules/role-supports-aria-props.md | 6 +- docs/rules/scope.md | 6 +- docs/rules/tabindex-no-positive.md | 6 +- markdown.config.js | 59 ------- package.json | 7 +- scripts/boilerplate/rule.js | 2 +- ...eractive-element-to-noninteractive-role.js | 1 - .../no-noninteractive-element-interactions.js | 1 - ...interactive-element-to-interactive-role.js | 1 - src/rules/no-noninteractive-tabindex.js | 1 - src/rules/no-static-element-interactions.js | 1 - src/rules/scope.js | 1 - 49 files changed, 322 insertions(+), 241 deletions(-) delete mode 100644 markdown.config.js diff --git a/.eslintrc b/.eslintrc index a0623fd57..a94e7cb6a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -28,20 +28,6 @@ "eslint-plugin/require-meta-type": "off", }, }, - { - "files": ["markdown.config.js"], - "parserOptions": { - "sourceType": "script", - }, - "rules": { - "no-console": 0, - "import/no-extraneous-dependencies": [ - "error", - { "devDependencies": true }, - ], - "strict": ["error", "global"], - }, - }, { "files": ["__tests__/src/rules/*.js"], "extends": ["plugin:eslint-plugin/tests-recommended"], diff --git a/README.md b/README.md index 43411bbf4..d74fc210e 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`: "extends": ["plugin:jsx-a11y/recommended"] } ``` + > As you are extending our configuration, you can omit `"plugins": ["jsx-a11y"]` from your `.eslintrc` configuration file. To enable your custom components to be checked as DOM elements, you can set global settings in your @@ -110,95 +111,59 @@ configuration file by mapping each custom component name to a DOM element type. ## Supported Rules - - -- [alt-text](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/alt-text.md): Enforce all elements that require alternative text have meaningful information to relay back to end user. -- [anchor-ambiguous-text](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-ambiguous-text.md): Enforce `` text to not exactly match "click here", "here", "link", or "a link". -- [anchor-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-has-content.md): Enforce all anchors to contain accessible content. -- [anchor-is-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-is-valid.md): Enforce all anchors are valid, navigable elements. -- [aria-activedescendant-has-tabindex](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-activedescendant-has-tabindex.md): Enforce elements with aria-activedescendant are tabbable. -- [aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-props.md): Enforce all `aria-*` props are valid. -- [aria-proptypes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-proptypes.md): Enforce ARIA state and property values are valid. -- [aria-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-role.md): Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role. -- [aria-unsupported-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md): Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. -- [autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/autocomplete-valid.md): Enforce that autocomplete attributes are used correctly. -- [click-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md): Enforce a clickable non-interactive element has at least one keyboard event listener. -- [control-has-associated-label](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/control-has-associated-label.md): Enforce that a control (an interactive element) has a text label. -- [heading-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/heading-has-content.md): Enforce heading (`h1`, `h2`, etc) elements contain accessible content. -- [html-has-lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md): Enforce `` element has `lang` prop. -- [iframe-has-title](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md): Enforce iframe elements have a title attribute. -- [img-redundant-alt](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/img-redundant-alt.md): Enforce `` alt prop does not contain the word "image", "picture", or "photo". -- [interactive-supports-focus](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/interactive-supports-focus.md): Enforce that elements with interactive handlers like `onClick` must be focusable. -- [label-has-associated-control](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md): Enforce that a `label` tag has a text label and an associated control. - -- [lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/lang.md): Enforce lang attribute has a valid value. -- [media-has-caption](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/media-has-caption.md): Enforces that `
`) that have click handlers use the role attribute. - -- [role-has-required-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-has-required-aria-props.md): Enforce that elements with ARIA roles must have all required attributes for that role. -- [role-supports-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-supports-aria-props.md): Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. -- [scope](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/scope.md): Enforce `scope` prop is only used on `` elements. -- [tabindex-no-positive](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/tabindex-no-positive.md): Enforce `tabIndex` value is not greater than zero. - - -### Rule strictness in different modes - - -| Rule | Recommended | Strict | -| :--- | :--- | :--- | -| [accessible-emoji](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/accessible-emoji.md) | off | off | -| [alt-text](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/alt-text.md) | error | error | -| [anchor-ambiguous-text](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-ambiguous-text.md) | off | off | -| [anchor-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-has-content.md) | error | error | -| [anchor-is-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-is-valid.md) | error | error | -| [aria-activedescendant-has-tabindex](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-activedescendant-has-tabindex.md) | error | error | -| [aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-props.md) | error | error | -| [aria-proptypes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-proptypes.md) | error | error | -| [aria-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-role.md) | error | error | -| [aria-unsupported-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md) | error | error | -| [autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/autocomplete-valid.md) | error | error | -| [click-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md) | error | error | -| [control-has-associated-label](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/control-has-associated-label.md) | off | off | -| [heading-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/heading-has-content.md) | error | error | -| [html-has-lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md) | error | error | -| [iframe-has-title](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md) | error | error | -| [img-redundant-alt](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/img-redundant-alt.md) | error | error | -| [interactive-supports-focus](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/interactive-supports-focus.md) | error | error | -| [label-has-associated-control](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md) | error | error | -| [label-has-for](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/label-has-for.md) | off | off | -| [lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/lang.md) | off | off | -| [media-has-caption](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/media-has-caption.md) | error | error | -| [mouse-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/mouse-events-have-key-events.md) | error | error | -| [no-access-key](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-access-key.md) | error | error | -| [no-autofocus](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-autofocus.md) | error | error | -| [no-distracting-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-distracting-elements.md) | error | error | -| [no-interactive-element-to-noninteractive-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-interactive-element-to-noninteractive-role.md) | error, with options | error | -| [no-noninteractive-element-interactions](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-element-interactions.md) | error, with options | error | -| [no-noninteractive-element-to-interactive-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-element-to-interactive-role.md) | error, with options | error | -| [no-noninteractive-tabindex](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-tabindex.md) | error, with options | error | -| [no-onchange](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-onchange.md) | off | off | -| [no-redundant-roles](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-redundant-roles.md) | error | error | -| [no-static-element-interactions](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-static-element-interactions.md) | error, with options | error | -| [prefer-tag-over-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/prefer-tag-over-role.md) | off | off | -| [role-has-required-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-has-required-aria-props.md) | error | error | -| [role-supports-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-supports-aria-props.md) | error | error | -| [scope](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/scope.md) | error, with options | error | -| [tabindex-no-positive](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/tabindex-no-positive.md) | error | error | - + + +πŸ’Ό Configurations enabled in.\ +β˜‘οΈ Enabled in the `recommended` configuration.\ +πŸ”’ Enabled in the `strict` configuration.\ +❌ Deprecated. + +| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | ❌ | +| :----------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | :---- | :-- | +| [accessible-emoji](docs/rules/accessible-emoji.md) | | | ❌ | +| [alt-text](docs/rules/alt-text.md) | Enforce all elements that require alternative text have meaningful information to relay back to end user. | β˜‘οΈ πŸ”’ | | +| [anchor-ambiguous-text](docs/rules/anchor-ambiguous-text.md) | Enforce `` text to not exactly match "click here", "here", "link", or "a link". | | | +| [anchor-has-content](docs/rules/anchor-has-content.md) | Enforce all anchors to contain accessible content. | β˜‘οΈ πŸ”’ | | +| [anchor-is-valid](docs/rules/anchor-is-valid.md) | Enforce all anchors are valid, navigable elements. | β˜‘οΈ πŸ”’ | | +| [aria-activedescendant-has-tabindex](docs/rules/aria-activedescendant-has-tabindex.md) | Enforce elements with aria-activedescendant are tabbable. | β˜‘οΈ πŸ”’ | | +| [aria-props](docs/rules/aria-props.md) | Enforce all `aria-*` props are valid. | β˜‘οΈ πŸ”’ | | +| [aria-proptypes](docs/rules/aria-proptypes.md) | Enforce ARIA state and property values are valid. | β˜‘οΈ πŸ”’ | | +| [aria-role](docs/rules/aria-role.md) | Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role. | β˜‘οΈ πŸ”’ | | +| [aria-unsupported-elements](docs/rules/aria-unsupported-elements.md) | Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | β˜‘οΈ πŸ”’ | | +| [autocomplete-valid](docs/rules/autocomplete-valid.md) | Enforce that autocomplete attributes are used correctly. | β˜‘οΈ πŸ”’ | | +| [click-events-have-key-events](docs/rules/click-events-have-key-events.md) | Enforce a clickable non-interactive element has at least one keyboard event listener. | β˜‘οΈ πŸ”’ | | +| [control-has-associated-label](docs/rules/control-has-associated-label.md) | Enforce that a control (an interactive element) has a text label. | | | +| [heading-has-content](docs/rules/heading-has-content.md) | Enforce heading (`h1`, `h2`, etc) elements contain accessible content. | β˜‘οΈ πŸ”’ | | +| [html-has-lang](docs/rules/html-has-lang.md) | Enforce `` element has `lang` prop. | β˜‘οΈ πŸ”’ | | +| [iframe-has-title](docs/rules/iframe-has-title.md) | Enforce iframe elements have a title attribute. | β˜‘οΈ πŸ”’ | | +| [img-redundant-alt](docs/rules/img-redundant-alt.md) | Enforce `` alt prop does not contain the word "image", "picture", or "photo". | β˜‘οΈ πŸ”’ | | +| [interactive-supports-focus](docs/rules/interactive-supports-focus.md) | Enforce that elements with interactive handlers like `onClick` must be focusable. | β˜‘οΈ πŸ”’ | | +| [label-has-associated-control](docs/rules/label-has-associated-control.md) | Enforce that a `label` tag has a text label and an associated control. | β˜‘οΈ πŸ”’ | | +| [label-has-for](docs/rules/label-has-for.md) | | | ❌ | +| [lang](docs/rules/lang.md) | Enforce lang attribute has a valid value. | | | +| [media-has-caption](docs/rules/media-has-caption.md) | Enforces that `