eslint-plugin-jsdoc 37.6.3 → 37.8.1

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 CHANGED
@@ -70,6 +70,7 @@ JSDoc linting rules for ESLint.
70
70
  * [`require-throws`](#eslint-plugin-jsdoc-rules-require-throws)
71
71
  * [`require-yields`](#eslint-plugin-jsdoc-rules-require-yields)
72
72
  * [`require-yields-check`](#eslint-plugin-jsdoc-rules-require-yields-check)
73
+ * [`sort-tags`](#eslint-plugin-jsdoc-rules-sort-tags)
73
74
  * [`tag-lines`](#eslint-plugin-jsdoc-rules-tag-lines)
74
75
  * [`valid-types`](#eslint-plugin-jsdoc-rules-valid-types)
75
76
 
@@ -4728,7 +4729,7 @@ number
4728
4729
  bigint
4729
4730
  string
4730
4731
  symbol
4731
- object
4732
+ object (For TypeScript's sake, however, using `Object` when specifying child types on it like `Object<string, number>`)
4732
4733
  Array
4733
4734
  Function
4734
4735
  Date
@@ -4789,7 +4790,7 @@ the `valid-types` rule to report parsing errors.
4789
4790
 
4790
4791
  Why are `boolean`, `number` and `string` exempt from starting with a capital
4791
4792
  letter? Let's take `string` as an example. In Javascript, everything is an
4792
- object. The string Object has prototypes for string functions such as
4793
+ object. The `String` object has prototypes for string functions such as
4793
4794
  `.toUpperCase()`.
4794
4795
 
4795
4796
  Fortunately we don't have to write `new String()` everywhere in our code.
@@ -4812,17 +4813,28 @@ new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
4812
4813
  new String('lard') === 'lard' // false
4813
4814
  ```
4814
4815
 
4815
- To make things more confusing, there are also object literals and object
4816
- Objects. But object literals are still static Objects and object Objects are
4817
- instantiated Objects. So an object primitive is still an object Object.
4816
+ To make things more confusing, there are also object literals (like `{}`) and
4817
+ `Object` objects. But object literals are still static `Object`s and `Object`
4818
+ objects are instantiated objects. So an object primitive is still an `Object`
4819
+ object.
4818
4820
 
4819
4821
  However, `Object.create(null)` objects are not `instanceof Object`, however, so
4820
- in the case of this Object we lower-case to indicate possible support for
4821
- these objects.
4822
+ in the case of such a plain object we lower-case to indicate possible support
4823
+ for these objects. Also, nowadays, TypeScript also discourages use of `Object`
4824
+ as a lone type. However, one additional complexity is that TypeScript allows and
4825
+ actually [currently requires](https://github.com/microsoft/TypeScript/issues/20555)
4826
+ `Object` (with the initial upper-case) if used in the syntax
4827
+ `Object.<keyType, valueType>` or `Object<keyType, valueType`, perhaps to
4828
+ adhere to what [JSDoc documents](https://jsdoc.app/tags-type.html).
4829
+
4830
+ So, for optimal compatibility with TypeScript (especially since TypeScript
4831
+ tools can be used on plain JavaScript with JSDoc), we are now allowing this
4832
+ TypeScript approach by default.
4822
4833
 
4823
4834
  Basically, for primitives, we want to define the type as a primitive, because
4824
4835
  that's what we use in 99.9% of cases. For everything else, we use the type
4825
- rather than the primitive. Otherwise it would all just be `{object}`.
4836
+ rather than the primitive. Otherwise it would all just be `{object}` (with the
4837
+ additional exception of the special case of `Object.<>` just mentioned).
4826
4838
 
4827
4839
  In short: It's not about consistency, rather about the 99.9% use case. (And
4828
4840
  some functions might not even support the objects if they are checking for
@@ -5447,6 +5459,39 @@ function quux (foo) {
5447
5459
  }
5448
5460
  // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object"}}}
5449
5461
  // Message: Invalid JSDoc @param "foo" type "Object"; prefer: "object".
5462
+
5463
+ /**
5464
+ * @param {object.<string>} foo
5465
+ */
5466
+ function quux (foo) {
5467
+
5468
+ }
5469
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"object.<>":"Object"}}}
5470
+ // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object".
5471
+
5472
+ /**
5473
+ * @param {object.<string, number>} foo
5474
+ */
5475
+ function quux (foo) {
5476
+ }
5477
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","Object.<>":"Object<>","object<>":"Object<>"}}}
5478
+ // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".
5479
+
5480
+ /**
5481
+ * @param {Object.<string, number>} foo
5482
+ */
5483
+ function quux (foo) {
5484
+ }
5485
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","Object.<>":"Object<>","object<>":"Object<>"}}}
5486
+ // Message: Invalid JSDoc @param "foo" type "Object"; prefer: "Object<>".
5487
+
5488
+ /**
5489
+ * @param {object<string, number>} foo
5490
+ */
5491
+ function quux (foo) {
5492
+ }
5493
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","Object.<>":"Object<>","object<>":"Object<>"}}}
5494
+ // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".
5450
5495
  ````
5451
5496
 
5452
5497
  The following patterns are not considered problems:
@@ -5734,6 +5779,26 @@ function b () {}
5734
5779
  function quux (foo) {
5735
5780
 
5736
5781
  }
5782
+
5783
+ /**
5784
+ * @param {Object.<string>} foo
5785
+ */
5786
+ function quux (foo) {
5787
+
5788
+ }
5789
+ // Settings: {"jsdoc":{"mode":"typescript"}}
5790
+
5791
+ /**
5792
+ * @typedef {object} foo
5793
+ */
5794
+ function a () {}
5795
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","object<>":"Object<>"}}}
5796
+
5797
+ /**
5798
+ * @typedef {Object<string, number>} foo
5799
+ */
5800
+ function a () {}
5801
+ // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","object<>":"Object<>"}}}
5737
5802
  ````
5738
5803
 
5739
5804
 
@@ -9109,6 +9174,13 @@ const MY_ENUM = Object.freeze({
9109
9174
  } as const);
9110
9175
  // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag ~ JsdocTag[tag=/private|protected/])","context":"any","message":"Access modifier tags must come first"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":":declaration","message":"@enum not allowed on declarations"}]}]
9111
9176
  // Message: @enum not allowed on declarations
9177
+
9178
+ /** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
9179
+ const MyComponent = ({ children }) => {
9180
+ return children;
9181
+ }
9182
+ // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"type\"]:has([value=/FunctionComponent/]))","context":"any","message":"The `FunctionComponent` type is not allowed. Please use `FC` instead."}]}]
9183
+ // Message: The `FunctionComponent` type is not allowed. Please use `FC` instead.
9112
9184
  ````
9113
9185
 
9114
9186
  The following patterns are not considered problems:
@@ -19985,12 +20057,349 @@ function * quux (foo) {
19985
20057
  ````
19986
20058
 
19987
20059
 
20060
+ <a name="eslint-plugin-jsdoc-rules-sort-tags"></a>
20061
+ ### <code>sort-tags</code>
20062
+
20063
+ Sorts tags by a specified sequence according to tag name.
20064
+
20065
+ (Default order originally inspired by [`@homer0/prettier-plugin-jsdoc`](https://github.com/homer0/packages/tree/main/packages/public/prettier-plugin-jsdoc).)
20066
+
20067
+ <a name="eslint-plugin-jsdoc-rules-sort-tags-options-40"></a>
20068
+ #### Options
20069
+
20070
+ <a name="eslint-plugin-jsdoc-rules-sort-tags-options-40-tagsequence"></a>
20071
+ ##### <code>tagSequence</code>
20072
+
20073
+ An array of tag names indicating the preferred sequence for sorting tags.
20074
+
20075
+ Tag names earlier in the list will be arranged first. The relative position of
20076
+ tags of the same name will not be changed.
20077
+
20078
+ Tags not in the list will be sorted alphabetically at the end (or in place of
20079
+ the pseudo-tag `-other` placed within `tagSequence`) if `alphabetizeExtras` is
20080
+ enabled and in their order of appearance otherwise (so if you want all your
20081
+ tags alphabetized, supply an empty array with `alphabetizeExtras` enabled).
20082
+
20083
+ Defaults to the array below.
20084
+
20085
+ Please note that this order is still experimental, so if you want to retain
20086
+ a fixed order that doesn't change into the future, supply your own
20087
+ `tagSequence`.
20088
+
20089
+ ```js
20090
+ [
20091
+ // Brief descriptions
20092
+ 'summary',
20093
+ 'typeSummary',
20094
+
20095
+ // Module/file-level
20096
+ 'module',
20097
+ 'exports',
20098
+ 'file',
20099
+ 'fileoverview',
20100
+ 'overview',
20101
+
20102
+ // Identifying (name, type)
20103
+ 'typedef',
20104
+ 'interface',
20105
+ 'record',
20106
+ 'template',
20107
+ 'name',
20108
+ 'kind',
20109
+ 'type',
20110
+ 'alias',
20111
+ 'external',
20112
+ 'host',
20113
+ 'callback',
20114
+ 'func',
20115
+ 'function',
20116
+ 'method',
20117
+ 'class',
20118
+ 'constructor',
20119
+
20120
+ // Relationships
20121
+ 'modifies',
20122
+ 'mixes',
20123
+ 'mixin',
20124
+ 'mixinClass',
20125
+ 'mixinFunction',
20126
+ 'namespace',
20127
+ 'borrows',
20128
+ 'constructs',
20129
+ 'lends',
20130
+ 'implements',
20131
+ 'requires',
20132
+
20133
+ // Long descriptions
20134
+ 'desc',
20135
+ 'description',
20136
+ 'classdesc',
20137
+ 'tutorial',
20138
+ 'copyright',
20139
+ 'license',
20140
+
20141
+ // Simple annotations
20142
+ 'const',
20143
+ 'constant',
20144
+ 'final',
20145
+ 'global',
20146
+ 'readonly',
20147
+ 'abstract',
20148
+ 'virtual',
20149
+ 'var',
20150
+ 'member',
20151
+ 'memberof',
20152
+ 'memberof!',
20153
+ 'inner',
20154
+ 'instance',
20155
+ 'inheritdoc',
20156
+ 'inheritDoc',
20157
+ 'override',
20158
+ 'hideconstructor',
20159
+
20160
+ // Core function/object info
20161
+ 'param',
20162
+ 'arg',
20163
+ 'argument',
20164
+ 'prop',
20165
+ 'property',
20166
+ 'return',
20167
+ 'returns',
20168
+
20169
+ // Important behavior details
20170
+ 'async',
20171
+ 'generator',
20172
+ 'default',
20173
+ 'defaultvalue',
20174
+ 'enum',
20175
+ 'augments',
20176
+ 'extends',
20177
+ 'throws',
20178
+ 'exception',
20179
+ 'yield',
20180
+ 'yields',
20181
+ 'event',
20182
+ 'fires',
20183
+ 'emits',
20184
+ 'listens',
20185
+ 'this',
20186
+
20187
+ // Access
20188
+ 'static',
20189
+ 'private',
20190
+ 'protected',
20191
+ 'public',
20192
+ 'access',
20193
+ 'package',
20194
+
20195
+ '-other',
20196
+
20197
+ // Supplementary descriptions
20198
+ 'see',
20199
+ 'example',
20200
+
20201
+ // METADATA
20202
+
20203
+ // Other Closure (undocumented) metadata
20204
+ 'closurePrimitive',
20205
+ 'customElement',
20206
+ 'expose',
20207
+ 'hidden',
20208
+ 'idGenerator',
20209
+ 'meaning',
20210
+ 'ngInject',
20211
+ 'owner',
20212
+ 'wizaction',
20213
+
20214
+ // Other Closure (documented) metadata
20215
+ 'define',
20216
+ 'dict',
20217
+ 'export',
20218
+ 'externs',
20219
+ 'implicitCast',
20220
+ 'noalias',
20221
+ 'nocollapse',
20222
+ 'nocompile',
20223
+ 'noinline',
20224
+ 'nosideeffects',
20225
+ 'polymer',
20226
+ 'polymerBehavior',
20227
+ 'preserve',
20228
+ 'struct',
20229
+ 'suppress',
20230
+ 'unrestricted',
20231
+
20232
+ // @homer0/prettier-plugin-jsdoc metadata
20233
+ 'category',
20234
+
20235
+ // Non-Closure metadata
20236
+ 'ignore',
20237
+ 'author',
20238
+ 'version',
20239
+ 'variation',
20240
+ 'since',
20241
+ 'deprecated',
20242
+ 'todo',
20243
+ ];
20244
+ ```
20245
+
20246
+ <a name="eslint-plugin-jsdoc-rules-sort-tags-options-40-alphabetizeextras"></a>
20247
+ ##### <code>alphabetizeExtras</code>
20248
+
20249
+ Defaults to `false`. Alphabetizes any items not within `tagSequence` after any
20250
+ items within `tagSequence` (or in place of the special `-other` pseudo-tag)
20251
+ are sorted.
20252
+
20253
+ |||
20254
+ |---|---|
20255
+ |Context|everywhere|
20256
+ |Tags|any|
20257
+ |Recommended|false|
20258
+ |Settings||
20259
+ |Options|`tagSequence`, `alphabetizeExtras`|
20260
+
20261
+ The following patterns are considered problems:
20262
+
20263
+ ````js
20264
+ /**
20265
+ * @returns {string}
20266
+ * @param b
20267
+ * @param a
20268
+ */
20269
+ function quux () {}
20270
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20271
+
20272
+ /**
20273
+ * Some description
20274
+ * @returns {string}
20275
+ * @param b
20276
+ * @param a
20277
+ */
20278
+ function quux () {}
20279
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20280
+
20281
+ /**
20282
+ * @returns {string}
20283
+ * @param b A long
20284
+ * description
20285
+ * @param a
20286
+ */
20287
+ function quux () {}
20288
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20289
+
20290
+ /**
20291
+ * Some description
20292
+ * @returns {string}
20293
+ * @param b A long
20294
+ * description
20295
+ * @param a
20296
+ */
20297
+ function quux () {}
20298
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20299
+
20300
+ /**
20301
+ * @param b A long
20302
+ * description
20303
+ * @returns {string}
20304
+ * @param a
20305
+ */
20306
+ function quux () {}
20307
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20308
+
20309
+ /**
20310
+ * @def
20311
+ * @xyz
20312
+ * @abc
20313
+ */
20314
+ function quux () {}
20315
+ // "jsdoc/sort-tags": ["error"|"warn", {"alphabetizeExtras":true}]
20316
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20317
+
20318
+ /**
20319
+ * @xyz
20320
+ * @def
20321
+ * @abc
20322
+ */
20323
+ function quux () {}
20324
+ // "jsdoc/sort-tags": ["error"|"warn", {"tagSequence":["def","xyz","abc"]}]
20325
+ // Message: Tags are not in the prescribed order: def, xyz, abc
20326
+
20327
+ /**
20328
+ * @returns {string}
20329
+ * @ignore
20330
+ * @param b A long
20331
+ * description
20332
+ * @param a
20333
+ * @module
20334
+ */
20335
+ function quux () {}
20336
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20337
+
20338
+ /**
20339
+ * @xyz
20340
+ * @abc
20341
+ * @abc
20342
+ * @def
20343
+ * @xyz
20344
+ */
20345
+ function quux () {}
20346
+ // "jsdoc/sort-tags": ["error"|"warn", {"alphabetizeExtras":true}]
20347
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20348
+
20349
+ /**
20350
+ * @param b A long
20351
+ * description
20352
+ * @module
20353
+ */
20354
+ function quux () {}
20355
+ // Message: Tags are not in the prescribed order: summary, typeSummary, module, exports, file, fileoverview, overview, typedef, interface, record, template, name, kind, type, alias, external, host, callback, func, function, method, class, constructor, modifies, mixes, mixin, mixinClass, mixinFunction, namespace, borrows, constructs, lends, implements, requires, desc, description, classdesc, tutorial, copyright, license, const, constant, final, global, readonly, abstract, virtual, var, member, memberof, memberof!, inner, instance, inheritdoc, inheritDoc, override, hideconstructor, param, arg, argument, prop, property, return, returns, async, generator, default, defaultvalue, enum, augments, extends, throws, exception, yield, yields, event, fires, emits, listens, this, static, private, protected, public, access, package, -other, see, example, closurePrimitive, customElement, expose, hidden, idGenerator, meaning, ngInject, owner, wizaction, define, dict, export, externs, implicitCast, noalias, nocollapse, nocompile, noinline, nosideeffects, polymer, polymerBehavior, preserve, struct, suppress, unrestricted, category, ignore, author, version, variation, since, deprecated, todo
20356
+ ````
20357
+
20358
+ The following patterns are not considered problems:
20359
+
20360
+ ````js
20361
+ /**
20362
+ * @param b
20363
+ * @param a
20364
+ * @returns {string}
20365
+ */
20366
+ function quux () {}
20367
+
20368
+ /**
20369
+ * @abc
20370
+ * @def
20371
+ * @xyz
20372
+ */
20373
+ function quux () {}
20374
+ // "jsdoc/sort-tags": ["error"|"warn", {"alphabetizeExtras":true}]
20375
+
20376
+ /**
20377
+ * @def
20378
+ * @xyz
20379
+ * @abc
20380
+ */
20381
+ function quux () {}
20382
+ // "jsdoc/sort-tags": ["error"|"warn", {"alphabetizeExtras":false}]
20383
+
20384
+ /**
20385
+ * @def
20386
+ * @xyz
20387
+ * @abc
20388
+ */
20389
+ function quux () {}
20390
+ // "jsdoc/sort-tags": ["error"|"warn", {"tagSequence":["def","xyz","abc"]}]
20391
+
20392
+ /** @def */
20393
+ function quux () {}
20394
+ ````
20395
+
20396
+
19988
20397
  <a name="eslint-plugin-jsdoc-rules-tag-lines"></a>
19989
20398
  ### <code>tag-lines</code>
19990
20399
 
19991
20400
  Enforces lines (or no lines) between tags.
19992
20401
 
19993
- <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40"></a>
20402
+ <a name="eslint-plugin-jsdoc-rules-tag-lines-options-41"></a>
19994
20403
  #### Options
19995
20404
 
19996
20405
  The first option is a single string set to "always", "never", or "any"
@@ -20001,18 +20410,18 @@ for particular tags).
20001
20410
 
20002
20411
  The second option is an object with the following optional properties.
20003
20412
 
20004
- <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-count-defaults-to-1"></a>
20413
+ <a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-count-defaults-to-1"></a>
20005
20414
  ##### <code>count</code> (defaults to 1)
20006
20415
 
20007
20416
  Use with "always" to indicate the number of lines to require be present.
20008
20417
 
20009
- <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-noendlines-defaults-to-false"></a>
20418
+ <a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-noendlines-defaults-to-false"></a>
20010
20419
  ##### <code>noEndLines</code> (defaults to <code>false</code>)
20011
20420
 
20012
20421
  Use with "always" to indicate the normal lines to be added after tags should
20013
20422
  not be added after the final tag.
20014
20423
 
20015
- <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-tags-default-to-empty-object"></a>
20424
+ <a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-tags-default-to-empty-object"></a>
20016
20425
  ##### <code>tags</code> (default to empty object)
20017
20426
 
20018
20427
  Overrides the default behavior depending on specific tags.
@@ -20408,7 +20817,7 @@ for valid types (based on the tag's `type` value), and either portion checked
20408
20817
  for presence (based on `false` `name` or `type` values or their `required`
20409
20818
  value). See the setting for more details.
20410
20819
 
20411
- <a name="eslint-plugin-jsdoc-rules-valid-types-options-41"></a>
20820
+ <a name="eslint-plugin-jsdoc-rules-valid-types-options-42"></a>
20412
20821
  #### Options
20413
20822
 
20414
20823
  - `allowEmptyNamepaths` (default: true) - Set to `false` to bulk disallow
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const defaultTagOrder = [// Brief descriptions
8
+ 'summary', 'typeSummary', // Module/file-level
9
+ 'module', 'exports', 'file', 'fileoverview', 'overview', // Identifying (name, type)
10
+ 'typedef', 'interface', 'record', 'template', 'name', 'kind', 'type', 'alias', 'external', 'host', 'callback', 'func', 'function', 'method', 'class', 'constructor', // Relationships
11
+ 'modifies', 'mixes', 'mixin', 'mixinClass', 'mixinFunction', 'namespace', 'borrows', 'constructs', 'lends', 'implements', 'requires', // Long descriptions
12
+ 'desc', 'description', 'classdesc', 'tutorial', 'copyright', 'license', // Simple annotations
13
+ 'const', 'constant', 'final', 'global', 'readonly', 'abstract', 'virtual', 'var', 'member', 'memberof', 'memberof!', 'inner', 'instance', 'inheritdoc', 'inheritDoc', 'override', 'hideconstructor', // Core function/object info
14
+ 'param', 'arg', 'argument', 'prop', 'property', 'return', 'returns', // Important behavior details
15
+ 'async', 'generator', 'default', 'defaultvalue', 'enum', 'augments', 'extends', 'throws', 'exception', 'yield', 'yields', 'event', 'fires', 'emits', 'listens', 'this', // Access
16
+ 'static', 'private', 'protected', 'public', 'access', 'package', '-other', // Supplementary descriptions
17
+ 'see', 'example', // METADATA
18
+ // Other Closure (undocumented) metadata
19
+ 'closurePrimitive', 'customElement', 'expose', 'hidden', 'idGenerator', 'meaning', 'ngInject', 'owner', 'wizaction', // Other Closure (documented) metadata
20
+ 'define', 'dict', 'export', 'externs', 'implicitCast', 'noalias', 'nocollapse', 'nocompile', 'noinline', 'nosideeffects', 'polymer', 'polymerBehavior', 'preserve', 'struct', 'suppress', 'unrestricted', // @homer0/prettier-plugin-jsdoc metadata
21
+ 'category', // Non-Closure metadata
22
+ 'ignore', 'author', 'version', 'variation', 'since', 'deprecated', 'todo'];
23
+ var _default = defaultTagOrder;
24
+ exports.default = _default;
25
+ module.exports = exports.default;
26
+ //# sourceMappingURL=defaultTagOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/defaultTagOrder.js"],"names":["defaultTagOrder"],"mappings":";;;;;;AAAA,MAAMA,eAAe,GAAG,CACtB;AACA,SAFsB,EAGtB,aAHsB,EAKtB;AACA,QANsB,EAOtB,SAPsB,EAQtB,MARsB,EAStB,cATsB,EAUtB,UAVsB,EAYtB;AACA,SAbsB,EActB,WAdsB,EAetB,QAfsB,EAgBtB,UAhBsB,EAiBtB,MAjBsB,EAkBtB,MAlBsB,EAmBtB,MAnBsB,EAoBtB,OApBsB,EAqBtB,UArBsB,EAsBtB,MAtBsB,EAuBtB,UAvBsB,EAwBtB,MAxBsB,EAyBtB,UAzBsB,EA0BtB,QA1BsB,EA2BtB,OA3BsB,EA4BtB,aA5BsB,EA8BtB;AACA,UA/BsB,EAgCtB,OAhCsB,EAiCtB,OAjCsB,EAkCtB,YAlCsB,EAmCtB,eAnCsB,EAoCtB,WApCsB,EAqCtB,SArCsB,EAsCtB,YAtCsB,EAuCtB,OAvCsB,EAwCtB,YAxCsB,EAyCtB,UAzCsB,EA2CtB;AACA,MA5CsB,EA6CtB,aA7CsB,EA8CtB,WA9CsB,EA+CtB,UA/CsB,EAgDtB,WAhDsB,EAiDtB,SAjDsB,EAmDtB;AACA,OApDsB,EAqDtB,UArDsB,EAsDtB,OAtDsB,EAuDtB,QAvDsB,EAwDtB,UAxDsB,EAyDtB,UAzDsB,EA0DtB,SA1DsB,EA2DtB,KA3DsB,EA4DtB,QA5DsB,EA6DtB,UA7DsB,EA8DtB,WA9DsB,EA+DtB,OA/DsB,EAgEtB,UAhEsB,EAiEtB,YAjEsB,EAkEtB,YAlEsB,EAmEtB,UAnEsB,EAoEtB,iBApEsB,EAsEtB;AACA,OAvEsB,EAwEtB,KAxEsB,EAyEtB,UAzEsB,EA0EtB,MA1EsB,EA2EtB,UA3EsB,EA4EtB,QA5EsB,EA6EtB,SA7EsB,EA+EtB;AACA,OAhFsB,EAiFtB,WAjFsB,EAkFtB,SAlFsB,EAmFtB,cAnFsB,EAoFtB,MApFsB,EAqFtB,UArFsB,EAsFtB,SAtFsB,EAuFtB,QAvFsB,EAwFtB,WAxFsB,EAyFtB,OAzFsB,EA0FtB,QA1FsB,EA2FtB,OA3FsB,EA4FtB,OA5FsB,EA6FtB,OA7FsB,EA8FtB,SA9FsB,EA+FtB,MA/FsB,EAiGtB;AACA,QAlGsB,EAmGtB,SAnGsB,EAoGtB,WApGsB,EAqGtB,QArGsB,EAsGtB,QAtGsB,EAuGtB,SAvGsB,EAyGtB,QAzGsB,EA2GtB;AACA,KA5GsB,EA6GtB,SA7GsB,EA+GtB;AAEA;AACA,kBAlHsB,EAmHtB,eAnHsB,EAoHtB,QApHsB,EAqHtB,QArHsB,EAsHtB,aAtHsB,EAuHtB,SAvHsB,EAwHtB,UAxHsB,EAyHtB,OAzHsB,EA0HtB,WA1HsB,EA4HtB;AACA,QA7HsB,EA8HtB,MA9HsB,EA+HtB,QA/HsB,EAgItB,SAhIsB,EAiItB,cAjIsB,EAkItB,SAlIsB,EAmItB,YAnIsB,EAoItB,WApIsB,EAqItB,UArIsB,EAsItB,eAtIsB,EAuItB,SAvIsB,EAwItB,iBAxIsB,EAyItB,UAzIsB,EA0ItB,QA1IsB,EA2ItB,UA3IsB,EA4ItB,cA5IsB,EA8ItB;AACA,UA/IsB,EAiJtB;AACA,QAlJsB,EAmJtB,QAnJsB,EAoJtB,SApJsB,EAqJtB,WArJsB,EAsJtB,OAtJsB,EAuJtB,YAvJsB,EAwJtB,MAxJsB,CAAxB;eA2JeA,e","sourcesContent":["const defaultTagOrder = [\n // Brief descriptions\n 'summary',\n 'typeSummary',\n\n // Module/file-level\n 'module',\n 'exports',\n 'file',\n 'fileoverview',\n 'overview',\n\n // Identifying (name, type)\n 'typedef',\n 'interface',\n 'record',\n 'template',\n 'name',\n 'kind',\n 'type',\n 'alias',\n 'external',\n 'host',\n 'callback',\n 'func',\n 'function',\n 'method',\n 'class',\n 'constructor',\n\n // Relationships\n 'modifies',\n 'mixes',\n 'mixin',\n 'mixinClass',\n 'mixinFunction',\n 'namespace',\n 'borrows',\n 'constructs',\n 'lends',\n 'implements',\n 'requires',\n\n // Long descriptions\n 'desc',\n 'description',\n 'classdesc',\n 'tutorial',\n 'copyright',\n 'license',\n\n // Simple annotations\n 'const',\n 'constant',\n 'final',\n 'global',\n 'readonly',\n 'abstract',\n 'virtual',\n 'var',\n 'member',\n 'memberof',\n 'memberof!',\n 'inner',\n 'instance',\n 'inheritdoc',\n 'inheritDoc',\n 'override',\n 'hideconstructor',\n\n // Core function/object info\n 'param',\n 'arg',\n 'argument',\n 'prop',\n 'property',\n 'return',\n 'returns',\n\n // Important behavior details\n 'async',\n 'generator',\n 'default',\n 'defaultvalue',\n 'enum',\n 'augments',\n 'extends',\n 'throws',\n 'exception',\n 'yield',\n 'yields',\n 'event',\n 'fires',\n 'emits',\n 'listens',\n 'this',\n\n // Access\n 'static',\n 'private',\n 'protected',\n 'public',\n 'access',\n 'package',\n\n '-other',\n\n // Supplementary descriptions\n 'see',\n 'example',\n\n // METADATA\n\n // Other Closure (undocumented) metadata\n 'closurePrimitive',\n 'customElement',\n 'expose',\n 'hidden',\n 'idGenerator',\n 'meaning',\n 'ngInject',\n 'owner',\n 'wizaction',\n\n // Other Closure (documented) metadata\n 'define',\n 'dict',\n 'export',\n 'externs',\n 'implicitCast',\n 'noalias',\n 'nocollapse',\n 'nocompile',\n 'noinline',\n 'nosideeffects',\n 'polymer',\n 'polymerBehavior',\n 'preserve',\n 'struct',\n 'suppress',\n 'unrestricted',\n\n // @homer0/prettier-plugin-jsdoc metadata\n 'category',\n\n // Non-Closure metadata\n 'ignore',\n 'author',\n 'version',\n 'variation',\n 'since',\n 'deprecated',\n 'todo',\n];\n\nexport default defaultTagOrder;\n"],"file":"defaultTagOrder.js"}
@@ -10,6 +10,7 @@ const getDefaultTagStructureForMode = mode => {
10
10
  const isClosure = mode === 'closure';
11
11
  const isTypescript = mode === 'typescript';
12
12
  const isPermissive = mode === 'permissive';
13
+ const isJsdocOrPermissive = isJsdoc || isPermissive;
13
14
  const isJsdocOrTypescript = isJsdoc || isTypescript;
14
15
  const isTypescriptOrClosure = isTypescript || isClosure;
15
16
  const isClosureOrPermissive = isClosure || isPermissive;
@@ -151,10 +152,15 @@ const getDefaultTagStructureForMode = mode => {
151
152
  // "typeName"
152
153
  ['typeRequired', true]])], ['typedef', new Map([// Seems to require a "namepath" in the signature (with no
153
154
  // counter-examples)
154
- ['nameContents', 'namepath-defining'], // "namepath"
155
- ['nameRequired', isJsdocTypescriptOrPermissive], // Has example showing curly brackets but not in doc signature
156
- ['typeAllowed', true], // "namepath"
157
- ['typeOrNameRequired', true]])], ['var', new Map([// Allows for "name"'s in signature, but indicated as optional
155
+ ['nameContents', 'namepath-defining'], // TypeScript may allow it to be dropped if followed by @property or @member;
156
+ // also shown as missing in Closure
157
+ // "namepath"
158
+ ['nameRequired', isJsdocOrPermissive], // Is not `typeRequired` for TypeScript because it gives an error:
159
+ // JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags.
160
+ // Has example showing curly brackets but not in doc signature
161
+ ['typeAllowed', true], // TypeScript may allow it to be dropped if followed by @property or @member
162
+ // "namepath"
163
+ ['typeOrNameRequired', !isTypescript]])], ['var', new Map([// Allows for "name"'s in signature, but indicated as optional
158
164
  ['nameContents', 'namepath-defining'], // Has example showing curly brackets but not in doc signature
159
165
  ['typeAllowed', true]])], ['yields', new Map([// Shows curly brackets in the signature and in the examples
160
166
  ['typeAllowed', true]])], ['yield', new Map([// Shows curly brackets in the signature and in the examples