Skip to content

Commit

Permalink
feat: added informative-docs rule
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg authored and brettz9 committed Apr 11, 2023
1 parent f1ea352 commit 8e13fa7
Show file tree
Hide file tree
Showing 7 changed files with 1,569 additions and 222 deletions.
1 change: 1 addition & 0 deletions .README/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ selector).
{"gitdown": "include", "file": "./rules/check-values.md"}
{"gitdown": "include", "file": "./rules/empty-tags.md"}
{"gitdown": "include", "file": "./rules/implements-on-classes.md"}
{"gitdown": "include", "file": "./rules/informative-docs.md"}
{"gitdown": "include", "file": "./rules/match-description.md"}
{"gitdown": "include", "file": "./rules/match-name.md"}
{"gitdown": "include", "file": "./rules/multiline-blocks.md"}
Expand Down
61 changes: 61 additions & 0 deletions .README/rules/informative-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
### `informative-docs`

Reports on JSDoc texts that serve only to restart their attached name.

Devs sometimes write JSDoc descriptions that add no additional information just to fill out the doc:

```js
/** The user id. */
let userId;
```

Those "uninformative" docs comments take up space without being helpful.
This rule requires all docs comments contain at least one word not already in the code.

#### Options

#### `aliases`

The `aliases` option allows indicating words as synonyms (aliases) of each other.

For example, with `{ aliases: { emoji: ["smiley", "winkey"] } }`, the following comment would be considered uninformative:

```js
/** A smiley/winkey. */
let emoji;
```

The default `aliases` option is:

```json
{
"a": ["an", "our"]
}
```

#### `uselessWords`

Words that are ignored when searching for one that adds meaning.

For example, with `{ uselessWords: ["our"] }`, the following comment would be considered uninformative:

```js
/** Our text. */
let text;
```

The default `uselessWords` option is:

```json
["a", "an", "i", "in", "of", "s", "the"]
```

|||
|---|---|
|Context|everywhere|
|Tags|any|
|Recommended|false|
|Settings||
|Options|`aliases`, `uselessWords`|

<!-- assertions informativeDocs -->
Loading

0 comments on commit 8e13fa7

Please sign in to comment.