Skip to content

Commit e67e474

Browse files
authored
feat: add name-defining role for likes of typedef as distinct from likes of param (#1551)
* feat: updates jsdoccomment and devDeps. * feat: add `name-defining` role for likes of `typedef` as distinct from likes of `param` Also: - chore: updates jsdoccomment with reserved word checks on types and liberalized handling on namepaths
1 parent 622b17e commit e67e474

15 files changed

+454
-268
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ types for a tag, the function will silently ignore that tag, leaving it to
4040
the `valid-types` rule to report parsing errors.
4141

4242
If you define your own tags, you can use `settings.jsdoc.structuredTags`
43-
to indicate that a tag's `name` is "namepath-defining" (and should prevent
43+
to indicate that a tag's `name` is "name-defining" or "namepath-defining" (and should prevent
4444
reporting on use of that namepath elsewhere) and/or that a tag's `type` is
4545
`false` (and should not be checked for types). If the `type` is an array, that
4646
array's items will be considered as defined for the purposes of that tag.

.README/settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ values are objects with the following optional properties:
315315
name position (non-whitespace immediately after the tag and whitespace),
316316
e.g., in `@throws This is an error`, "This" would normally be the name,
317317
but "text" allows non-name text here also. This is the default.
318+
- `"name-defining"` - Indicates the tag adds a name to definitions. May not be an arbitrary namepath, unlike `"namepath-defining"`
318319
- `"namepath-defining"` - As with `namepath-referencing`, but also
319320
indicates the tag adds a namepath to definitions, e.g., to prevent
320321
`no-undefined-types` from reporting references to that namepath.

docs/rules/no-undefined-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ types for a tag, the function will silently ignore that tag, leaving it to
5050
the `valid-types` rule to report parsing errors.
5151

5252
If you define your own tags, you can use `settings.jsdoc.structuredTags`
53-
to indicate that a tag's `name` is "namepath-defining" (and should prevent
53+
to indicate that a tag's `name` is "name-defining" or "namepath-defining" (and should prevent
5454
reporting on use of that namepath elsewhere) and/or that a tag's `type` is
5555
`false` (and should not be checked for types). If the `type` is an array, that
5656
array's items will be considered as defined for the purposes of that tag.

docs/rules/valid-types.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,15 @@ function quux (items) {
503503
* @param {SomeType} aName An inline {@link} tag without content.
504504
*/
505505
// Message: Inline tag "link" missing content
506+
507+
/**
508+
* With reserved word in type
509+
* @param {Array<import>} foo
510+
*/
511+
function quux() {
512+
513+
}
514+
// Message: Syntax error in type: Array<import>
506515
````
507516

508517

@@ -919,5 +928,42 @@ export function onGlobalEvent (selector, type, callback, options) {
919928
*/
920929
function a () {}
921930
// Settings: {"jsdoc":{"structuredTags":{"next":{"required":["type"]}}}}
931+
932+
/**
933+
* With reserved word in name
934+
* @typedef {SomeType} import
935+
*/
936+
937+
/**
938+
* With reserved word in namepath
939+
* @param {SomeType} import
940+
*/
941+
942+
/**
943+
* @param readonly
944+
*/
945+
946+
/**
947+
* @param {boolean} readonly
948+
*/
949+
950+
/**
951+
* @param {object} params
952+
* @param {boolean} params.readonly
953+
*/
954+
955+
/**
956+
* An object interface
957+
* @typedef {Object} FooBar
958+
* @property {boolean} readonly
959+
* @property {boolean} private
960+
* @property {boolean} public
961+
* @property {boolean} constant
962+
*/
963+
964+
/**
965+
* @param {object} props
966+
* @param {string} props.is
967+
*/
922968
````
923969

docs/settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ values are objects with the following optional properties:
342342
name position (non-whitespace immediately after the tag and whitespace),
343343
e.g., in `@throws This is an error`, "This" would normally be the name,
344344
but "text" allows non-name text here also. This is the default.
345+
- `"name-defining"` - Indicates the tag adds a name to definitions. May not be an arbitrary namepath, unlike `"namepath-defining"`
345346
- `"namepath-defining"` - As with `namepath-referencing`, but also
346347
indicates the tag adds a namepath to definitions, e.g., to prevent
347348
`no-undefined-types` from reporting references to that namepath.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"@es-joy/jsdoccomment": "~0.65.2",
8+
"@es-joy/jsdoccomment": "~0.67.2",
99
"are-docs-informative": "^0.0.2",
1010
"comment-parser": "1.4.1",
1111
"debug": "^4.4.3",
@@ -41,7 +41,7 @@
4141
"@types/estree": "^1.0.8",
4242
"@types/json-schema": "^7.0.15",
4343
"@types/mocha": "^10.0.10",
44-
"@types/node": "^24.6.1",
44+
"@types/node": "^24.6.2",
4545
"@types/semver": "^7.7.1",
4646
"@types/spdx-expression-parse": "^3.0.5",
4747
"@typescript-eslint/types": "^8.45.0",
@@ -52,17 +52,17 @@
5252
"camelcase": "^8.0.0",
5353
"chai": "^6.2.0",
5454
"decamelize": "^6.0.1",
55-
"eslint": "9.36.0",
56-
"eslint-config-canonical": "^45.0.0",
55+
"eslint": "9.37.0",
56+
"eslint-config-canonical": "^45.0.1",
5757
"gitdown": "^4.1.1",
5858
"glob": "^11.0.3",
5959
"globals": "^16.4.0",
6060
"husky": "^9.1.7",
61-
"jsdoc-type-pratt-parser": "^6.1.2",
61+
"jsdoc-type-pratt-parser": "^6.3.2",
6262
"json-schema": "^0.4.0",
6363
"json-schema-to-typescript": "^15.0.4",
6464
"lint-staged": "^16.2.3",
65-
"mocha": "^11.7.3",
65+
"mocha": "^11.7.4",
6666
"open-editor": "^5.1.0",
6767
"replace": "^1.2.2",
6868
"rimraf": "^6.0.1",

0 commit comments

Comments
 (0)