Skip to content

Commit

Permalink
feat: add require-asterisk-prefix rule (#446)
Browse files Browse the repository at this point in the history
feat: add require-asterisk-prefix rule; fixes #199

This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with other rules, this does not check the alignment or indentation of the comment content. Allow any/never/always option and `tags` option.

Co-authored-by: Eli Skeggs <eli@mixmax.com>
Co-authored-by: Brett Zamir <brettz9@yahoo.com>
  • Loading branch information
3 people committed May 10, 2021
1 parent 7de397b commit f892338
Show file tree
Hide file tree
Showing 8 changed files with 1,051 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .README/README.md
Expand Up @@ -63,6 +63,7 @@ Finally, enable all of the rules that you would like to use.
"jsdoc/no-defaults": 1,
"jsdoc/no-types": 1,
"jsdoc/no-undefined-types": 1, // Recommended
"jsdoc/require-asterisk-prefix": 1,
"jsdoc/require-description": 1,
"jsdoc/require-description-complete-sentence": 1,
"jsdoc/require-example": 1,
Expand Down Expand Up @@ -558,6 +559,7 @@ selector).
{"gitdown": "include", "file": "./rules/no-restricted-syntax.md"}
{"gitdown": "include", "file": "./rules/no-types.md"}
{"gitdown": "include", "file": "./rules/no-undefined-types.md"}
{"gitdown": "include", "file": "./rules/require-asterisk-prefix.md"}
{"gitdown": "include", "file": "./rules/require-description-complete-sentence.md"}
{"gitdown": "include", "file": "./rules/require-description.md"}
{"gitdown": "include", "file": "./rules/require-example.md"}
Expand Down
40 changes: 40 additions & 0 deletions .README/rules/require-asterisk-prefix.md
@@ -0,0 +1,40 @@
### `require-asterisk-prefix`

Requires that each JSDoc line starts with an `*`.

#### Options

This rule allows an optional string argument. If it is `"always"` then a
problem is raised when there is no asterisk prefix on a given jsdoc line. If
it is `"never"` then a problem is raised when there is an asterisk present.
The default value is `"always"`. You may also set the default to `"any"`
and use the `tags` option to apply to specific tags only.

After the string option, one may add an object with the following.

##### `tags`

If you want different values to apply to specific tags, you may use
the `tags` option object. The keys are `always`, `never`, or `any` and
the values are arrays of tag names or the special value `*description`
which applies to the main jsdoc block description.

```js
{
'jsdoc/require-asterisk-prefix': ['error', 'always', {
tags: {
always: ['*description'],
any: ['example', 'license'],
never: ['copyright']
}
}]
}
```

|||
|---|---|
|Context|everywhere|
|Tags|All or as limited by the `tags` option|
|Options|(a string matching `"always"|"never"` and optional object with `tags`)|

<!-- assertions requireAsteriskPrefix -->

0 comments on commit f892338

Please sign in to comment.