From 9980d1da6f1c7d156db5653a136c8fab38f3f2d8 Mon Sep 17 00:00:00 2001 From: uncommon-type Date: Mon, 28 Feb 2022 15:43:09 +0300 Subject: [PATCH] [Docs] Add infrastructure for auto-generating markdown table and list - Add readme.yml file to ensure table and list markdown content is auto-generated from rules folder - Add md-magic dependency and scripts to package.json for updating readme markdown - Add markdown.config.js file to add transformation functions to the transforms object - Add scripts to README markdown to keep documentation content in sync with readme - Disable `no-console` rule in markdown.config file in .eslintrc - Add errorOptions property to source files for rules with extra options Closes #836 --- .eslintrc | 14 ++ .github/workflows/readme.yml | 15 ++ README.md | 145 ++++++++++-------- markdown.config.js | 49 ++++++ package.json | 8 +- src/rules/alt-text.js | 1 + src/rules/anchor-has-content.js | 1 + src/rules/anchor-is-valid.js | 1 + .../aria-activedescendant-has-tabindex.js | 1 + src/rules/aria-props.js | 1 + src/rules/aria-proptypes.js | 1 + src/rules/aria-role.js | 1 + src/rules/aria-unsupported-elements.js | 1 + src/rules/autocomplete-valid.js | 1 + src/rules/click-events-have-key-events.js | 1 + src/rules/heading-has-content.js | 1 + src/rules/html-has-lang.js | 1 + src/rules/iframe-has-title.js | 1 + src/rules/img-redundant-alt.js | 1 + src/rules/interactive-supports-focus.js | 1 + src/rules/label-has-associated-control.js | 5 +- src/rules/lang.js | 1 + src/rules/media-has-caption.js | 1 + src/rules/mouse-events-have-key-events.js | 1 + src/rules/no-access-key.js | 1 + src/rules/no-autofocus.js | 1 + src/rules/no-distracting-elements.js | 1 + ...eractive-element-to-noninteractive-role.js | 2 + .../no-noninteractive-element-interactions.js | 2 + ...interactive-element-to-interactive-role.js | 2 + src/rules/no-noninteractive-tabindex.js | 2 + src/rules/no-onchange.js | 1 + src/rules/no-redundant-roles.js | 1 + src/rules/no-static-element-interactions.js | 2 + src/rules/role-has-required-aria-props.js | 1 + src/rules/role-supports-aria-props.js | 1 + src/rules/scope.js | 2 + src/rules/tabindex-no-positive.js | 1 + 38 files changed, 204 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/readme.yml create mode 100644 markdown.config.js diff --git a/.eslintrc b/.eslintrc index a413b4ca4..aeb58e1f6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -23,6 +23,20 @@ "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/.github/workflows/readme.yml b/.github/workflows/readme.yml new file mode 100644 index 000000000..1a943aa4c --- /dev/null +++ b/.github/workflows/readme.yml @@ -0,0 +1,15 @@ +name: 'Tests: readme' + +on: [pull_request, push] + +jobs: + readme: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: npm run generate-list-of-rules:check diff --git a/README.md b/README.md index c229f7353..c75e78dad 100644 --- a/README.md +++ b/README.md @@ -91,76 +91,87 @@ Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`: ## Supported Rules -- [alt-text](docs/rules/alt-text.md): Enforce all elements that require alternative text have meaningful information to relay back to end user. -- [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. -- [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. -- [lang](docs/rules/lang.md): Enforce lang attribute has a valid value. -- [media-has-caption](docs/rules/media-has-caption.md): Enforces that `