eslint-plugin-jsdoc 58.1.0 → 59.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/README.md +66 -60
- package/dist/buildForbidRuleDefinition.cjs +0 -1
- package/dist/buildForbidRuleDefinition.cjs.map +1 -1
- package/dist/buildRejectOrPreferRuleDefinition.cjs +7 -2
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
- package/dist/cjs/rules/convertToJsdocComments.d.ts +7 -0
- package/dist/generateDocs.cjs +129 -3
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/generateRule.cjs +3 -1
- package/dist/generateRule.cjs.map +1 -1
- package/dist/generateRuleTypes.cjs +5 -5
- package/dist/generateRuleTypes.cjs.map +1 -1
- package/dist/index-cjs.cjs +30 -0
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +1 -1
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +4 -1
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +1 -1
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +19 -0
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +25 -1
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +62 -1
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +6 -0
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +71 -0
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +16 -1
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +17 -1
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +48 -0
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.d.ts +7 -0
- package/dist/rules/emptyTags.cjs +10 -1
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +15 -1
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +45 -0
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +14 -0
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +129 -0
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +30 -0
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +78 -6
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +11 -2
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +3 -1
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +19 -0
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +22 -2
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +29 -0
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +17 -1
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +17 -1
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +11 -1
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +28 -0
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +30 -1
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +27 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +26 -1
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +61 -0
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +20 -2
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +82 -3
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +213 -1
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +21 -0
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +16 -1
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +21 -1
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +1 -1
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +1 -1
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +54 -1
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +22 -1
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +15 -1
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +15 -1
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +17 -1
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +18 -1
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +50 -1
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +25 -7
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +200 -1
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +32 -2
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +5 -1
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/typeFormatting.cjs +64 -16
- package/dist/rules/typeFormatting.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +8 -1
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/rules.d.ts +2130 -32
- package/package.json +1 -1
- package/src/buildForbidRuleDefinition.js +0 -1
- package/src/buildRejectOrPreferRuleDefinition.js +12 -2
- package/src/index-cjs.js +36 -0
- package/src/index.js +36 -0
- package/src/rules/checkAccess.js +1 -1
- package/src/rules/checkAlignment.js +3 -0
- package/src/rules/checkExamples.js +1 -1
- package/src/rules/checkIndentation.js +19 -0
- package/src/rules/checkLineAlignment.js +24 -0
- package/src/rules/checkParamNames.js +62 -1
- package/src/rules/checkPropertyNames.js +6 -0
- package/src/rules/checkTagNames.js +71 -0
- package/src/rules/checkTypes.js +16 -1
- package/src/rules/checkValues.js +16 -0
- package/src/rules/convertToJsdocComments.js +48 -0
- package/src/rules/emptyTags.js +10 -1
- package/src/rules/implementsOnClasses.js +15 -1
- package/src/rules/informativeDocs.js +45 -0
- package/src/rules/linesBeforeBlock.js +14 -0
- package/src/rules/matchDescription.js +129 -0
- package/src/rules/matchName.js +30 -0
- package/src/rules/multilineBlocks.js +77 -5
- package/src/rules/noBadBlocks.js +11 -2
- package/src/rules/noBlankBlockDescriptions.js +1 -1
- package/src/rules/noBlankBlocks.js +2 -0
- package/src/rules/noDefaults.js +19 -0
- package/src/rules/noMissingSyntax.js +22 -2
- package/src/rules/noMultiAsterisks.js +29 -0
- package/src/rules/noRestrictedSyntax.js +17 -1
- package/src/rules/noTypes.js +17 -1
- package/src/rules/noUndefinedTypes.js +11 -1
- package/src/rules/requireAsteriskPrefix.js +28 -0
- package/src/rules/requireDescription.js +30 -1
- package/src/rules/requireDescriptionCompleteSentence.js +27 -0
- package/src/rules/requireExample.js +26 -1
- package/src/rules/requireFileOverview.js +61 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +19 -1
- package/src/rules/requireJsdoc.js +80 -1
- package/src/rules/requireParam.js +213 -1
- package/src/rules/requireParamDescription.js +21 -0
- package/src/rules/requireParamName.js +16 -1
- package/src/rules/requireParamType.js +21 -1
- package/src/rules/requirePropertyName.js +1 -1
- package/src/rules/requirePropertyType.js +1 -1
- package/src/rules/requireReturns.js +54 -1
- package/src/rules/requireReturnsCheck.js +22 -1
- package/src/rules/requireReturnsDescription.js +15 -1
- package/src/rules/requireReturnsType.js +15 -1
- package/src/rules/requireTemplate.js +17 -1
- package/src/rules/requireThrows.js +18 -1
- package/src/rules/requireYields.js +50 -1
- package/src/rules/requireYieldsCheck.js +25 -7
- package/src/rules/sortTags.js +200 -1
- package/src/rules/tagLines.js +30 -0
- package/src/rules/textEscaping.js +5 -1
- package/src/rules/typeFormatting.js +57 -19
- package/src/rules/validTypes.js +8 -1
- package/src/rules.d.ts +2130 -32
- package/typings/gitdown.d.ts +4 -0
package/README.md
CHANGED
|
@@ -412,63 +412,69 @@ non-default-recommended fixer).
|
|
|
412
412
|
|
|
413
413
|
|recommended|fixable|rule|description|
|
|
414
414
|
|-|-|-|-|
|
|
415
|
-
|:heavy_check_mark:|| [check-access](./docs/rules/check-access.md#readme) |
|
|
416
|
-
|:heavy_check_mark:|:wrench:| [check-alignment](./docs/rules/check-alignment.md#readme)|
|
|
417
|
-
|||[check-examples](./docs/rules/check-examples.md#readme)|
|
|
418
|
-
|||[check-indentation](./docs/rules/check-indentation.md#readme)|
|
|
419
|
-
||:wrench:|[check-line-alignment](./docs/rules/check-line-alignment.md#readme)|Reports invalid alignment of JSDoc block lines
|
|
420
|
-
|:heavy_check_mark:|:wrench:|[check-param-names](./docs/rules/check-param-names.md#readme)|Checks for dupe `@param` names, that nested param names have roots, and that parameter names in function declarations match
|
|
421
|
-
|:heavy_check_mark:|:wrench:|[check-property-names](./docs/rules/check-property-names.md#readme)|
|
|
422
|
-
|||[check-syntax](./docs/rules/check-syntax.md#readme)|Reports
|
|
423
|
-
|:heavy_check_mark:|:wrench:|[check-tag-names](./docs/rules/check-tag-names.md#readme)|Reports invalid
|
|
424
|
-
|
|
425
|
-
|:heavy_check_mark:|:wrench:|[check-types](./docs/rules/check-types.md#readme)|Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements)|
|
|
426
|
-
|:heavy_check_mark:||[check-values](./docs/rules/check-values.md#readme)|
|
|
427
|
-
|
|
428
|
-
|:heavy_check_mark:|:wrench:|[empty-tags](./docs/rules/empty-tags.md#readme)|Checks tags that are expected to be empty (e.g., `@abstract` or `@async`), reporting if they have content|
|
|
429
|
-
|:heavy_check_mark:||[implements-on-classes](./docs/rules/implements-on-classes.md#readme)|Prohibits use of `@implements` on non-constructor functions (to enforce the tag only being used on classes/constructors)|
|
|
430
|
-
|||[
|
|
431
|
-
|||[
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
||:wrench:|[no-
|
|
437
|
-
||:wrench:|[no-blank-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
||:wrench:|[require-
|
|
448
|
-
|||[require-
|
|
449
|
-
||:wrench:|[require-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|:heavy_check_mark
|
|
454
|
-
|
|
455
|
-
|:heavy_check_mark
|
|
456
|
-
|:heavy_check_mark:|:wrench:|[require-
|
|
457
|
-
|:heavy_check_mark
|
|
458
|
-
|:heavy_check_mark:||[require-
|
|
459
|
-
|:heavy_check_mark: (
|
|
460
|
-
|:heavy_check_mark
|
|
461
|
-
|:heavy_check_mark:||[require-
|
|
462
|
-
|:heavy_check_mark:||[require-
|
|
463
|
-
|:heavy_check_mark: (
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|:heavy_check_mark:||[require-
|
|
467
|
-
|:heavy_check_mark
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|||[
|
|
471
|
-
|:heavy_check_mark
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
415
|
+
|:heavy_check_mark:|| [check-access](./docs/rules/check-access.md#readme) | Checks that `@access` tags have a valid value. |
|
|
416
|
+
|:heavy_check_mark:|:wrench:| [check-alignment](./docs/rules/check-alignment.md#readme) | Reports invalid alignment of JSDoc block asterisks. |
|
|
417
|
+
||| [check-examples](./docs/rules/check-examples.md#readme) | Ensures that (JavaScript) samples within `@example` tags adhere to ESLint rules. |
|
|
418
|
+
||| [check-indentation](./docs/rules/check-indentation.md#readme) | Reports invalid padding inside JSDoc blocks. |
|
|
419
|
+
||:wrench:| [check-line-alignment](./docs/rules/check-line-alignment.md#readme) | Reports invalid alignment of JSDoc block lines. |
|
|
420
|
+
|:heavy_check_mark:|:wrench:| [check-param-names](./docs/rules/check-param-names.md#readme) | Checks for dupe `@param` names, that nested param names have roots, and that parameter names in function declarations match JSDoc param names. |
|
|
421
|
+
|:heavy_check_mark:|:wrench:| [check-property-names](./docs/rules/check-property-names.md#readme) | Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots. |
|
|
422
|
+
||| [check-syntax](./docs/rules/check-syntax.md#readme) | Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode). |
|
|
423
|
+
|:heavy_check_mark:|:wrench:| [check-tag-names](./docs/rules/check-tag-names.md#readme) | Reports invalid block tag names. |
|
|
424
|
+
||| [check-template-names](./docs/rules/check-template-names.md#readme) | Checks that any `@template` names are actually used in the connected `@typedef` or type alias. |
|
|
425
|
+
|:heavy_check_mark:|:wrench:| [check-types](./docs/rules/check-types.md#readme) | Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements). |
|
|
426
|
+
|:heavy_check_mark:|| [check-values](./docs/rules/check-values.md#readme) | This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`. |
|
|
427
|
+
||:wrench:| [convert-to-jsdoc-comments](./docs/rules/convert-to-jsdoc-comments.md#readme) | Converts non-JSDoc comments preceding or following nodes into JSDoc ones |
|
|
428
|
+
|:heavy_check_mark:|:wrench:| [empty-tags](./docs/rules/empty-tags.md#readme) | Checks tags that are expected to be empty (e.g., `@abstract` or `@async`), reporting if they have content |
|
|
429
|
+
|:heavy_check_mark:|| [implements-on-classes](./docs/rules/implements-on-classes.md#readme) | Prohibits use of `@implements` on non-constructor functions (to enforce the tag only being used on classes/constructors). |
|
|
430
|
+
||| [imports-as-dependencies](./docs/rules/imports-as-dependencies.md#readme) | Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies` |
|
|
431
|
+
||| [informative-docs](./docs/rules/informative-docs.md#readme) | This rule reports doc comments that only restate their attached name. |
|
|
432
|
+
||:wrench:| [lines-before-block](./docs/rules/lines-before-block.md#readme) | Enforces minimum number of newlines before JSDoc comment blocks |
|
|
433
|
+
||| [match-description](./docs/rules/match-description.md#readme) | Enforces a regular expression pattern on descriptions. |
|
|
434
|
+
||:wrench:| [match-name](./docs/rules/match-name.md#readme) | Reports the name portion of a JSDoc tag if matching or not matching a given regular expression. |
|
|
435
|
+
|:heavy_check_mark:|:wrench:| [multiline-blocks](./docs/rules/multiline-blocks.md#readme) | Controls how and whether JSDoc blocks can be expressed as single or multiple line blocks. |
|
|
436
|
+
||:wrench:| [no-bad-blocks](./docs/rules/no-bad-blocks.md#readme) | This rule checks for multi-line-style comments which fail to meet the criteria of a JSDoc block. |
|
|
437
|
+
||:wrench:| [no-blank-block-descriptions](./docs/rules/no-blank-block-descriptions.md#readme) | If tags are present, this rule will prevent empty lines in the block description. If no tags are present, this rule will prevent extra empty lines in the block description. |
|
|
438
|
+
||:wrench:| [no-blank-blocks](./docs/rules/no-blank-blocks.md#readme) | Removes empty blocks with nothing but possibly line breaks |
|
|
439
|
+
|:heavy_check_mark:|:wrench:| [no-defaults](./docs/rules/no-defaults.md#readme) | This rule reports defaults being used on the relevant portion of `@param` or `@default`. |
|
|
440
|
+
||| [no-missing-syntax](./docs/rules/no-missing-syntax.md#readme) | Reports when certain comment structures are always expected. |
|
|
441
|
+
|:heavy_check_mark:|:wrench:| [no-multi-asterisks](./docs/rules/no-multi-asterisks.md#readme) | Prevents use of multiple asterisks at the beginning of lines. |
|
|
442
|
+
||| [no-restricted-syntax](./docs/rules/no-restricted-syntax.md#readme) | Reports when certain comment structures are present. |
|
|
443
|
+
|On in TS; Off in TS flavor|:wrench:| [no-types](./docs/rules/no-types.md#readme) | This rule reports types being used on `@param` or `@returns` (redundant with TypeScript). |
|
|
444
|
+
|:heavy_check_mark: (Off in TS; Off in TS flavor)|| [no-undefined-types](./docs/rules/no-undefined-types.md#readme) | Besides some expected built-in types, prohibits any types not specified as globals or within `@typedef`. |
|
|
445
|
+
|:heavy_check_mark:|| [reject-any-type](./docs/rules/reject-any-type.md#readme) | Reports use of `any` or `*` type |
|
|
446
|
+
|:heavy_check_mark:|| [reject-function-type](./docs/rules/reject-function-type.md#readme) | Reports use of `Function` type |
|
|
447
|
+
||:wrench:| [require-asterisk-prefix](./docs/rules/require-asterisk-prefix.md#readme) | Requires that each JSDoc line starts with an `*`. |
|
|
448
|
+
||| [require-description](./docs/rules/require-description.md#readme) | Requires that all functions (and potentially other contexts) have a description. |
|
|
449
|
+
||:wrench:| [require-description-complete-sentence](./docs/rules/require-description-complete-sentence.md#readme) | Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences. |
|
|
450
|
+
||:wrench:| [require-example](./docs/rules/require-example.md#readme) | Requires that all functions (and potentially other contexts) have examples. |
|
|
451
|
+
||| [require-file-overview](./docs/rules/require-file-overview.md#readme) | Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file. |
|
|
452
|
+
||:wrench:| [require-hyphen-before-param-description](./docs/rules/require-hyphen-before-param-description.md#readme) | Requires a hyphen before the `@param` description (and optionally before `@property` descriptions). |
|
|
453
|
+
|:heavy_check_mark:|:wrench:| [require-jsdoc](./docs/rules/require-jsdoc.md#readme) | Checks for presence of JSDoc comments, on functions and potentially other contexts (optionally limited to exports). |
|
|
454
|
+
||| [require-next-description](./docs/rules/require-next-description.md#readme) | Requires a description for `@next` tags |
|
|
455
|
+
|:heavy_check_mark:|| [require-next-type](./docs/rules/require-next-type.md#readme) | Requires a type for `@next` tags |
|
|
456
|
+
|:heavy_check_mark:|:wrench:| [require-param](./docs/rules/require-param.md#readme) | Requires that all function parameters are documented with a `@param` tag. |
|
|
457
|
+
|:heavy_check_mark:|:wrench:| [require-param-description](./docs/rules/require-param-description.md#readme) | Requires that each `@param` tag has a `description` value. |
|
|
458
|
+
|:heavy_check_mark:|| [require-param-name](./docs/rules/require-param-name.md#readme) | Requires that all `@param` tags have names. |
|
|
459
|
+
|:heavy_check_mark: (Off in TS; On in TS flavor)|:wrench:| [require-param-type](./docs/rules/require-param-type.md#readme) | Requires that each `@param` tag has a type value (in curly brackets). |
|
|
460
|
+
|:heavy_check_mark:|:wrench:| [require-property](./docs/rules/require-property.md#readme) | Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`. |
|
|
461
|
+
|:heavy_check_mark:|| [require-property-description](./docs/rules/require-property-description.md#readme) | Requires that each `@property` tag has a `description` value. |
|
|
462
|
+
|:heavy_check_mark:|| [require-property-name](./docs/rules/require-property-name.md#readme) | Requires that all `@property` tags have names. |
|
|
463
|
+
|:heavy_check_mark: (Off in TS; On in TS flavor)|| [require-property-type](./docs/rules/require-property-type.md#readme) | Requires that each `@property` tag has a type value (in curly brackets). |
|
|
464
|
+
|:heavy_check_mark:|:wrench:| [require-returns](./docs/rules/require-returns.md#readme) | Requires that returns are documented with `@returns`. |
|
|
465
|
+
|:heavy_check_mark:|| [require-returns-check](./docs/rules/require-returns-check.md#readme) | Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present). |
|
|
466
|
+
|:heavy_check_mark:|| [require-returns-description](./docs/rules/require-returns-description.md#readme) | Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns). |
|
|
467
|
+
|:heavy_check_mark: (Off in TS; On in TS flavor)|| [require-returns-type](./docs/rules/require-returns-type.md#readme) | Requires that `@returns` tag has type value (in curly brackets). |
|
|
468
|
+
||| [require-template](./docs/rules/require-template.md#readme) | Requires `@template` tags be present when type parameters are used. |
|
|
469
|
+
||| [require-throws](./docs/rules/require-throws.md#readme) | Requires that throw statements are documented with `@throws` tags. |
|
|
470
|
+
||| [require-throws-description](./docs/rules/require-throws-description.md#readme) | Requires a description for `@throws` tags |
|
|
471
|
+
|:heavy_check_mark:|| [require-throws-type](./docs/rules/require-throws-type.md#readme) | Requires a type for `@throws` tags |
|
|
472
|
+
|:heavy_check_mark:|| [require-yields](./docs/rules/require-yields.md#readme) | Requires yields are documented with `@yields` tags. |
|
|
473
|
+
|:heavy_check_mark:|| [require-yields-check](./docs/rules/require-yields-check.md#readme) | Ensures that if a `@yields` is present that a `yield` (or `yield` with a value) is present in the function body (or that if a `@next` is present that there is a yield with a return value present). |
|
|
474
|
+
||| [require-yields-description](./docs/rules/require-yields-description.md#readme) | Requires a description for `@yields` tags |
|
|
475
|
+
|:heavy_check_mark:|| [require-yields-type](./docs/rules/require-yields-type.md#readme) | Requires a type for `@yields` tags |
|
|
476
|
+
||:wrench:| [sort-tags](./docs/rules/sort-tags.md#readme) | Sorts tags by a specified sequence according to tag name, optionally adding line breaks between tag groups. |
|
|
477
|
+
|:heavy_check_mark:|:wrench:| [tag-lines](./docs/rules/tag-lines.md#readme) | Enforces lines (or no lines) between tags. |
|
|
478
|
+
||:wrench:| [text-escaping](./docs/rules/text-escaping.md#readme) | Auto-escape certain characters that are input within block and tag descriptions. |
|
|
479
|
+
||:wrench:| [type-formatting](./docs/rules/type-formatting.md#readme) | Formats JSDoc type values. |
|
|
480
|
+
|:heavy_check_mark:|| [valid-types](./docs/rules/valid-types.md#readme) | Requires all types/namepaths to be valid JSDoc, Closure compiler, or TypeScript types (configurable in settings). |
|
|
@@ -59,7 +59,6 @@ const buildForbidRuleDefinition = ({
|
|
|
59
59
|
description: description ?? contextName ?? 'Reports when certain comment structures are present.',
|
|
60
60
|
url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules'
|
|
61
61
|
},
|
|
62
|
-
fixable: 'code',
|
|
63
62
|
schema: [],
|
|
64
63
|
type: 'suggestion'
|
|
65
64
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildForbidRuleDefinition.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","buildForbidRuleDefinition","contextName","contexts","description","url","iterateJsdoc","info","comment","report","utils","contextStr","foundContext","findContext","message","context","contextSelected","meta","docs","
|
|
1
|
+
{"version":3,"file":"buildForbidRuleDefinition.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","buildForbidRuleDefinition","contextName","contexts","description","url","iterateJsdoc","info","comment","report","utils","contextStr","foundContext","findContext","message","context","contextSelected","meta","docs","schema","type","modifyContext","propertyDescriptors","Object","getOwnPropertyDescriptors","create","getPrototypeOf","options","value","nonGlobalSettings","exports"],"sources":["../src/buildForbidRuleDefinition.js"],"sourcesContent":["import iterateJsdoc from './iterateJsdoc.js';\n\n/**\n * @param {{\n * contexts: (string|{\n * comment: string,\n * context: string,\n * message: string\n * })[],\n * description?: string,\n * contextName?: string\n * url?: string,\n * }} cfg\n * @returns {import('@eslint/core').RuleDefinition<\n * import('@eslint/core').RuleDefinitionTypeOptions\n * >}\n */\nexport const buildForbidRuleDefinition = ({\n contextName,\n contexts,\n description,\n url,\n}) => {\n return iterateJsdoc(({\n // context,\n info: {\n comment,\n },\n report,\n utils,\n }) => {\n const {\n contextStr,\n foundContext,\n } = utils.findContext(contexts, comment);\n\n // We are not on the *particular* matching context/comment, so don't assume\n // we need reporting\n if (!foundContext) {\n return;\n }\n\n const message = /** @type {import('./iterateJsdoc.js').ContextObject} */ (\n foundContext\n )?.message ??\n 'Syntax is restricted: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n\n report(message, null, null, comment ? {\n comment,\n context: contextStr,\n } : {\n context: contextStr,\n });\n }, {\n contextSelected: true,\n meta: {\n docs: {\n description: description ?? contextName ?? 'Reports when certain comment structures are present.',\n url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',\n },\n schema: [],\n type: 'suggestion',\n },\n modifyContext: (context) => {\n // Reproduce context object with our own `contexts`\n const propertyDescriptors = Object.getOwnPropertyDescriptors(context);\n return Object.create(\n Object.getPrototypeOf(context),\n {\n ...propertyDescriptors,\n options: {\n ...propertyDescriptors.options,\n value: [\n {\n contexts,\n },\n ],\n },\n },\n );\n },\n nonGlobalSettings: true,\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,yBAAyB,GAAGA,CAAC;EACxCC,WAAW;EACXC,QAAQ;EACRC,WAAW;EACXC;AACF,CAAC,KAAK;EACJ,OAAO,IAAAC,qBAAY,EAAC,CAAC;IACnB;IACAC,IAAI,EAAE;MACJC;IACF,CAAC;IACDC,MAAM;IACNC;EACF,CAAC,KAAK;IACJ,MAAM;MACJC,UAAU;MACVC;IACF,CAAC,GAAGF,KAAK,CAACG,WAAW,CAACV,QAAQ,EAAEK,OAAO,CAAC;;IAExC;IACA;IACA,IAAI,CAACI,YAAY,EAAE;MACjB;IACF;IAEA,MAAME,OAAO,GAAG,wDACdF,YAAY,EACXE,OAAO,IACR,mCAAmC,IAChCN,OAAO,GAAG,mBAAmB,GAAG,EAAE,CAAC;IAExCC,MAAM,CAACK,OAAO,EAAE,IAAI,EAAE,IAAI,EAAEN,OAAO,GAAG;MACpCA,OAAO;MACPO,OAAO,EAAEJ;IACX,CAAC,GAAG;MACFI,OAAO,EAAEJ;IACX,CAAC,CAAC;EACJ,CAAC,EAAE;IACDK,eAAe,EAAE,IAAI;IACrBC,IAAI,EAAE;MACJC,IAAI,EAAE;QACJd,WAAW,EAAEA,WAAW,IAAIF,WAAW,IAAI,sDAAsD;QACjGG,GAAG,EAAEA,GAAG,IAAI;MACd,CAAC;MACDc,MAAM,EAAE,EAAE;MACVC,IAAI,EAAE;IACR,CAAC;IACDC,aAAa,EAAGN,OAAO,IAAK;MAC1B;MACA,MAAMO,mBAAmB,GAAGC,MAAM,CAACC,yBAAyB,CAACT,OAAO,CAAC;MACrE,OAAOQ,MAAM,CAACE,MAAM,CAClBF,MAAM,CAACG,cAAc,CAACX,OAAO,CAAC,EAC9B;QACE,GAAGO,mBAAmB;QACtBK,OAAO,EAAE;UACP,GAAGL,mBAAmB,CAACK,OAAO;UAC9BC,KAAK,EAAE,CACL;YACEzB;UACF,CAAC;QAEL;MACF,CACF,CAAC;IACH,CAAC;IACD0B,iBAAiB,EAAE;EACrB,CAAC,CAAC;AACJ,CAAC;AAACC,OAAA,CAAA7B,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -103,7 +103,7 @@ const infoUC = {
|
|
|
103
103
|
const buildRejectOrPreferRuleDefinition = ({
|
|
104
104
|
checkNativeTypes = null,
|
|
105
105
|
typeName,
|
|
106
|
-
description = typeName ?? 'Reports invalid
|
|
106
|
+
description = typeName ?? 'Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements).',
|
|
107
107
|
overrideSettings = null,
|
|
108
108
|
schema = [],
|
|
109
109
|
url = 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header'
|
|
@@ -339,7 +339,12 @@ const buildRejectOrPreferRuleDefinition = ({
|
|
|
339
339
|
description,
|
|
340
340
|
url
|
|
341
341
|
},
|
|
342
|
-
|
|
342
|
+
...(!overrideSettings || Object.values(overrideSettings).some(os => {
|
|
343
|
+
return os && typeof os === 'object' ? /* c8 ignore next -- Ok */
|
|
344
|
+
os.replacement : typeof os === 'string';
|
|
345
|
+
}) ? {
|
|
346
|
+
fixable: 'code'
|
|
347
|
+
} : {}),
|
|
343
348
|
schema,
|
|
344
349
|
type: 'suggestion'
|
|
345
350
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRejectOrPreferRuleDefinition.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","e","__esModule","default","adjustNames","type","preferred","isGenericMatch","typeNodeName","node","parentNode","ret","parentMeta","meta","brackets","dot","dotBracketEnd","match","slice","length","bracketEnd","endsWith","value","replace","getMessage","upperCase","info","message","replacement","infoUC","buildRejectOrPreferRuleDefinition","checkNativeTypes","typeName","description","overrideSettings","schema","url","iterateJsdoc","context","jsdocNode","report","settings","sourceCode","utils","jsdocTagsWithPossibleType","filterTags","tag","Boolean","tagMightHaveTypePosition","mode","preferredTypes","preferredTypesOriginal","structuredTags","injectObjectPreferredTypes","typeToInject","Object","exemptTagContexts","noDefaults","unifyParentAndChildTypeChecks","options","getPreferredTypeInfo","_type","property","hasMatchingPreferredType","typName","isNameOfGeneric","undefined","checkPostFixes","some","checkPostFix","preferredType","prefType","directNameMatch","values","includes","specificUnify","unifiedSyntaxParentMatch","getInvalidTypes","tagName","nameInTag","idx","invalidTypes","types","preferredSetting","push","nextItem","skipRootChecking","name","startsWith","reportSettings","entries","typs","Array","isArray","jsdocTag","typeAst","tryParse","parse","traverse","fixedType","stringify","fix","fixer","replaceText","getText","badType","msg","tagValue","JSON","iterateAllJsdocs","docs","fixable","exports"],"sources":["../src/buildRejectOrPreferRuleDefinition.js"],"sourcesContent":["import iterateJsdoc from './iterateJsdoc.js';\nimport {\n parse,\n stringify,\n traverse,\n tryParse,\n} from '@es-joy/jsdoccomment';\n\n/**\n * Adjusts the parent type node `meta` for generic matches (or type node\n * `type` for `JsdocTypeAny`) and sets the type node `value`.\n * @param {string} type The actual type\n * @param {string} preferred The preferred type\n * @param {boolean} isGenericMatch\n * @param {string} typeNodeName\n * @param {import('jsdoc-type-pratt-parser').NonRootResult} node\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @returns {void}\n */\nconst adjustNames = (type, preferred, isGenericMatch, typeNodeName, node, parentNode) => {\n let ret = preferred;\n if (isGenericMatch) {\n const parentMeta = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n ).meta;\n if (preferred === '[]') {\n parentMeta.brackets = 'square';\n parentMeta.dot = false;\n ret = 'Array';\n } else {\n const dotBracketEnd = preferred.match(/\\.(?:<>)?$/v);\n if (dotBracketEnd) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = true;\n ret = preferred.slice(0, -dotBracketEnd[0].length);\n } else {\n const bracketEnd = preferred.endsWith('<>');\n if (bracketEnd) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = false;\n ret = preferred.slice(0, -2);\n } else if (\n parentMeta?.brackets === 'square' &&\n (typeNodeName === '[]' || typeNodeName === 'Array')\n ) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = false;\n }\n }\n }\n } else if (type === 'JsdocTypeAny') {\n node.type = 'JsdocTypeName';\n }\n\n /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n node\n ).value = ret.replace(/(?:\\.|<>|\\.<>|\\[\\])$/v, '');\n\n // For bare pseudo-types like `<>`\n if (!ret) {\n /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n node\n ).value = typeNodeName;\n }\n};\n\n/**\n * @param {boolean} [upperCase]\n * @returns {string}\n */\nconst getMessage = (upperCase) => {\n return 'Use object shorthand or index signatures instead of ' +\n '`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`';\n};\n\n/**\n * @type {{\n * message: string,\n * replacement: false\n * }}\n */\nconst info = {\n message: getMessage(),\n replacement: false,\n};\n\n/**\n * @type {{\n * message: string,\n * replacement: false\n * }}\n */\nconst infoUC = {\n message: getMessage(true),\n replacement: false,\n};\n\n/**\n * @param {{\n * checkNativeTypes?: import('./rules/checkTypes.js').CheckNativeTypes|null\n * overrideSettings?: import('./iterateJsdoc.js').Settings['preferredTypes']|null,\n * description?: string,\n * schema?: import('eslint').Rule.RuleMetaData['schema'],\n * typeName?: string,\n * url?: string,\n * }} cfg\n * @returns {import('@eslint/core').RuleDefinition<\n * import('@eslint/core').RuleDefinitionTypeOptions\n * >}\n */\nexport const buildRejectOrPreferRuleDefinition = ({\n checkNativeTypes = null,\n typeName,\n description = typeName ?? 'Reports invalid types.',\n overrideSettings = null,\n schema = [],\n url = 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header',\n}) => {\n return iterateJsdoc(\n ({\n context,\n jsdocNode,\n report,\n settings,\n sourceCode,\n utils,\n }) => {\n const jsdocTagsWithPossibleType = utils.filterTags((tag) => {\n return Boolean(utils.tagMightHaveTypePosition(tag.tag));\n });\n\n const\n /**\n * @type {{\n * preferredTypes: import('./iterateJsdoc.js').PreferredTypes,\n * structuredTags: import('./iterateJsdoc.js').StructuredTags,\n * mode: import('./jsdocUtils.js').ParserMode\n * }}\n */\n {\n mode,\n preferredTypes: preferredTypesOriginal,\n structuredTags,\n } = overrideSettings ? {\n mode: settings.mode,\n preferredTypes: overrideSettings,\n structuredTags: {},\n } : settings;\n\n const injectObjectPreferredTypes = !('Object' in preferredTypesOriginal ||\n 'object' in preferredTypesOriginal ||\n 'object.<>' in preferredTypesOriginal ||\n 'Object.<>' in preferredTypesOriginal ||\n 'object<>' in preferredTypesOriginal);\n\n /** @type {import('./iterateJsdoc.js').PreferredTypes} */\n const typeToInject = mode === 'typescript' ?\n {\n Object: 'object',\n 'object.<>': info,\n 'Object.<>': infoUC,\n 'object<>': info,\n 'Object<>': infoUC,\n } :\n {\n Object: 'object',\n 'object.<>': 'Object<>',\n 'Object.<>': 'Object<>',\n 'object<>': 'Object<>',\n };\n\n /** @type {import('./iterateJsdoc.js').PreferredTypes} */\n const preferredTypes = {\n ...injectObjectPreferredTypes ?\n typeToInject :\n {},\n ...preferredTypesOriginal,\n };\n\n const\n /**\n * @type {{\n * noDefaults: boolean,\n * unifyParentAndChildTypeChecks: boolean,\n * exemptTagContexts: ({\n * tag: string,\n * types: true|string[]\n * })[]\n * }}\n */ {\n exemptTagContexts = [],\n noDefaults,\n unifyParentAndChildTypeChecks,\n } = context.options[0] || {};\n\n /**\n * Gets information about the preferred type: whether there is a matching\n * preferred type, what the type is, and whether it is a match to a generic.\n * @param {string} _type Not currently in use\n * @param {string} typeNodeName\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @param {string|undefined} property\n * @returns {[hasMatchingPreferredType: boolean, typeName: string, isGenericMatch: boolean]}\n */\n const getPreferredTypeInfo = (_type, typeNodeName, parentNode, property) => {\n let hasMatchingPreferredType = false;\n let isGenericMatch = false;\n let typName = typeNodeName;\n\n const isNameOfGeneric = parentNode !== undefined && parentNode.type === 'JsdocTypeGeneric' && property === 'left';\n\n const brackets = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n )?.meta?.brackets;\n const dot = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n )?.meta?.dot;\n\n if (brackets === 'angle') {\n const checkPostFixes = dot ? [\n '.', '.<>',\n ] : [\n '<>',\n ];\n isGenericMatch = checkPostFixes.some((checkPostFix) => {\n const preferredType = preferredTypes?.[typeNodeName + checkPostFix];\n\n // Does `unifyParentAndChildTypeChecks` need to be checked here?\n if (\n (unifyParentAndChildTypeChecks || isNameOfGeneric ||\n /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */\n (typeof preferredType === 'object' &&\n preferredType?.unifyParentAndChildTypeChecks)\n ) &&\n preferredType !== undefined\n ) {\n typName += checkPostFix;\n\n return true;\n }\n\n return false;\n });\n }\n\n if (\n !isGenericMatch && property &&\n /** @type {import('jsdoc-type-pratt-parser').NonRootResult} */ (\n parentNode\n ).type === 'JsdocTypeGeneric'\n ) {\n const checkPostFixes = dot ? [\n '.', '.<>',\n ] : [\n brackets === 'angle' ? '<>' : '[]',\n ];\n\n isGenericMatch = checkPostFixes.some((checkPostFix) => {\n const preferredType = preferredTypes?.[checkPostFix];\n if (\n // Does `unifyParentAndChildTypeChecks` need to be checked here?\n (unifyParentAndChildTypeChecks || isNameOfGeneric ||\n /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */\n (typeof preferredType === 'object' &&\n preferredType?.unifyParentAndChildTypeChecks)) &&\n preferredType !== undefined\n ) {\n typName = checkPostFix;\n\n return true;\n }\n\n return false;\n });\n }\n\n const prefType = preferredTypes?.[typeNodeName];\n const directNameMatch = prefType !== undefined &&\n !Object.values(preferredTypes).includes(typeNodeName);\n const specificUnify = typeof prefType === 'object' &&\n prefType?.unifyParentAndChildTypeChecks;\n const unifiedSyntaxParentMatch = property && directNameMatch && (unifyParentAndChildTypeChecks || specificUnify);\n isGenericMatch = isGenericMatch || Boolean(unifiedSyntaxParentMatch);\n\n hasMatchingPreferredType = isGenericMatch ||\n directNameMatch && !property;\n\n return [\n hasMatchingPreferredType, typName, isGenericMatch,\n ];\n };\n\n /**\n * Collect invalid type info.\n * @param {string} type\n * @param {string} value\n * @param {string} tagName\n * @param {string} nameInTag\n * @param {number} idx\n * @param {string|undefined} property\n * @param {import('jsdoc-type-pratt-parser').NonRootResult} node\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @param {(string|false|undefined)[][]} invalidTypes\n * @returns {void}\n */\n const getInvalidTypes = (type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes) => {\n let typeNodeName = type === 'JsdocTypeAny' ? '*' : value;\n\n const [\n hasMatchingPreferredType,\n typName,\n isGenericMatch,\n ] = getPreferredTypeInfo(type, typeNodeName, parentNode, property);\n\n let preferred;\n let types;\n if (hasMatchingPreferredType) {\n const preferredSetting = preferredTypes[typName];\n typeNodeName = typName === '[]' ? typName : typeNodeName;\n\n if (!preferredSetting) {\n invalidTypes.push([\n typeNodeName,\n ]);\n } else if (typeof preferredSetting === 'string') {\n preferred = preferredSetting;\n invalidTypes.push([\n typeNodeName, preferred,\n ]);\n } else if (preferredSetting && typeof preferredSetting === 'object') {\n const nextItem = preferredSetting.skipRootChecking && jsdocTagsWithPossibleType[idx + 1];\n\n if (!nextItem || !nextItem.name.startsWith(`${nameInTag}.`)) {\n preferred = preferredSetting.replacement;\n invalidTypes.push([\n typeNodeName,\n preferred,\n preferredSetting.message,\n ]);\n }\n } else {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n\n return;\n }\n } else if (Object.entries(structuredTags).some(([\n tag,\n {\n type: typs,\n },\n ]) => {\n types = typs;\n\n return tag === tagName &&\n Array.isArray(types) &&\n !types.includes(typeNodeName);\n })) {\n invalidTypes.push([\n typeNodeName, types,\n ]);\n } else if (checkNativeTypes && !noDefaults && type === 'JsdocTypeName') {\n preferred = checkNativeTypes(\n preferredTypes, typeNodeName, preferred, parentNode, invalidTypes,\n );\n }\n\n // For fixer\n if (preferred) {\n adjustNames(type, preferred, isGenericMatch, typeNodeName, node, parentNode);\n }\n };\n\n for (const [\n idx,\n jsdocTag,\n ] of jsdocTagsWithPossibleType.entries()) {\n /** @type {(string|false|undefined)[][]} */\n const invalidTypes = [];\n let typeAst;\n\n try {\n typeAst = mode === 'permissive' ? tryParse(jsdocTag.type) : parse(jsdocTag.type, mode);\n } catch {\n continue;\n }\n\n const {\n name: nameInTag,\n tag: tagName,\n } = jsdocTag;\n\n traverse(typeAst, (node, parentNode, property) => {\n const {\n type,\n value,\n } =\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult}\n */ (node);\n if (![\n 'JsdocTypeAny', 'JsdocTypeName',\n ].includes(type)) {\n return;\n }\n\n getInvalidTypes(type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes);\n });\n\n if (invalidTypes.length) {\n const fixedType = stringify(typeAst);\n\n /**\n * @type {import('eslint').Rule.ReportFixer}\n */\n const fix = (fixer) => {\n return fixer.replaceText(\n jsdocNode,\n sourceCode.getText(jsdocNode).replace(\n `{${jsdocTag.type}}`,\n `{${fixedType}}`,\n ),\n );\n };\n\n for (const [\n badType,\n preferredType = '',\n msg,\n ] of invalidTypes) {\n const tagValue = jsdocTag.name ? ` \"${jsdocTag.name}\"` : '';\n if (exemptTagContexts.some(({\n tag,\n types,\n }) => {\n return tag === tagName &&\n (types === true || types.includes(jsdocTag.type));\n })) {\n continue;\n }\n\n report(\n msg ||\n `Invalid JSDoc @${tagName}${tagValue} type \"${badType}\"` +\n (preferredType ? '; ' : '.') +\n (preferredType ? `prefer: ${JSON.stringify(preferredType)}.` : ''),\n preferredType ? fix : null,\n jsdocTag,\n msg ? {\n tagName,\n tagValue,\n } : undefined,\n );\n }\n }\n }\n },\n {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description,\n url,\n },\n fixable: 'code',\n schema,\n type: 'suggestion',\n },\n },\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAK8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,WAAW,GAAGA,CAACC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,YAAY,EAAEC,IAAI,EAAEC,UAAU,KAAK;EACvF,IAAIC,GAAG,GAAGL,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","_interopRequireDefault","require","_jsdoccomment","e","__esModule","default","adjustNames","type","preferred","isGenericMatch","typeNodeName","node","parentNode","ret","parentMeta","meta","brackets","dot","dotBracketEnd","match","slice","length","bracketEnd","endsWith","value","replace","getMessage","upperCase","info","message","replacement","infoUC","buildRejectOrPreferRuleDefinition","checkNativeTypes","typeName","description","overrideSettings","schema","url","iterateJsdoc","context","jsdocNode","report","settings","sourceCode","utils","jsdocTagsWithPossibleType","filterTags","tag","Boolean","tagMightHaveTypePosition","mode","preferredTypes","preferredTypesOriginal","structuredTags","injectObjectPreferredTypes","typeToInject","Object","exemptTagContexts","noDefaults","unifyParentAndChildTypeChecks","options","getPreferredTypeInfo","_type","property","hasMatchingPreferredType","typName","isNameOfGeneric","undefined","checkPostFixes","some","checkPostFix","preferredType","prefType","directNameMatch","values","includes","specificUnify","unifiedSyntaxParentMatch","getInvalidTypes","tagName","nameInTag","idx","invalidTypes","types","preferredSetting","push","nextItem","skipRootChecking","name","startsWith","reportSettings","entries","typs","Array","isArray","jsdocTag","typeAst","tryParse","parse","traverse","fixedType","stringify","fix","fixer","replaceText","getText","badType","msg","tagValue","JSON","iterateAllJsdocs","docs","os","fixable","exports"],"sources":["../src/buildRejectOrPreferRuleDefinition.js"],"sourcesContent":["import iterateJsdoc from './iterateJsdoc.js';\nimport {\n parse,\n stringify,\n traverse,\n tryParse,\n} from '@es-joy/jsdoccomment';\n\n/**\n * Adjusts the parent type node `meta` for generic matches (or type node\n * `type` for `JsdocTypeAny`) and sets the type node `value`.\n * @param {string} type The actual type\n * @param {string} preferred The preferred type\n * @param {boolean} isGenericMatch\n * @param {string} typeNodeName\n * @param {import('jsdoc-type-pratt-parser').NonRootResult} node\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @returns {void}\n */\nconst adjustNames = (type, preferred, isGenericMatch, typeNodeName, node, parentNode) => {\n let ret = preferred;\n if (isGenericMatch) {\n const parentMeta = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n ).meta;\n if (preferred === '[]') {\n parentMeta.brackets = 'square';\n parentMeta.dot = false;\n ret = 'Array';\n } else {\n const dotBracketEnd = preferred.match(/\\.(?:<>)?$/v);\n if (dotBracketEnd) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = true;\n ret = preferred.slice(0, -dotBracketEnd[0].length);\n } else {\n const bracketEnd = preferred.endsWith('<>');\n if (bracketEnd) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = false;\n ret = preferred.slice(0, -2);\n } else if (\n parentMeta?.brackets === 'square' &&\n (typeNodeName === '[]' || typeNodeName === 'Array')\n ) {\n parentMeta.brackets = 'angle';\n parentMeta.dot = false;\n }\n }\n }\n } else if (type === 'JsdocTypeAny') {\n node.type = 'JsdocTypeName';\n }\n\n /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n node\n ).value = ret.replace(/(?:\\.|<>|\\.<>|\\[\\])$/v, '');\n\n // For bare pseudo-types like `<>`\n if (!ret) {\n /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n node\n ).value = typeNodeName;\n }\n};\n\n/**\n * @param {boolean} [upperCase]\n * @returns {string}\n */\nconst getMessage = (upperCase) => {\n return 'Use object shorthand or index signatures instead of ' +\n '`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`';\n};\n\n/**\n * @type {{\n * message: string,\n * replacement: false\n * }}\n */\nconst info = {\n message: getMessage(),\n replacement: false,\n};\n\n/**\n * @type {{\n * message: string,\n * replacement: false\n * }}\n */\nconst infoUC = {\n message: getMessage(true),\n replacement: false,\n};\n\n/**\n * @param {{\n * checkNativeTypes?: import('./rules/checkTypes.js').CheckNativeTypes|null\n * overrideSettings?: import('./iterateJsdoc.js').Settings['preferredTypes']|null,\n * description?: string,\n * schema?: import('eslint').Rule.RuleMetaData['schema'],\n * typeName?: string,\n * url?: string,\n * }} cfg\n * @returns {import('@eslint/core').RuleDefinition<\n * import('@eslint/core').RuleDefinitionTypeOptions\n * >}\n */\nexport const buildRejectOrPreferRuleDefinition = ({\n checkNativeTypes = null,\n typeName,\n description = typeName ?? 'Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements).',\n overrideSettings = null,\n schema = [],\n url = 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header',\n}) => {\n return iterateJsdoc(\n ({\n context,\n jsdocNode,\n report,\n settings,\n sourceCode,\n utils,\n }) => {\n const jsdocTagsWithPossibleType = utils.filterTags((tag) => {\n return Boolean(utils.tagMightHaveTypePosition(tag.tag));\n });\n\n const\n /**\n * @type {{\n * preferredTypes: import('./iterateJsdoc.js').PreferredTypes,\n * structuredTags: import('./iterateJsdoc.js').StructuredTags,\n * mode: import('./jsdocUtils.js').ParserMode\n * }}\n */\n {\n mode,\n preferredTypes: preferredTypesOriginal,\n structuredTags,\n } = overrideSettings ? {\n mode: settings.mode,\n preferredTypes: overrideSettings,\n structuredTags: {},\n } : settings;\n\n const injectObjectPreferredTypes = !('Object' in preferredTypesOriginal ||\n 'object' in preferredTypesOriginal ||\n 'object.<>' in preferredTypesOriginal ||\n 'Object.<>' in preferredTypesOriginal ||\n 'object<>' in preferredTypesOriginal);\n\n /** @type {import('./iterateJsdoc.js').PreferredTypes} */\n const typeToInject = mode === 'typescript' ?\n {\n Object: 'object',\n 'object.<>': info,\n 'Object.<>': infoUC,\n 'object<>': info,\n 'Object<>': infoUC,\n } :\n {\n Object: 'object',\n 'object.<>': 'Object<>',\n 'Object.<>': 'Object<>',\n 'object<>': 'Object<>',\n };\n\n /** @type {import('./iterateJsdoc.js').PreferredTypes} */\n const preferredTypes = {\n ...injectObjectPreferredTypes ?\n typeToInject :\n {},\n ...preferredTypesOriginal,\n };\n\n const\n /**\n * @type {{\n * noDefaults: boolean,\n * unifyParentAndChildTypeChecks: boolean,\n * exemptTagContexts: ({\n * tag: string,\n * types: true|string[]\n * })[]\n * }}\n */ {\n exemptTagContexts = [],\n noDefaults,\n unifyParentAndChildTypeChecks,\n } = context.options[0] || {};\n\n /**\n * Gets information about the preferred type: whether there is a matching\n * preferred type, what the type is, and whether it is a match to a generic.\n * @param {string} _type Not currently in use\n * @param {string} typeNodeName\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @param {string|undefined} property\n * @returns {[hasMatchingPreferredType: boolean, typeName: string, isGenericMatch: boolean]}\n */\n const getPreferredTypeInfo = (_type, typeNodeName, parentNode, property) => {\n let hasMatchingPreferredType = false;\n let isGenericMatch = false;\n let typName = typeNodeName;\n\n const isNameOfGeneric = parentNode !== undefined && parentNode.type === 'JsdocTypeGeneric' && property === 'left';\n\n const brackets = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n )?.meta?.brackets;\n const dot = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (\n parentNode\n )?.meta?.dot;\n\n if (brackets === 'angle') {\n const checkPostFixes = dot ? [\n '.', '.<>',\n ] : [\n '<>',\n ];\n isGenericMatch = checkPostFixes.some((checkPostFix) => {\n const preferredType = preferredTypes?.[typeNodeName + checkPostFix];\n\n // Does `unifyParentAndChildTypeChecks` need to be checked here?\n if (\n (unifyParentAndChildTypeChecks || isNameOfGeneric ||\n /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */\n (typeof preferredType === 'object' &&\n preferredType?.unifyParentAndChildTypeChecks)\n ) &&\n preferredType !== undefined\n ) {\n typName += checkPostFix;\n\n return true;\n }\n\n return false;\n });\n }\n\n if (\n !isGenericMatch && property &&\n /** @type {import('jsdoc-type-pratt-parser').NonRootResult} */ (\n parentNode\n ).type === 'JsdocTypeGeneric'\n ) {\n const checkPostFixes = dot ? [\n '.', '.<>',\n ] : [\n brackets === 'angle' ? '<>' : '[]',\n ];\n\n isGenericMatch = checkPostFixes.some((checkPostFix) => {\n const preferredType = preferredTypes?.[checkPostFix];\n if (\n // Does `unifyParentAndChildTypeChecks` need to be checked here?\n (unifyParentAndChildTypeChecks || isNameOfGeneric ||\n /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */\n (typeof preferredType === 'object' &&\n preferredType?.unifyParentAndChildTypeChecks)) &&\n preferredType !== undefined\n ) {\n typName = checkPostFix;\n\n return true;\n }\n\n return false;\n });\n }\n\n const prefType = preferredTypes?.[typeNodeName];\n const directNameMatch = prefType !== undefined &&\n !Object.values(preferredTypes).includes(typeNodeName);\n const specificUnify = typeof prefType === 'object' &&\n prefType?.unifyParentAndChildTypeChecks;\n const unifiedSyntaxParentMatch = property && directNameMatch && (unifyParentAndChildTypeChecks || specificUnify);\n isGenericMatch = isGenericMatch || Boolean(unifiedSyntaxParentMatch);\n\n hasMatchingPreferredType = isGenericMatch ||\n directNameMatch && !property;\n\n return [\n hasMatchingPreferredType, typName, isGenericMatch,\n ];\n };\n\n /**\n * Collect invalid type info.\n * @param {string} type\n * @param {string} value\n * @param {string} tagName\n * @param {string} nameInTag\n * @param {number} idx\n * @param {string|undefined} property\n * @param {import('jsdoc-type-pratt-parser').NonRootResult} node\n * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode\n * @param {(string|false|undefined)[][]} invalidTypes\n * @returns {void}\n */\n const getInvalidTypes = (type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes) => {\n let typeNodeName = type === 'JsdocTypeAny' ? '*' : value;\n\n const [\n hasMatchingPreferredType,\n typName,\n isGenericMatch,\n ] = getPreferredTypeInfo(type, typeNodeName, parentNode, property);\n\n let preferred;\n let types;\n if (hasMatchingPreferredType) {\n const preferredSetting = preferredTypes[typName];\n typeNodeName = typName === '[]' ? typName : typeNodeName;\n\n if (!preferredSetting) {\n invalidTypes.push([\n typeNodeName,\n ]);\n } else if (typeof preferredSetting === 'string') {\n preferred = preferredSetting;\n invalidTypes.push([\n typeNodeName, preferred,\n ]);\n } else if (preferredSetting && typeof preferredSetting === 'object') {\n const nextItem = preferredSetting.skipRootChecking && jsdocTagsWithPossibleType[idx + 1];\n\n if (!nextItem || !nextItem.name.startsWith(`${nameInTag}.`)) {\n preferred = preferredSetting.replacement;\n invalidTypes.push([\n typeNodeName,\n preferred,\n preferredSetting.message,\n ]);\n }\n } else {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n\n return;\n }\n } else if (Object.entries(structuredTags).some(([\n tag,\n {\n type: typs,\n },\n ]) => {\n types = typs;\n\n return tag === tagName &&\n Array.isArray(types) &&\n !types.includes(typeNodeName);\n })) {\n invalidTypes.push([\n typeNodeName, types,\n ]);\n } else if (checkNativeTypes && !noDefaults && type === 'JsdocTypeName') {\n preferred = checkNativeTypes(\n preferredTypes, typeNodeName, preferred, parentNode, invalidTypes,\n );\n }\n\n // For fixer\n if (preferred) {\n adjustNames(type, preferred, isGenericMatch, typeNodeName, node, parentNode);\n }\n };\n\n for (const [\n idx,\n jsdocTag,\n ] of jsdocTagsWithPossibleType.entries()) {\n /** @type {(string|false|undefined)[][]} */\n const invalidTypes = [];\n let typeAst;\n\n try {\n typeAst = mode === 'permissive' ? tryParse(jsdocTag.type) : parse(jsdocTag.type, mode);\n } catch {\n continue;\n }\n\n const {\n name: nameInTag,\n tag: tagName,\n } = jsdocTag;\n\n traverse(typeAst, (node, parentNode, property) => {\n const {\n type,\n value,\n } =\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult}\n */ (node);\n if (![\n 'JsdocTypeAny', 'JsdocTypeName',\n ].includes(type)) {\n return;\n }\n\n getInvalidTypes(type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes);\n });\n\n if (invalidTypes.length) {\n const fixedType = stringify(typeAst);\n\n /**\n * @type {import('eslint').Rule.ReportFixer}\n */\n const fix = (fixer) => {\n return fixer.replaceText(\n jsdocNode,\n sourceCode.getText(jsdocNode).replace(\n `{${jsdocTag.type}}`,\n `{${fixedType}}`,\n ),\n );\n };\n\n for (const [\n badType,\n preferredType = '',\n msg,\n ] of invalidTypes) {\n const tagValue = jsdocTag.name ? ` \"${jsdocTag.name}\"` : '';\n if (exemptTagContexts.some(({\n tag,\n types,\n }) => {\n return tag === tagName &&\n (types === true || types.includes(jsdocTag.type));\n })) {\n continue;\n }\n\n report(\n msg ||\n `Invalid JSDoc @${tagName}${tagValue} type \"${badType}\"` +\n (preferredType ? '; ' : '.') +\n (preferredType ? `prefer: ${JSON.stringify(preferredType)}.` : ''),\n preferredType ? fix : null,\n jsdocTag,\n msg ? {\n tagName,\n tagValue,\n } : undefined,\n );\n }\n }\n }\n },\n {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description,\n url,\n },\n ...(!overrideSettings || (Object.values(overrideSettings).some((os) => {\n return os && typeof os === 'object' ?\n /* c8 ignore next -- Ok */\n os.replacement :\n typeof os === 'string';\n })) ?\n {\n fixable: 'code',\n } :\n {}\n ),\n schema,\n type: 'suggestion',\n },\n },\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAK8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,WAAW,GAAGA,CAACC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,YAAY,EAAEC,IAAI,EAAEC,UAAU,KAAK;EACvF,IAAIC,GAAG,GAAGL,SAAS;EACnB,IAAIC,cAAc,EAAE;IAClB,MAAMK,UAAU,GAAG,8DACjBF,UAAU,CACVG,IAAI;IACN,IAAIP,SAAS,KAAK,IAAI,EAAE;MACtBM,UAAU,CAACE,QAAQ,GAAG,QAAQ;MAC9BF,UAAU,CAACG,GAAG,GAAG,KAAK;MACtBJ,GAAG,GAAG,OAAO;IACf,CAAC,MAAM;MACL,MAAMK,aAAa,GAAGV,SAAS,CAACW,KAAK,CAAC,aAAa,CAAC;MACpD,IAAID,aAAa,EAAE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CAACY,IAAI,CAAC,CAAC;YAC1BtB,GAAG;YACHoC;UACF,CAAC,KAAK;YACJ,OAAOpC,GAAG,KAAKgC,OAAO,KACnBI,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACR,QAAQ,CAACoB,QAAQ,CAACzF,IAAI,CAAC,CAAC;UACrD,CAAC,CAAC,EAAE;YACF;UACF;UAEAmC,MAAM,CACJkE,GAAG,IACD,kBAAkB5B,OAAO,GAAG6B,QAAQ,UAAUF,OAAO,GAAG,IACvDnC,aAAa,GAAG,IAAI,GAAG,GAAG,CAAC,IAC3BA,aAAa,GAAG,WAAWsC,IAAI,CAACR,SAAS,CAAC9B,aAAa,CAAC,GAAG,GAAG,EAAE,CAAC,EACpEA,aAAa,GAAG+B,GAAG,GAAG,IAAI,EAC1BP,QAAQ,EACRY,GAAG,GAAG;YACJ5B,OAAO;YACP6B;UACF,CAAC,GAAGzC,SACN,CAAC;QACH;MACF;IACF;EACF,CAAC,EACD;IACE2C,gBAAgB,EAAE,IAAI;IACtBhG,IAAI,EAAE;MACJiG,IAAI,EAAE;QACJ7E,WAAW;QACXG;MACF,CAAC;MACD,IAAI,CAACF,gBAAgB,IAAKqB,MAAM,CAACkB,MAAM,CAACvC,gBAAgB,CAAC,CAACkC,IAAI,CAAE2C,EAAE,IAAK;QACrE,OAAOA,EAAE,IAAI,OAAOA,EAAE,KAAK,QAAQ,GACjC;QACAA,EAAE,CAACnF,WAAW,GACd,OAAOmF,EAAE,KAAK,QAAQ;MAC1B,CAAC,CAAE,GACD;QACEC,OAAO,EAAE;MACX,CAAC,GACD,CAAC,CAAC,CACH;MACD7E,MAAM;MACN9B,IAAI,EAAE;IACR;EACF,CACF,CAAC;AACH,CAAC;AAAC4G,OAAA,CAAAnF,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -163,12 +163,14 @@ declare const _default: {
|
|
|
163
163
|
additionalProperties: false;
|
|
164
164
|
properties: {
|
|
165
165
|
allowedPrefixes: {
|
|
166
|
+
description: string;
|
|
166
167
|
items: {
|
|
167
168
|
type: "string";
|
|
168
169
|
};
|
|
169
170
|
type: "array";
|
|
170
171
|
};
|
|
171
172
|
contexts: {
|
|
173
|
+
description: string;
|
|
172
174
|
items: {
|
|
173
175
|
anyOf: ({
|
|
174
176
|
type: "string";
|
|
@@ -190,6 +192,7 @@ declare const _default: {
|
|
|
190
192
|
type: "array";
|
|
191
193
|
};
|
|
192
194
|
contextsAfter: {
|
|
195
|
+
description: string;
|
|
193
196
|
items: {
|
|
194
197
|
anyOf: ({
|
|
195
198
|
type: "string";
|
|
@@ -211,6 +214,7 @@ declare const _default: {
|
|
|
211
214
|
type: "array";
|
|
212
215
|
};
|
|
213
216
|
contextsBeforeAndAfter: {
|
|
217
|
+
description: string;
|
|
214
218
|
items: {
|
|
215
219
|
anyOf: ({
|
|
216
220
|
type: "string";
|
|
@@ -232,13 +236,16 @@ declare const _default: {
|
|
|
232
236
|
type: "array";
|
|
233
237
|
};
|
|
234
238
|
enableFixer: {
|
|
239
|
+
description: string;
|
|
235
240
|
type: "boolean";
|
|
236
241
|
};
|
|
237
242
|
enforceJsdocLineStyle: {
|
|
243
|
+
description: string;
|
|
238
244
|
enum: string[];
|
|
239
245
|
type: "string";
|
|
240
246
|
};
|
|
241
247
|
lineOrBlockStyle: {
|
|
248
|
+
description: string;
|
|
242
249
|
enum: string[];
|
|
243
250
|
type: "string";
|
|
244
251
|
};
|
package/dist/generateDocs.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _index = _interopRequireDefault(require("../index.cjs"));
|
|
7
8
|
var _decamelize = _interopRequireDefault(require("decamelize"));
|
|
8
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
10
|
var _gitdown = _interopRequireDefault(require("gitdown"));
|
|
@@ -15,6 +16,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
15
16
|
*/
|
|
16
17
|
const dirname = __dirname;
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} str
|
|
21
|
+
*/
|
|
22
|
+
const escapeDescription = str => {
|
|
23
|
+
return str.replaceAll(/(?<!`|\* +|'|\/\/ )@\w+/gv, '<code>$&</code>');
|
|
24
|
+
};
|
|
25
|
+
|
|
18
26
|
/**
|
|
19
27
|
* @param {string} code
|
|
20
28
|
* @returns {string}
|
|
@@ -109,11 +117,37 @@ const generateDocs = async () => {
|
|
|
109
117
|
assertionNames,
|
|
110
118
|
assertions
|
|
111
119
|
} = await getAssertions();
|
|
120
|
+
|
|
121
|
+
/** @type {import('json-schema').JSONSchema4[][]} */
|
|
122
|
+
const schemas = [];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @type {{
|
|
126
|
+
* decamelized: string,
|
|
127
|
+
* row: string
|
|
128
|
+
* }[]}
|
|
129
|
+
*/
|
|
130
|
+
const tableRows = [];
|
|
112
131
|
const docContents = await Promise.all([...assertionNames.map(assertionName => {
|
|
113
|
-
|
|
132
|
+
const decamelized = (0, _decamelize.default)(assertionName, {
|
|
114
133
|
separator: '-'
|
|
115
|
-
})
|
|
116
|
-
|
|
134
|
+
});
|
|
135
|
+
schemas.push(/** @type {import('json-schema').JSONSchema4[]} */
|
|
136
|
+
_index.default.rules?.[decamelized].meta?.schema);
|
|
137
|
+
const ruleDescription = _index.default.rules?.[decamelized]?.meta?.docs?.description;
|
|
138
|
+
if (!ruleDescription) {
|
|
139
|
+
throw new Error(`Rule ${assertionName} missing description`);
|
|
140
|
+
}
|
|
141
|
+
const fixable = _index.default.rules?.[decamelized]?.meta?.fixable ?? null;
|
|
142
|
+
const recommended = _index.default.configs['flat/recommended'].rules?.['jsdoc/' + decamelized] !== 'off';
|
|
143
|
+
const tsRecommended = _index.default.configs['flat/recommended-typescript'].rules?.['jsdoc/' + decamelized] !== 'off';
|
|
144
|
+
const tsRecommendedFlavor = _index.default.configs['flat/recommended-typescript-flavor'].rules?.['jsdoc/' + decamelized] !== 'off';
|
|
145
|
+
tableRows.push({
|
|
146
|
+
decamelized,
|
|
147
|
+
row: `|${recommended ? tsRecommended && tsRecommendedFlavor ? ':heavy_check_mark:' : ':heavy_check_mark: (' + (tsRecommended ? 'On in TS' : 'Off in TS') + '; ' + (tsRecommendedFlavor ? 'On in TS flavor' : 'Off in TS flavor') + ')' : tsRecommended || tsRecommendedFlavor ? (tsRecommended ? 'On in TS' : 'Off in TS') + '; ' + (tsRecommendedFlavor ? 'On in TS flavor' : 'Off in TS flavor') : ''}|${fixable ? ':wrench:' : ''}| [${decamelized}](./docs/rules/${decamelized}.md#readme) | ${ruleDescription} |`
|
|
148
|
+
});
|
|
149
|
+
return _path.default.join(dirname, '..', '..', '.README', 'rules', decamelized + '.md');
|
|
150
|
+
}), ...otherPaths].map(async (docPath, idx) => {
|
|
117
151
|
const gitdown = await _gitdown.default.readFile(docPath);
|
|
118
152
|
gitdown.setConfig({
|
|
119
153
|
gitinfo: {
|
|
@@ -121,6 +155,98 @@ const generateDocs = async () => {
|
|
|
121
155
|
gitPath: _path.default.join(dirname, '../../.git')
|
|
122
156
|
}
|
|
123
157
|
});
|
|
158
|
+
gitdown.registerHelper('rules-table', {
|
|
159
|
+
compile() {
|
|
160
|
+
return tableRows.toSorted(({
|
|
161
|
+
decamelized
|
|
162
|
+
}, {
|
|
163
|
+
decamelized: dc
|
|
164
|
+
}) => {
|
|
165
|
+
return decamelized < dc ? -1 : decamelized > dc ? 1 : 0;
|
|
166
|
+
}).map(({
|
|
167
|
+
row
|
|
168
|
+
}) => {
|
|
169
|
+
return row;
|
|
170
|
+
}).join('\n');
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
gitdown.registerHelper('options', {
|
|
174
|
+
compile() {
|
|
175
|
+
if (!schemas[idx]) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @param {import('json-schema').JSONSchema4} schema
|
|
181
|
+
* @param {number} jIdx
|
|
182
|
+
* @param {import('json-schema').JSONSchema4[]} arr
|
|
183
|
+
* @param {number} [nesting]
|
|
184
|
+
*/
|
|
185
|
+
const convertFromSchema = (schema, jIdx, arr, nesting = 3) => {
|
|
186
|
+
let ret = '';
|
|
187
|
+
switch (schema.type) {
|
|
188
|
+
case 'array':
|
|
189
|
+
ret += convertFromSchema(/** @type {import('json-schema').JSONSchema4} */schema.items, 0, [], nesting + 1);
|
|
190
|
+
break;
|
|
191
|
+
case 'object':
|
|
192
|
+
if (!schema.properties) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
if (jIdx === 0) {
|
|
196
|
+
ret += (arr.length <= 1 ? 'A single' : 'An') + ' options object has the following properties.\n\n';
|
|
197
|
+
} else {
|
|
198
|
+
ret += '\n\nThe next option is an object with the following properties.\n\n';
|
|
199
|
+
}
|
|
200
|
+
if (schema.description) {
|
|
201
|
+
ret += `${escapeDescription(schema.description)}\n`;
|
|
202
|
+
}
|
|
203
|
+
for (const [property, innerSchema] of Object.entries(schema.properties)) {
|
|
204
|
+
const {
|
|
205
|
+
description,
|
|
206
|
+
type
|
|
207
|
+
} = innerSchema;
|
|
208
|
+
if (!description) {
|
|
209
|
+
throw new Error('Missing description for property ' + property + ' for rule ' + assertionNames[idx] + ' with schema ' + JSON.stringify(innerSchema));
|
|
210
|
+
}
|
|
211
|
+
ret += '#'.repeat(nesting) + ` \`${property}\`
|
|
212
|
+
|
|
213
|
+
${type === 'object' && innerSchema.properties ? '' : escapeDescription(description)}
|
|
214
|
+
`;
|
|
215
|
+
if (type === 'object' || type === 'array') {
|
|
216
|
+
ret += convertFromSchema(innerSchema, 0, [], nesting + 1);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case 'string':
|
|
221
|
+
if (jIdx !== 0) {
|
|
222
|
+
throw new Error('Unexpected string schema');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// If a simple string, should be documented by parent
|
|
226
|
+
if (schema.enum) {
|
|
227
|
+
ret += 'The first option is a string with the following possible values: ';
|
|
228
|
+
ret += schema.enum?.map(val => {
|
|
229
|
+
return `"${val}"`;
|
|
230
|
+
}).join(', ') + '.\n';
|
|
231
|
+
}
|
|
232
|
+
if (schema.description) {
|
|
233
|
+
ret += escapeDescription(schema.description);
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
// Describe on parent object
|
|
238
|
+
if (schema.anyOf) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
throw new Error('Unrecognized type ' + schema.type + ' for schema: ' + JSON.stringify(schema));
|
|
242
|
+
}
|
|
243
|
+
return ret;
|
|
244
|
+
};
|
|
245
|
+
return schemas[idx].map((schema, jIdx, arr) => {
|
|
246
|
+
return convertFromSchema(schema, jIdx, arr);
|
|
247
|
+
}).join('');
|
|
248
|
+
}
|
|
249
|
+
});
|
|
124
250
|
return gitdown.get();
|
|
125
251
|
}));
|
|
126
252
|
return docContents.map(docContent => {
|