Skip to content

Commit aeae82a

Browse files
committed
- Docs: Toward resolving #216, document which rules employ each of the settings
- Docs: Add require-jsdoc docs per #208 - Docs: Fix/add to tags/aliases listed for rules - Docs: Add "Settings" column in rule tables to indicate applicable settings - Docs: Observation about `Object.create(null)` and `check-types` - Refactoring: Avoid nested `if`
1 parent f165509 commit aeae82a

21 files changed

+517
-28
lines changed

.README/README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ Finally, enable all of the rules that you would like to use.
103103

104104
## Settings
105105

106+
### Allow `@private` to disable rules for that comment block
107+
108+
- `settings.jsdoc.allowPrivate` - Disables all rules for the comment block
109+
on which it occurs.
110+
111+
### Exempting empty functions from `require-jsdoc`
112+
113+
- `settings.jsdoc.exemptEmptyFunctions` - Will not report missing jsdoc blocks
114+
above functions/methods with no parameters or return values (intended where
115+
variable names are sufficient for themselves as documentation).
116+
106117
### Alias Preference
107118

108119
Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a JSDoc tag. The format of the configuration is: `<primary tag name>: <preferred alias name>`, e.g.
@@ -121,9 +132,26 @@ Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a
121132
}
122133
```
123134

135+
This setting is utilized by the the rule for tag name checking
136+
(`check-tag-names`) as well as in the `@param` and `@require` rules:
137+
138+
- `check-param-names`
139+
- `check-tag-names`
140+
- `require-hyphen-before-param-description`
141+
- `require-description`
142+
- `require-param`
143+
- `require-param-description`
144+
- `require-param-name`
145+
- `require-param-type`
146+
- `require-returns`
147+
- `require-returns-check`
148+
- `require-returns-description`
149+
- `require-returns-type`
150+
124151
### Additional Tag Names
125152

126-
Use `settings.jsdoc.additionalTagNames` to configure additional, allowed JSDoc tags. The format of the configuration is as follows:
153+
Use `settings.jsdoc.additionalTagNames` to configure additional, allowed JSDoc
154+
tags in the rule `check-tag-names`. The format of the configuration is as follows:
127155

128156
```json
129157
{
@@ -166,6 +194,29 @@ The format of the configuration is as follows:
166194
}
167195
```
168196

197+
### Settings to Configure `valid-types`
198+
199+
* `settings.jsdoc.allowEmptyNamepaths` - Set to `false` to disallow
200+
empty name paths with `@callback`, `@event`, `@listens`, `@fires`,
201+
or `@emits` (these might often be expected to have an accompanying
202+
name path, though they have some indicative value without one)
203+
* `settings.jsdoc.checkSeesForNamepaths` - Set this to `true` to insist
204+
that `@see` only use name paths (the tag is normally permitted to
205+
allow other text)
206+
207+
### Settings to Configure `require-returns`
208+
209+
* `settings.jsdoc.forceRequireReturn` - Set to `true` to always insist on
210+
`@returns` documentation regardless of implicit or explicit `return`'s
211+
in the function. May be desired to flag that a project is aware of an
212+
`undefined`/`void` return.
213+
214+
### Settings to Configure `require-example`
215+
216+
* `settings.jsdoc.avoidExampleOnConstructors` - Set to `true` to avoid the
217+
need for an example on a constructor (whether indicated as such by a
218+
jsdoc tag or by being within an ES6 `class`).
219+
169220
### Settings to Configure `check-examples`
170221

171222
The settings below all impact the `check-examples` rule and default to
@@ -264,6 +315,7 @@ Finally, the following rule pertains to inline disable directives:
264315
{"gitdown": "include", "file": "./rules/require-description-complete-sentence.md"}
265316
{"gitdown": "include", "file": "./rules/require-description.md"}
266317
{"gitdown": "include", "file": "./rules/require-example.md"}
318+
{"gitdown": "include", "file": "./rules/require-jsdoc.md"}
267319
{"gitdown": "include", "file": "./rules/require-hyphen-before-param-description.md"}
268320
{"gitdown": "include", "file": "./rules/require-param-description.md"}
269321
{"gitdown": "include", "file": "./rules/require-param-name.md"}

.README/rules/check-examples.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ command.
2323
|||
2424
|---|---|
2525
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
26-
|Tags|`param`|
26+
|Tags|`example`|
27+
|Settings| *See above* |
2728

2829
<!-- assertions checkExamples -->

.README/rules/check-tag-names.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ yields
7979
|---|---|
8080
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8181
|Tags|N/A|
82+
|Settings|`tagNamePreference`, `additionalTagNames`|
8283

8384
<!-- assertions checkTagNames -->

.README/rules/check-types.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
3030
new String('lard') === 'lard' // false
3131
```
3232

33-
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object.
33+
To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object. (`Object.create(null)` objects are not, however.)
3434

3535
Basically, for primitives, we want to define the type as a primitive, because that's what we use in 99.9% of cases. For everything else, we use the type rather than the primitive. Otherwise it would all just be `{object}`.
3636

@@ -47,8 +47,9 @@ Number | **number** | **number** | `(41) instanceof Number` -> **`false`**
4747
String | **string** | **string** | `("test") instanceof String` -> **`false`**
4848

4949
|||
50-
|---|---|
50+
|---|---|---|
5151
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
52-
|Tags|`class`, `constant`, `enum`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`|
53-
52+
|Tags|`class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
53+
|Aliases|`constructor`, `const`, `var`, `arg`, `argument`, `prop`, `return`, `exception`|
54+
|Closure-only|`package`, `private`, `protected`, `public`, `static`|
5455
<!-- assertions checkTypes -->

