agent-docs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/plans/OPTIMISE.md +379 -0
- package/.cursor/plans/VERSIONING.md +207 -0
- package/.cursor/rules/IMPORTANT.mdc +97 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +13 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/.github/dependabot.yml +38 -0
- package/.github/pull_request_template.md +10 -0
- package/.github/workflows/format.yml +35 -0
- package/CODE_OF_CONDUCT.md +64 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE.md +20 -0
- package/PLAN.md +707 -0
- package/README.md +133 -0
- package/SECURITY.md +21 -0
- package/docs/APEXANNOTATIONS.md +472 -0
- package/docs/APEXDOC.md +198 -0
- package/docs/CML.md +877 -0
- package/docs/CODEANALYZER.md +435 -0
- package/docs/CONTEXTDEFINITIONS.md +617 -0
- package/docs/ESLINT.md +827 -0
- package/docs/ESLINTJSDOC.md +520 -0
- package/docs/FIELDSERVICE.md +4452 -0
- package/docs/GRAPHBINARY.md +208 -0
- package/docs/GRAPHENGINE.md +616 -0
- package/docs/GRAPHML.md +337 -0
- package/docs/GRAPHSON.md +302 -0
- package/docs/GREMLIN.md +490 -0
- package/docs/GRYO.md +232 -0
- package/docs/HUSKY.md +106 -0
- package/docs/JEST.md +387 -0
- package/docs/JORJE.md +537 -0
- package/docs/JSDOC.md +621 -0
- package/docs/PMD.md +910 -0
- package/docs/PNPM.md +409 -0
- package/docs/PRETTIER.md +716 -0
- package/docs/PRETTIERAPEX.md +874 -0
- package/docs/REVENUETRANSACTIONMANAGEMENT.md +887 -0
- package/docs/TINKERPOP.md +252 -0
- package/docs/VITEST.md +706 -0
- package/docs/VSCODE.md +231 -0
- package/docs/XPATH31.md +213 -0
- package/package.json +32 -0
- package/postinstall.mjs +51 -0
- package/prettier.config.js +18 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
# ESLint Plugin JSDoc Reference
|
|
2
|
+
|
|
3
|
+
> **Version**: 1.0.0
|
|
4
|
+
|
|
5
|
+
> **Purpose**: JSDoc linting rules for ESLint. Validates syntax, types, params,
|
|
6
|
+
> returns, completeness. **Node**: >=20.11.0 | **ESLint**: ^7.0.0 | ^8.0.0 |
|
|
7
|
+
> ^9.0.0
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev eslint-plugin-jsdoc
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
### Flat Config (ESLint v9) — Procedural (Recommended)
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { jsdoc } from 'eslint-plugin-jsdoc';
|
|
25
|
+
|
|
26
|
+
export default [
|
|
27
|
+
jsdoc({
|
|
28
|
+
config: 'flat/recommended',
|
|
29
|
+
rules: {
|
|
30
|
+
'jsdoc/require-description': 'warn',
|
|
31
|
+
},
|
|
32
|
+
// Uncomment this if you wish your `settings` to overwrite the config's own settings;
|
|
33
|
+
// otherwise, the default behavior is to merge recursively
|
|
34
|
+
// mergeSettings: false,
|
|
35
|
+
settings: {
|
|
36
|
+
// No `jsdoc` child object needed here
|
|
37
|
+
structuredTags: {
|
|
38
|
+
see: { name: 'namepath-referencing', required: ['name'] },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A `plugins` property can also be supplied to merge with the resulting `jsdoc`
|
|
46
|
+
plugin. Other config properties such as `files`, `ignores`, etc. are also copied
|
|
47
|
+
over, though noting that if the specified config produces an array, they will
|
|
48
|
+
not currently function.
|
|
49
|
+
|
|
50
|
+
### Flat Config — Declarative
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
54
|
+
|
|
55
|
+
export default [
|
|
56
|
+
jsdoc.configs['flat/recommended'],
|
|
57
|
+
{
|
|
58
|
+
files: ['**/*.js'],
|
|
59
|
+
plugins: { jsdoc },
|
|
60
|
+
rules: { 'jsdoc/require-description': 'warn' },
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Legacy eslintrc
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
module.exports = {
|
|
69
|
+
plugins: ['jsdoc'],
|
|
70
|
+
extends: ['plugin:jsdoc/recommended'],
|
|
71
|
+
rules: { 'jsdoc/require-description': 'error' },
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Presets
|
|
78
|
+
|
|
79
|
+
### Flat Config Presets
|
|
80
|
+
|
|
81
|
+
| Preset | Description |
|
|
82
|
+
| ------------------------------------------ | --------------------------------------------------------------- |
|
|
83
|
+
| `flat/recommended` | Recommended rules (warnings) |
|
|
84
|
+
| `flat/recommended-error` | Recommended rules (errors) |
|
|
85
|
+
| `flat/recommended-typescript` | TypeScript-aware (warnings) |
|
|
86
|
+
| `flat/recommended-typescript-error` | TypeScript-aware (errors) |
|
|
87
|
+
| `flat/recommended-typescript-flavor` | JS with TS JSDoc flavor (warnings) |
|
|
88
|
+
| `flat/recommended-typescript-flavor-error` | JS with TS JSDoc flavor (errors) |
|
|
89
|
+
| `flat/recommended-mixed` | TS-flavor for `.js/.jsx/.cjs/.mjs`, TS for `.ts/.tsx/.cts/.mts` |
|
|
90
|
+
|
|
91
|
+
### Granular Presets (TypeScript-only)
|
|
92
|
+
|
|
93
|
+
| Category | Presets | Description |
|
|
94
|
+
| ---------------- | ------------------------------------------------------------------------------------- | --------------------- |
|
|
95
|
+
| **Contents** | `flat/contents-typescript[-error]`, `flat/contents-typescript-flavor[-error]` | Names & descriptions |
|
|
96
|
+
| **Logical** | `flat/logical-typescript[-error]`, `flat/logical-typescript-flavor[-error]` | Proper tag values |
|
|
97
|
+
| **Requirements** | `flat/requirements-typescript[-error]`, `flat/requirements-typescript-flavor[-error]` | Tags exist/have types |
|
|
98
|
+
| **Stylistic** | `flat/stylistic-typescript[-error]`, `flat/stylistic-typescript-flavor[-error]` | Consistent formatting |
|
|
99
|
+
|
|
100
|
+
**Excluded from granular configs:**
|
|
101
|
+
|
|
102
|
+
| Category | Rule | Reason |
|
|
103
|
+
| ----------- | --------------------------------------- | ----------------------- |
|
|
104
|
+
| `required` | `require-throws` | Can't enforce all cases |
|
|
105
|
+
| | `require-file-overview` | Too demanding |
|
|
106
|
+
| | `convert-to-jsdoc-comments` | Overly aggressive |
|
|
107
|
+
| `logical` | `no-missing-syntax` | No default options |
|
|
108
|
+
| | `no-restricted-syntax` | No default options |
|
|
109
|
+
| `contents` | `match-name` | No default options |
|
|
110
|
+
| | `require-description` | Too demanding |
|
|
111
|
+
| | `require-description-complete-sentence` | Too demanding |
|
|
112
|
+
| `stylistic` | `check-indentation` | May not be desired |
|
|
113
|
+
| | `sort-tags` | Too project-specific |
|
|
114
|
+
|
|
115
|
+
### eslintrc Presets
|
|
116
|
+
|
|
117
|
+
| Preset | Description |
|
|
118
|
+
| -------------------------------------------------- | ---------------------------------- |
|
|
119
|
+
| `plugin:jsdoc/recommended` | Recommended (warnings) |
|
|
120
|
+
| `plugin:jsdoc/recommended-error` | Recommended (errors) |
|
|
121
|
+
| `plugin:jsdoc/recommended-typescript` | TypeScript-aware (warnings) |
|
|
122
|
+
| `plugin:jsdoc/recommended-typescript-error` | TypeScript-aware (errors) |
|
|
123
|
+
| `plugin:jsdoc/recommended-typescript-flavor` | JS with TS JSDoc flavor (warnings) |
|
|
124
|
+
| `plugin:jsdoc/recommended-typescript-flavor-error` | JS with TS JSDoc flavor (errors) |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Settings
|
|
129
|
+
|
|
130
|
+
| Setting | Type | Default | Description |
|
|
131
|
+
| ----------------------------- | ------- | -------------- | ------------------------------------------------------ |
|
|
132
|
+
| `mode` | string | `'typescript'` | `'typescript'`, `'closure'`, `'jsdoc'`, `'permissive'` |
|
|
133
|
+
| `tagNamePreference` | object | `{}` | Tag name aliases |
|
|
134
|
+
| `preferredTypes` | object | `{}` | Type replacements for `check-types` |
|
|
135
|
+
| `structuredTags` | object | `{}` | Tag structure requirements |
|
|
136
|
+
| `contexts` | array | `[]` | Default contexts for rules |
|
|
137
|
+
| `maxLines` | number | `1` | Max lines before JSDoc block |
|
|
138
|
+
| `minLines` | number | `0` | Min lines before JSDoc block |
|
|
139
|
+
| `ignorePrivate` | boolean | `false` | Skip `@private` blocks |
|
|
140
|
+
| `ignoreInternal` | boolean | `false` | Skip `@internal` blocks |
|
|
141
|
+
| `ignoreReplacesDocs` | boolean | `true` | `@ignore` exempts from require rules |
|
|
142
|
+
| `overrideReplacesDocs` | boolean | `true` | `@override` exempts from require rules |
|
|
143
|
+
| `augmentsExtendsReplacesDocs` | boolean | `false` | `@augments`/`@extends` exempts |
|
|
144
|
+
| `implementsReplacesDocs` | boolean | `false` | `@implements` exempts |
|
|
145
|
+
|
|
146
|
+
### Default Tag Aliases
|
|
147
|
+
|
|
148
|
+
| Preferred | Aliases |
|
|
149
|
+
| -------------- | ---------------------------- |
|
|
150
|
+
| `@abstract` | `@virtual` |
|
|
151
|
+
| `@augments` | `@extends` |
|
|
152
|
+
| `@class` | `@constructor` |
|
|
153
|
+
| `@constant` | `@const` |
|
|
154
|
+
| `@default` | `@defaultvalue` |
|
|
155
|
+
| `@description` | `@desc` |
|
|
156
|
+
| `@external` | `@host` |
|
|
157
|
+
| `@file` | `@fileoverview`, `@overview` |
|
|
158
|
+
| `@fires` | `@emits` |
|
|
159
|
+
| `@function` | `@func`, `@method` |
|
|
160
|
+
| `@member` | `@var` |
|
|
161
|
+
| `@param` | `@arg`, `@argument` |
|
|
162
|
+
| `@property` | `@prop` |
|
|
163
|
+
| `@returns` | `@return` |
|
|
164
|
+
| `@throws` | `@exception` |
|
|
165
|
+
| `@yields` | `@yield` |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Processors
|
|
170
|
+
|
|
171
|
+
Lint JavaScript inside `@example` and default value tags.
|
|
172
|
+
|
|
173
|
+
### Basic Setup
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
import { getJsdocProcessorPlugin } from 'eslint-plugin-jsdoc';
|
|
177
|
+
|
|
178
|
+
export default [
|
|
179
|
+
{
|
|
180
|
+
files: ['**/*.js'],
|
|
181
|
+
plugins: {
|
|
182
|
+
examples: getJsdocProcessorPlugin({
|
|
183
|
+
// checkDefaults: true,
|
|
184
|
+
// checkParams: true,
|
|
185
|
+
// checkProperties: true
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
processor: 'examples/examples',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
files: ['**/*.md/*.js'], // Target @example blocks
|
|
192
|
+
rules: {
|
|
193
|
+
/* rules for examples */
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
files: [
|
|
198
|
+
'**/*.jsdoc-defaults',
|
|
199
|
+
'**/*.jsdoc-params',
|
|
200
|
+
'**/*.jsdoc-properties',
|
|
201
|
+
],
|
|
202
|
+
rules: {
|
|
203
|
+
/* rules for defaults */
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Built-in Configs
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
213
|
+
|
|
214
|
+
export default [
|
|
215
|
+
...jsdoc.configs.examples,
|
|
216
|
+
// ...jsdoc.configs['default-expressions'],
|
|
217
|
+
// ...jsdoc.configs['examples-and-default-expressions'],
|
|
218
|
+
];
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### TypeScript Usage
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
import { getJsdocProcessorPlugin } from 'eslint-plugin-jsdoc';
|
|
225
|
+
import ts, { parser as typescriptEslintParser } from 'typescript-eslint';
|
|
226
|
+
|
|
227
|
+
export default [
|
|
228
|
+
{
|
|
229
|
+
files: ['**/*.ts'],
|
|
230
|
+
languageOptions: { parser: typescriptEslintParser },
|
|
231
|
+
plugins: {
|
|
232
|
+
examples: getJsdocProcessorPlugin({
|
|
233
|
+
parser: typescriptEslintParser,
|
|
234
|
+
matchingFileName: 'dummy.md/*.ts',
|
|
235
|
+
}),
|
|
236
|
+
},
|
|
237
|
+
processor: 'examples/examples',
|
|
238
|
+
},
|
|
239
|
+
...ts.configs.recommended,
|
|
240
|
+
{
|
|
241
|
+
files: ['**/*.md/*.ts'],
|
|
242
|
+
languageOptions: { parser: typescriptEslintParser },
|
|
243
|
+
rules: {
|
|
244
|
+
'no-extra-semi': 'error',
|
|
245
|
+
...ts.configs.disableTypeChecked.rules, // Required due to issue #1377
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Processor Options
|
|
252
|
+
|
|
253
|
+
| Option | Type | Default | Description |
|
|
254
|
+
| ---------------------------- | -------------- | --------------------------------------- | --------------------------------------- |
|
|
255
|
+
| `checkDefaults` | boolean | `false` | Check `@default` tags |
|
|
256
|
+
| `checkExamples` | boolean | `true` | Check `@example` tags |
|
|
257
|
+
| `checkParams` | boolean | `false` | Check `@param [name=default]` |
|
|
258
|
+
| `checkProperties` | boolean | `false` | Check `@property [name=default]` |
|
|
259
|
+
| `captionRequired` | boolean | `false` | Require `<caption>` for `@example` |
|
|
260
|
+
| `paddedIndent` | number | `0` | Spaces to strip from lines |
|
|
261
|
+
| `matchingFileName` | string | `null` | File pattern for `@example` |
|
|
262
|
+
| `matchingFileNameDefaults` | string | `null` | File pattern for `@default` |
|
|
263
|
+
| `matchingFileNameParams` | string | `null` | File pattern for `@param` |
|
|
264
|
+
| `matchingFileNameProperties` | string | `null` | File pattern for `@property` |
|
|
265
|
+
| `exampleCodeRegex` | string/RegExp | `null` | Match example code |
|
|
266
|
+
| `rejectExampleCodeRegex` | string/RegExp | `null` | Reject example code |
|
|
267
|
+
| `allowedLanguagesToProcess` | string[]/false | `['js','ts','javascript','typescript']` | Fenced block languages |
|
|
268
|
+
| `sourceType` | string | `'module'` | `'script'` or `'module'` |
|
|
269
|
+
| `parser` | Parser | `undefined` | Custom parser (e.g., typescript-eslint) |
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Rules
|
|
274
|
+
|
|
275
|
+
**Legend**: ✓ = Recommended | 🔧 = Fixable | TS = TypeScript behavior
|
|
276
|
+
|
|
277
|
+
| ✓ | 🔧 | Rule | Description |
|
|
278
|
+
| :--: | :-: | ----------------------------------------- | ------------------------------------------------------ |
|
|
279
|
+
| ✓ | | `check-access` | Valid `@access` values; no mixing/duplicates |
|
|
280
|
+
| ✓ | 🔧 | `check-alignment` | Valid JSDoc asterisk alignment |
|
|
281
|
+
| | | `check-examples` | @deprecated (ESLint 7 only); use processor |
|
|
282
|
+
| | | `check-indentation` | Valid padding inside blocks |
|
|
283
|
+
| | 🔧 | `check-line-alignment` | Align tag/type/name/description |
|
|
284
|
+
| ✓ | 🔧 | `check-param-names` | Params match function declaration |
|
|
285
|
+
| ✓ | 🔧 | `check-property-names` | No duplicate/invalid properties |
|
|
286
|
+
| | | `check-syntax` | Reports syntax invalid for mode |
|
|
287
|
+
| ✓ | 🔧 | `check-tag-names` | Valid block tag names |
|
|
288
|
+
| | | `check-template-names` | `@template` names are used |
|
|
289
|
+
| ✓ | 🔧 | `check-types` | Reports invalid types |
|
|
290
|
+
| ✓ | | `check-values` | Valid `@version`/`@since`/`@license`/`@author`/`@kind` |
|
|
291
|
+
| | 🔧 | `convert-to-jsdoc-comments` | Convert non-JSDoc to JSDoc |
|
|
292
|
+
| ✓ | 🔧 | `empty-tags` | Tags expected empty have no content |
|
|
293
|
+
| ✓ | 🔧 | `escape-inline-tags` | JSDoc tags in correct positions |
|
|
294
|
+
| ✓ | | `implements-on-classes` | `@implements` only on classes |
|
|
295
|
+
| | | `imports-as-dependencies` | `import()` in deps/devDeps |
|
|
296
|
+
| | | `informative-docs` | No restating attached name |
|
|
297
|
+
| | 🔧 | `lines-before-block` | Min newlines before JSDoc |
|
|
298
|
+
| | | `match-description` | Description matches regex |
|
|
299
|
+
| | 🔧 | `match-name` | Name matches/doesn't match regex |
|
|
300
|
+
| ✓ | 🔧 | `multiline-blocks` | Single/multi-line block control |
|
|
301
|
+
| | 🔧 | `no-bad-blocks` | Multi-line comments must be JSDoc |
|
|
302
|
+
| | 🔧 | `no-blank-block-descriptions` | No empty lines in descriptions |
|
|
303
|
+
| | 🔧 | `no-blank-blocks` | No empty JSDoc blocks |
|
|
304
|
+
| ✓ | 🔧 | `no-defaults` | No defaults on `@param`/`@default` |
|
|
305
|
+
| | | `no-missing-syntax` | Require certain structures |
|
|
306
|
+
| ✓ | 🔧 | `no-multi-asterisks` | No multiple asterisks at line start |
|
|
307
|
+
| | | `no-restricted-syntax` | Forbid certain structures |
|
|
308
|
+
| TS | 🔧 | `no-types` | No types on `@param`/`@returns` (TS redundant) |
|
|
309
|
+
| ✓\* | | `no-undefined-types` | All types must be defined |
|
|
310
|
+
| | 🔧 | `prefer-import-tag` | Prefer `@import` over inline `import()` |
|
|
311
|
+
| ✓ | | `reject-any-type` | No `any` or `*` type |
|
|
312
|
+
| ✓ | | `reject-function-type` | No `Function` type |
|
|
313
|
+
| | 🔧 | `require-asterisk-prefix` | Lines start with `*` |
|
|
314
|
+
| | | `require-description` | Functions have descriptions |
|
|
315
|
+
| | 🔧 | `require-description-complete-sentence` | Complete sentences |
|
|
316
|
+
| | 🔧 | `require-example` | Functions have examples |
|
|
317
|
+
| | | `require-file-overview` | Files have `@file`/`@fileoverview` |
|
|
318
|
+
| | 🔧 | `require-hyphen-before-param-description` | Hyphen before param desc |
|
|
319
|
+
| ✓ | 🔧 | `require-jsdoc` | JSDoc present on functions |
|
|
320
|
+
| | | `require-next-description` | `@next` has description |
|
|
321
|
+
| ✓ | | `require-next-type` | `@next` has type |
|
|
322
|
+
| ✓ | 🔧 | `require-param` | All params documented |
|
|
323
|
+
| ✓ | 🔧 | `require-param-description` | `@param` has description |
|
|
324
|
+
| ✓ | | `require-param-name` | `@param` has name |
|
|
325
|
+
| TS\* | 🔧 | `require-param-type` | `@param` has type |
|
|
326
|
+
| ✓ | 🔧 | `require-property` | `@typedef`/`@namespace` have properties |
|
|
327
|
+
| ✓ | | `require-property-description` | `@property` has description |
|
|
328
|
+
| ✓ | | `require-property-name` | `@property` has name |
|
|
329
|
+
| TS\* | | `require-property-type` | `@property` has type |
|
|
330
|
+
| | | `require-rejects` | Promise rejections documented |
|
|
331
|
+
| ✓ | 🔧 | `require-returns` | Returns documented |
|
|
332
|
+
| ✓ | | `require-returns-check` | Return statement matches `@returns` |
|
|
333
|
+
| ✓ | | `require-returns-description` | `@returns` has description |
|
|
334
|
+
| TS\* | | `require-returns-type` | `@returns` has type |
|
|
335
|
+
| | | `require-tags` | Specific tags present |
|
|
336
|
+
| | | `require-template` | `@template` for type params |
|
|
337
|
+
| | | `require-template-description` | `@template` has description |
|
|
338
|
+
| | | `require-throws` | Throws documented |
|
|
339
|
+
| | | `require-throws-description` | `@throws` has description |
|
|
340
|
+
| ✓ | | `require-throws-type` | `@throws` has type |
|
|
341
|
+
| ✓ | | `require-yields` | Yields documented |
|
|
342
|
+
| ✓ | | `require-yields-check` | Yield statement matches `@yields` |
|
|
343
|
+
| | | `require-yields-description` | `@yields` has description |
|
|
344
|
+
| ✓ | | `require-yields-type` | `@yields` has type |
|
|
345
|
+
| | 🔧 | `sort-tags` | Sort tags by sequence |
|
|
346
|
+
| ✓ | 🔧 | `tag-lines` | Lines before/after/between tags |
|
|
347
|
+
| | 🔧 | `text-escaping` | Auto-escape characters |
|
|
348
|
+
| | 🔧 | `ts-method-signature-style` | Prefer function props or method sigs |
|
|
349
|
+
| ✓ | | `ts-no-empty-object-type` | No empty object type |
|
|
350
|
+
| | 🔧 | `ts-no-unnecessary-template-expression` | No unnecessary template expressions |
|
|
351
|
+
| | 🔧 | `ts-prefer-function-type` | Prefer function types over call sigs |
|
|
352
|
+
| | 🔧 | `type-formatting` | Format JSDoc types (experimental) |
|
|
353
|
+
| ✓ | | `valid-types` | Valid JSDoc/Closure/TS types |
|
|
354
|
+
|
|
355
|
+
**75 rules total**
|
|
356
|
+
|
|
357
|
+
**TS Notes**:
|
|
358
|
+
|
|
359
|
+
- `TS` = On in TS; Off in TS flavor
|
|
360
|
+
- `TS*` = Off in TS; On in TS flavor
|
|
361
|
+
- `✓*` = Off in both TS and TS flavor
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Advanced Features
|
|
366
|
+
|
|
367
|
+
### Contexts (AST Selectors)
|
|
368
|
+
|
|
369
|
+
Rules with `contexts` option use
|
|
370
|
+
[ESLint selectors](https://eslint.org/docs/developer-guide/selectors) (esquery
|
|
371
|
+
expressions).
|
|
372
|
+
|
|
373
|
+
```javascript
|
|
374
|
+
{
|
|
375
|
+
rules: {
|
|
376
|
+
'jsdoc/require-description': ['error', {
|
|
377
|
+
contexts: ['FunctionDeclaration', 'ArrowFunctionExpression']
|
|
378
|
+
}]
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Context object properties**:
|
|
384
|
+
|
|
385
|
+
| Property | Type | Description |
|
|
386
|
+
| ------------------------------------ | ------ | ------------------------------------------------------------ |
|
|
387
|
+
| `context` | string | AST selector string |
|
|
388
|
+
| `comment` | string | JSDoc AST condition (experimental) |
|
|
389
|
+
| `message` | string | Custom message (`no-missing-syntax`, `no-restricted-syntax`) |
|
|
390
|
+
| `minimum` | number | Min occurrences (`no-missing-syntax`) |
|
|
391
|
+
| `inlineCommentBlock`, `minLineCount` | — | (`require-jsdoc` only) |
|
|
392
|
+
|
|
393
|
+
**AST tools**:
|
|
394
|
+
|
|
395
|
+
- [AST Explorer](https://astexplorer.net/) — Visualize JS AST
|
|
396
|
+
- [@es-joy/jsdoccomment demo](https://es-joy.github.io/jsdoccomment/demo/) —
|
|
397
|
+
JSDoc comment AST
|
|
398
|
+
- [jsdoc-type-pratt-parser demo](https://jsdoc-type-pratt-parser.github.io/jsdoc-type-pratt-parser/)
|
|
399
|
+
— Type AST
|
|
400
|
+
|
|
401
|
+
### Custom Forbid Rules
|
|
402
|
+
|
|
403
|
+
Create individual rules for forbidden structures:
|
|
404
|
+
|
|
405
|
+
```javascript
|
|
406
|
+
import { jsdoc } from 'eslint-plugin-jsdoc';
|
|
407
|
+
|
|
408
|
+
export default [
|
|
409
|
+
jsdoc({
|
|
410
|
+
config: 'flat/recommended',
|
|
411
|
+
extraRuleDefinitions: {
|
|
412
|
+
forbid: {
|
|
413
|
+
Any: {
|
|
414
|
+
contexts: [
|
|
415
|
+
{
|
|
416
|
+
comment:
|
|
417
|
+
'JsdocBlock:has(JsdocTypeName[value="any"])',
|
|
418
|
+
context: 'any',
|
|
419
|
+
message: '`any` not allowed',
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
description: 'Forbids `any` usage',
|
|
423
|
+
url: 'https://example.com/any-rule',
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
rules: {
|
|
428
|
+
'jsdoc/forbid-Any': ['error'],
|
|
429
|
+
},
|
|
430
|
+
}),
|
|
431
|
+
];
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Custom Prefer Type Rules
|
|
435
|
+
|
|
436
|
+
Create individual rules for preferred types:
|
|
437
|
+
|
|
438
|
+
```javascript
|
|
439
|
+
import { jsdoc } from 'eslint-plugin-jsdoc';
|
|
440
|
+
|
|
441
|
+
export default [
|
|
442
|
+
jsdoc({
|
|
443
|
+
config: 'flat/recommended',
|
|
444
|
+
extraRuleDefinitions: {
|
|
445
|
+
preferTypes: {
|
|
446
|
+
promise: {
|
|
447
|
+
description: 'Disallows Promise without generic',
|
|
448
|
+
overrideSettings: {
|
|
449
|
+
Promise: {
|
|
450
|
+
message: 'Add generic type for Promise',
|
|
451
|
+
replacement: false,
|
|
452
|
+
unifyParentAndChildTypeChecks: false,
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
url: 'https://example.com/promise-rule',
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
rules: {
|
|
460
|
+
'jsdoc/prefer-type-promise': ['error'],
|
|
461
|
+
},
|
|
462
|
+
}),
|
|
463
|
+
];
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Usage Examples
|
|
469
|
+
|
|
470
|
+
### Basic
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
import { jsdoc } from 'eslint-plugin-jsdoc';
|
|
474
|
+
|
|
475
|
+
export default [jsdoc({ config: 'flat/recommended' })];
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### TypeScript
|
|
479
|
+
|
|
480
|
+
```javascript
|
|
481
|
+
import { jsdoc } from 'eslint-plugin-jsdoc';
|
|
482
|
+
|
|
483
|
+
export default [
|
|
484
|
+
jsdoc({
|
|
485
|
+
config: 'flat/recommended-typescript',
|
|
486
|
+
settings: { mode: 'typescript' },
|
|
487
|
+
}),
|
|
488
|
+
];
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Custom Rules
|
|
492
|
+
|
|
493
|
+
```javascript
|
|
494
|
+
{
|
|
495
|
+
rules: {
|
|
496
|
+
'jsdoc/require-description': ['error', { contexts: ['FunctionDeclaration'] }],
|
|
497
|
+
'jsdoc/require-param': 'warn',
|
|
498
|
+
'jsdoc/require-returns': ['error', { forceRequireReturn: false }],
|
|
499
|
+
'jsdoc/check-types': 'error',
|
|
500
|
+
'jsdoc/check-param-names': 'error',
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Notes
|
|
508
|
+
|
|
509
|
+
- Default mode changed from `'all'` to `'typescript'`
|
|
510
|
+
- Many rules auto-fixable with `--fix`
|
|
511
|
+
- `check-examples` deprecated for ESLint >= 8; use `getJsdocProcessorPlugin`
|
|
512
|
+
- TypeScript type-checked rules must be disabled in examples (issue #1377)
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## Related
|
|
517
|
+
|
|
518
|
+
- [ESLint](ESLINT.md)
|
|
519
|
+
- [JSDoc](JSDOC.md)
|
|
520
|
+
- [GitHub](https://github.com/gajus/eslint-plugin-jsdoc)
|