Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate docs with eslint-doc-generator #398

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('eslint-doc-generator').GenerateOptions} */
module.exports = {
configEmoji: [
['browser', '🔍'],
['internal', '🔐'],
['react', '⚛️']
],
ruleDocSectionInclude: ['Rule Details', 'Version'],
};
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Installation

```sh
$ npm install --save-dev eslint eslint-plugin-github
npm install --save-dev eslint eslint-plugin-github
```

## Setup
Expand Down Expand Up @@ -72,25 +72,37 @@ This config will be interpreted in the following way:

### Rules

- [Array Foreach](./docs/rules/array-foreach.md)
- [Async Currenttarget](./docs/rules/async-currenttarget.md)
- [Async Preventdefault](./docs/rules/async-preventdefault.md)
- [Authenticity Token](./docs/rules/authenticity-token.md)
- [Get Attribute](./docs/rules/get-attribute.md)
- [JS Class Name](./docs/rules/js-class-name.md)
- [No Blur](./docs/rules/no-blur.md)
- [No D None](./docs/rules/no-d-none.md)
- [No Dataset](./docs/rules/no-dataset.md)
- [No Dynamic Script Tag](./docs/rules/no-dynamic-script-tag.md)
- [No Implicit Buggy Globals](./docs/rules/no-implicit-buggy-globals.md)
- [No Inner HTML](./docs/rules/no-inner-html.md)
- [No InnerText](./docs/rules/no-innerText.md)
- [No Then](./docs/rules/no-then.md)
- [No Useless Passive](./docs/rules/no-useless-passive.md)
- [Prefer Observers](./docs/rules/prefer-observers.md)
- [Require Passive Events](./docs/rules/require-passive-events.md)
- [Unescaped HTML Literal](./docs/rules/unescaped-html-literal.md)

#### Accessibility-focused rules (prefixed with a11y)

- [Role Supports ARIA Props](./docs/rules/role-supports-aria-props.md)
<!-- begin auto-generated rules list -->

💼 Configurations enabled in.\
🔍 Set in the `browser` configuration.\
🔐 Set in the `internal` configuration.\
⚛️ Set in the `react` configuration.\
✅ Set in the `recommended` configuration.\
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
❌ Deprecated.