.README/rules/no-undefined-types.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
### `no-undefined-types`
22

3-
Checks that types in jsdoc comments are defined. This can be used to check unimported types.
3+
Checks that types in jsdoc comments are defined. This can be used to check
4+
unimported types.
45

5-
When enabling this rule, types in jsdoc comments will resolve as used variables, i.e. will not be marked as unused by `no-unused-vars`.
6+
When enabling this rule, types in jsdoc comments will resolve as used
7+
variables, i.e. will not be marked as unused by `no-unused-vars`.
68

9+
The following tags will be checked for name(paths) definitions to also serve
10+
as a potential "type" for checking the tag types in the table below:
11+
12+
`callback`, `class` (or `constructor`), `constant` (or `const`), `event`, `external` (or `host`), `function` (or `func` or `method`), `interface`, `member` (or `var`), `mixin`, `name`, `namespace`, `typedef`.
713

814
|||
915
|---|---|
1016
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
11-
|Tags|`param`, `returns`|
12-
17+
|Tags|`class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
18+
|Aliases|`constructor`, `const`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
19+
|Closure-only|`package`, `private`, `protected`, `public`, `static`|
1320
<!-- assertions noUndefinedTypes -->

.README/rules/require-description-complete-sentence.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ Requires that block description and tag description are written in complete sent
1111
|---|---|
1212
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1313
|Tags|`param`, `returns`|
14+
|Aliases|`arg`, `argument`, `return`|
1415

1516
<!-- assertions requireDescriptionCompleteSentence -->

.README/rules/require-description.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Requires that all functions have a description.
88
|||
99
|---|---|
1010
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
11-
|Tags|`class`, `example`|
11+
|Tags|`description`|
12+
|Aliases|`desc`|
1213

1314
<!-- assertions requireDescription -->

.README/rules/require-example.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ Requires that all functions have examples.
99
|---|---|
1010
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1111
|Tags|`example`|
12+
|Settings|`avoidExampleOnConstructors`|
1213

1314
<!-- assertions requireExample -->

.README/rules/require-hyphen-before-param-description.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ This rule takes one argument. If it is `"always"` then a problem is raised when
88
|---|---|
99
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1010
|Tags|`param`|
11+
|Aliases|`arg`, `argument`|
1112

1213
<!-- assertions requireHyphenBeforeParamDescription -->

.README/rules/require-jsdoc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### `require-jsdoc`
2+
3+
Checks for presence of jsdoc comments, on class declarations as well as
4+
functions.
5+
6+
|||
7+
|---|---|
8+
|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `FunctionDeclaration`, `FunctionExpression`|
9+
|Tags|N/A|
10+
|Settings|`exemptEmptyFunctions`|
11+
12+
<!-- assertions requireJsdoc -->

.README/rules/require-param-description.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Requires that `@param` tag has `description` value.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`param`|
9+
|Aliases|`arg`, `argument`|
910

1011
<!-- assertions requireParamDescription -->

.README/rules/require-param-name.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Requires that all function parameters have name.
1010
|---|---|
1111
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1212
|Tags|`param`|
13+
|Aliases|`arg`, `argument`|
1314

1415
<!-- assertions requireParamName -->

.README/rules/require-param-type.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Requires that `@param` tag has `type` value.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`param`|
9+
|Aliases|`arg`, `argument`|
910

1011
<!-- assertions requireParamType -->

.README/rules/require-param.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ Requires that all function parameters are documented.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`param`|
9+
|Aliases|`arg`, `argument`|
10+
|Settings|`allowOverrideWithoutParam`, `allowImplementsWithoutParam`, `allowAugmentsExtendsWithoutParam`|
911

1012
<!-- assertions requireParam -->

.README/rules/require-returns-check.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Checks if the return expression exists in function body and in the comment.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`returns`|
9+
|Aliases|`return`|
910

1011
<!-- assertions requireReturnsCheck -->

.README/rules/require-returns-description.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Requires that `@returns` tag has `description` value.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`returns`|
9+
|Aliases|`return`|
910

1011
<!-- assertions requireReturnsDescription -->

.README/rules/require-returns-type.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Requires that `@returns` tag has `type` value.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`returns`|
9+
|Aliases|`return`|
910

1011
<!-- assertions requireReturnsType -->

.README/rules/require-returns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ Requires returns are documented.
66
|---|---|
77
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
88
|Tags|`returns`|
9+
|Aliases|`return`|
10+
|Settings|`forceRequireReturn`|
911

1012
<!-- assertions requireReturns -->

.README/rules/valid-types.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The following apply to the above sets:
1717
|||
1818
|---|---|
1919
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
20-
|Tags|`param`, `returns`|
20+
|Tags|
21+
For name only unless otherwise stated: `alias`, `augments`, `borrows`, `callback`, `class` (for name and type), `constant` (for name and type), `enum` (for type), `event`, `external`, `fires`, `function`, `implements` (for type), `interface`, `lends`, `listens`, `member` (for name and type), `memberof`, `memberof!`, `mixes`, `mixin`, `module` (for name and type), `name`, `namespace` (for name and type), `param` (for name and type), `property` (for name and type), `returns` (for type), `this`, `throws` (for type), `type` (for type), `typedef` (for name and type), `yields` (for type)|
22+
|Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
23+
|Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
24+
|Settings|`allowEmptyNamepaths`, `checkSeesForNamepaths`|
2125

2226
<!-- assertions validTypes -->

0 commit comments

Comments
 (0)