| Name                      | Description | 💼 | 🔧 | ❌ |
| :------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
| [a11y-no-generic-link-text](docs/rules/a11y-no-generic-link-text.md) | disallow generic link text | | | ❌ |
| [array-foreach](docs/rules/array-foreach.md) | enforce `for..of` loops over `Array.forEach` | ✅ | | |
| [async-currenttarget](docs/rules/async-currenttarget.md) | disallow `event.currentTarget` calls inside of async functions | 🔍 | | |
| [async-preventdefault](docs/rules/async-preventdefault.md) | disallow `event.preventDefault` calls inside of async functions | 🔍 | | |
| [authenticity-token](docs/rules/authenticity-token.md) | disallow usage of CSRF tokens in JavaScript | 🔐 | | |
| [get-attribute](docs/rules/get-attribute.md) | disallow wrong usage of attribute names | 🔍 | 🔧 | |
| [js-class-name](docs/rules/js-class-name.md) | enforce a naming convention for js- prefixed classes | 🔐 | | |
| [no-blur](docs/rules/no-blur.md) | disallow usage of `Element.prototype.blur()` | 🔍 | | |
| [no-d-none](docs/rules/no-d-none.md) | disallow usage the `d-none` CSS class | 🔐 | | |
| [no-dataset](docs/rules/no-dataset.md) | enforce usage of `Element.prototype.getAttribute` instead of `Element.prototype.datalist` | 🔍 | | |
| [no-dynamic-script-tag](docs/rules/no-dynamic-script-tag.md) | disallow creating dynamic script tags | ✅ | | |
| [no-implicit-buggy-globals](docs/rules/no-implicit-buggy-globals.md) | disallow implicit global variables | ✅ | | |
| [no-inner-html](docs/rules/no-inner-html.md) | disallow `Element.prototype.innerHTML` in favor of `Element.prototype.textContent` | 🔍 | | |
| [no-innerText](docs/rules/no-innerText.md) | disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent` | 🔍 | 🔧 | |
| [no-then](docs/rules/no-then.md) | enforce using `async/await` syntax over Promises | ✅ | | |
| [no-useless-passive](docs/rules/no-useless-passive.md) | disallow marking a event handler as passive when it has no effect | 🔍 | 🔧 | |
| [prefer-observers](docs/rules/prefer-observers.md) | disallow poorly performing event listeners | 🔍 | | |
| [require-passive-events](docs/rules/require-passive-events.md) | enforce marking high frequency event handlers as passive | 🔍 | | |
| [role-supports-aria-props](docs/rules/role-supports-aria-props.md) | Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. | ⚛️ | | |
| [unescaped-html-literal](docs/rules/unescaped-html-literal.md) | disallow unescaped HTML literals | 🔍 | | |

<!-- end auto-generated rules list -->
6 changes: 4 additions & 2 deletions docs/rules/a11y-no-generic-link-text.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# No Generic Link Text [Deprecated]
# Disallow generic link text (`github/a11y-no-generic-link-text`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these title updates auto-generated by the tool? If so what are they based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, based on the rule name and meta.docs.description, customizable here:

https://github.com/bmish/eslint-doc-generator#--rule-doc-title-format


_This rule has been deprecated in favor of `anchor-ambiguous-text` in `eslint-plugin-jsx-a11y`._
❌ This rule is deprecated. It was replaced by `jsx-a11y/anchor-ambiguous-text`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this part? is it auto-generated? If so what is it based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, based on meta.deprecated / meta.replacedBy.


<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/array-foreach.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Array Foreach
# Enforce `for..of` loops over `Array.forEach` (`github/array-foreach`)

💼 This rule is enabled in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

Prefer `for...of` statement instead of `Array.forEach`.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/async-currenttarget.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Async Currenttarget
# Disallow `event.currentTarget` calls inside of async functions (`github/async-currenttarget`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/async-preventdefault.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Async Preventdefault
# Disallow `event.preventDefault` calls inside of async functions (`github/async-preventdefault`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

Using `event.preventDefault()` inside an `async function()` won't likely work as you'd expect because synchronous nature of event dispatch.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/authenticity-token.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Authenticity Token
# Disallow usage of CSRF tokens in JavaScript (`github/authenticity-token`)

💼 This rule is enabled in the 🔐 `internal` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/get-attribute.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Get Attribute
# Disallow wrong usage of attribute names (`github/get-attribute`)

💼 This rule is enabled in the 🔍 `browser` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/js-class-name.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# JS Class Name
# Enforce a naming convention for js- prefixed classes (`github/js-class-name`)

💼 This rule is enabled in the 🔐 `internal` config.

<!-- end auto-generated rule header -->

JavaScript should only query and handle events for `js-` prefixed class names.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-blur.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Blur
# Disallow usage of `Element.prototype.blur()` (`github/no-blur`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

Do not use `element.blur()`. Blurring an element causes the focus position to be reset causing accessibility issues when using keyboard or voice navigation. Instead, restore focus by calling `element.focus()` on a prior element.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-d-none.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No D None
# Disallow usage the `d-none` CSS class (`github/no-d-none`)

💼 This rule is enabled in the 🔐 `internal` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-dataset.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Dataset
# Enforce usage of `Element.prototype.getAttribute` instead of `Element.prototype.datalist` (`github/no-dataset`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-dynamic-script-tag.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Dynamic Script Tag
# Disallow creating dynamic script tags (`github/no-dynamic-script-tag`)

💼 This rule is enabled in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-implicit-buggy-globals.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Implicit Buggy Globals
# Disallow implicit global variables (`github/no-implicit-buggy-globals`)

💼 This rule is enabled in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-inner-html.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Inner HTML
# Disallow `Element.prototype.innerHTML` in favor of `Element.prototype.textContent` (`github/no-inner-html`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/no-innerText.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# No InnerText
# Disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent` (`github/no-innerText`)

💼 This rule is enabled in the 🔍 `browser` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/no-then.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# No Then
# Enforce using `async/await` syntax over Promises (`github/no-then`)

💼 This rule is enabled in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/no-useless-passive.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# No Useless Passive
# Disallow marking a event handler as passive when it has no effect (`github/no-useless-passive`)

💼 This rule is enabled in the 🔍 `browser` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

This rule disallows setting `passive: true` for events on which it will have no effect.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/prefer-observers.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Prefer Observers
# Disallow poorly performing event listeners (`github/prefer-observers`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

Some events, such as `scroll` and `resize` have traditionally caused performance issues on web pages, as they are high frequency events, firing many times per second as the user interacts with the page viewport.

Expand Down
6 changes: 5 additions & 1 deletion docs/rules/require-passive-events.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Require Passive Events
# Enforce marking high frequency event handlers as passive (`github/require-passive-events`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

This rule enforces adding `passive: true` to high frequency event listeners (`touchstart`, `touchmove`, `touchenter`, `touchend`, `touchleave`, `wheel`, `mousewheel`).

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/role-supports-aria-props.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Role Supports ARIA Props
# Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role` (`github/role-supports-aria-props`)

💼 This rule is enabled in the ⚛️ `react` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down Expand Up @@ -72,3 +76,5 @@ There are conflicting resources and opinions on what elements should support the
<h1 id="dialogHeading">Heading</h1>
</div>
```

## Version
6 changes: 5 additions & 1 deletion docs/rules/unescaped-html-literal.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Unescaped HTML Literal
# Disallow unescaped HTML literals (`github/unescaped-html-literal`)

💼 This rule is enabled in the 🔍 `browser` config.

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
2 changes: 2 additions & 0 deletions lib/rules/a11y-no-generic-link-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = {
description: 'disallow generic link text',
url: require('../url')(module),
},
deprecated: true,
replacedBy: ['jsx-a11y/anchor-ambiguous-text'],
schema: [],
},

Expand Down