eslint-plugin-jsdoc 39.8.0 → 39.9.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 CHANGED
@@ -21,6 +21,7 @@ JSDoc linting rules for ESLint.
21
21
  * [`@override`/`@augments`/`@extends`/`@implements`/`@ignore` Without Accompanying `@param`/`@description`/`@example`/`@returns`/`@throws`/`@yields`](#user-content-eslint-plugin-jsdoc-settings-override-augments-extends-implements-ignore-without-accompanying-param-description-example-returns-throws-yields)
22
22
  * [Settings to Configure `check-types` and `no-undefined-types`](#user-content-eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types)
23
23
  * [`structuredTags`](#user-content-eslint-plugin-jsdoc-settings-structuredtags)
24
+ * [`contexts`](#user-content-eslint-plugin-jsdoc-settings-contexts)
24
25
  * [Advanced](#user-content-eslint-plugin-jsdoc-advanced)
25
26
  * [AST and Selectors](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
26
27
  * [Rules](#user-content-eslint-plugin-jsdoc-rules)
@@ -553,6 +554,14 @@ values are objects with the following optional properties:
553
554
  name (`@throws Some text`); does not require that both exist but
554
555
  disallows just an empty tag.
555
556
 
557
+ <a name="user-content-eslint-plugin-jsdoc-settings-contexts"></a>
558
+ <a name="eslint-plugin-jsdoc-settings-contexts"></a>
559
+ ### <code>contexts</code>
560
+
561
+ `settings.jsdoc.contexts` can be used as the default for any rules
562
+ with a `contexts` property option. See the "AST and Selectors" section
563
+ for more on this format.
564
+
556
565
  <a name="user-content-eslint-plugin-jsdoc-advanced"></a>
557
566
  <a name="eslint-plugin-jsdoc-advanced"></a>
558
567
  ## Advanced
@@ -6756,8 +6765,8 @@ function is adhering.
6756
6765
  <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10"></a>
6757
6766
  #### Options
6758
6767
 
6759
- <a name="user-content-eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts"></a>
6760
- <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts"></a>
6768
+ <a name="user-content-eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
6769
+ <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
6761
6770
  ##### <code>contexts</code>
6762
6771
 
6763
6772
  Set this to an array of strings representing the AST context (or an object with
@@ -7091,8 +7100,8 @@ You may also provide an object with `message`:
7091
7100
  }
7092
7101
  ```
7093
7102
 
7094
- <a name="user-content-eslint-plugin-jsdoc-rules-match-description-options-11-contexts-1"></a>
7095
- <a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-1"></a>
7103
+ <a name="user-content-eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
7104
+ <a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
7096
7105
  ##### <code>contexts</code>
7097
7106
 
7098
7107
  Set this to an array of strings representing the AST context (or an object with
@@ -8922,8 +8931,8 @@ the presence of ES6 default parameters (bearing in mind that such
8922
8931
  "defaults" are only applied when the supplied value is missing or
8923
8932
  `undefined` but not for `null` or other "falsey" values).
8924
8933
 
8925
- <a name="user-content-eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-2"></a>
8926
- <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-2"></a>
8934
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
8935
+ <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
8927
8936
  ##### <code>contexts</code>
8928
8937
 
8929
8938
  Set this to an array of strings representing the AST context (or an object with
@@ -9113,8 +9122,8 @@ not report if there were only a function declaration of the name "ignoreMe"
9113
9122
  <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17"></a>
9114
9123
  #### Options
9115
9124
 
9116
- <a name="user-content-eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-3"></a>
9117
- <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-3"></a>
9125
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
9126
+ <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
9118
9127
  ##### <code>contexts</code>
9119
9128
 
9120
9129
  Set this to an array of strings representing the AST context (or an object with
@@ -9159,6 +9168,15 @@ function quux () {
9159
9168
  */
9160
9169
  function quux () {
9161
9170
 
9171
+ }
9172
+ // Settings: {"jsdoc":{"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}}
9173
+ // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
9174
+
9175
+ /**
9176
+ * @implements {Bar|Foo}
9177
+ */
9178
+ function quux () {
9179
+
9162
9180
  }
9163
9181
  // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
9164
9182
  // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
@@ -9206,7 +9224,7 @@ function quux () {
9206
9224
  function quux () {
9207
9225
 
9208
9226
  }
9209
- // Message: Rule `no-missing-syntax` is missing a `context` option.
9227
+ // Message: Rule `no-missing-syntax` is missing a `contexts` option.
9210
9228
 
9211
9229
  /**
9212
9230
  * @implements {Bar|Foo}
@@ -9590,8 +9608,8 @@ is designed to do), you can just use ESLint's rule.
9590
9608
  <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19"></a>
9591
9609
  #### Options
9592
9610
 
9593
- <a name="user-content-eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-4"></a>
9594
- <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-4"></a>
9611
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
9612
+ <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
9595
9613
  ##### <code>contexts</code>
9596
9614
 
9597
9615
  Set this to an array of strings representing the AST context (or an object with
@@ -9669,7 +9687,16 @@ function quux () {
9669
9687
  function quux () {
9670
9688
 
9671
9689
  }
9672
- // Message: Rule `no-restricted-syntax` is missing a `context` option.
9690
+ // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
9691
+
9692
+ /**
9693
+ * @implements {Bar|Foo}
9694
+ */
9695
+ function quux () {
9696
+
9697
+ }
9698
+ // Settings: {"jsdoc":{"contexts":["FunctionDeclaration"]}}
9699
+ // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
9673
9700
 
9674
9701
  /**
9675
9702
  * @param opt_a
@@ -9911,8 +9938,8 @@ the type information would be redundant with TypeScript.
9911
9938
  <a name="eslint-plugin-jsdoc-rules-no-types-options-20"></a>
9912
9939
  #### Options
9913
9940
 
9914
- <a name="user-content-eslint-plugin-jsdoc-rules-no-types-options-20-contexts-5"></a>
9915
- <a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-5"></a>
9941
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
9942
+ <a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
9916
9943
  ##### <code>contexts</code>
9917
9944
 
9918
9945
  Set this to an array of strings representing the AST context (or an object with
@@ -11922,6 +11949,16 @@ class quux {
11922
11949
  // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
11923
11950
  // Message: Missing JSDoc @description declaration.
11924
11951
 
11952
+ /**
11953
+ *
11954
+ */
11955
+ class quux {
11956
+
11957
+ }
11958
+ // Settings: {"jsdoc":{"contexts":["ClassDeclaration"]}}
11959
+ // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
11960
+ // Message: Missing JSDoc @description declaration.
11961
+
11925
11962
  /**
11926
11963
  *
11927
11964
  */
@@ -12406,8 +12443,8 @@ exemption of the rule.
12406
12443
  Boolean to indicate that no-argument functions should not be reported for
12407
12444
  missing `@example` declarations.
12408
12445
 
12409
- <a name="user-content-eslint-plugin-jsdoc-rules-require-example-options-25-contexts-6"></a>
12410
- <a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-6"></a>
12446
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
12447
+ <a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
12411
12448
  ##### <code>contexts</code>
12412
12449
 
12413
12450
  Set this to an array of strings representing the AST context (or an object with
@@ -13311,8 +13348,8 @@ An object with the following optional boolean keys which all default to
13311
13348
  - `FunctionExpression`
13312
13349
  - `MethodDefinition`
13313
13350
 
13314
- <a name="user-content-eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-7"></a>
13315
- <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-7"></a>
13351
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
13352
+ <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
13316
13353
  ##### <code>contexts</code>
13317
13354
 
13318
13355
  Set this to an array of strings or objects representing the additional AST
@@ -13512,6 +13549,13 @@ export const test = () => {
13512
13549
 
13513
13550
  export const test = () => {
13514
13551
 
13552
+ };
13553
+ // Settings: {"jsdoc":{"contexts":["ArrowFunctionExpression"]}}
13554
+ // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true}]
13555
+ // Message: Missing JSDoc comment.
13556
+
13557
+ export const test = () => {
13558
+
13515
13559
  };
13516
13560
  // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[{"context":"ArrowFunctionExpression"}],"publicOnly":true}]
13517
13561
  // Message: Missing JSDoc comment.
@@ -15091,8 +15135,8 @@ string. Defaults to `false`.
15091
15135
  The description string to set by default for destructured roots. Defaults to
15092
15136
  "The root object".
15093
15137
 
15094
- <a name="user-content-eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-8"></a>
15095
- <a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-8"></a>
15138
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
15139
+ <a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
15096
15140
  ##### <code>contexts</code>
15097
15141
 
15098
15142
  Set this to an array of strings representing the AST context (or an object with
@@ -15289,8 +15333,8 @@ Requires that all function parameters have names.
15289
15333
  <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30"></a>
15290
15334
  #### Options
15291
15335
 
15292
- <a name="user-content-eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-9"></a>
15293
- <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-9"></a>
15336
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
15337
+ <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
15294
15338
  ##### <code>contexts</code>
15295
15339
 
15296
15340
  Set this to an array of strings representing the AST context (or an object with
@@ -15449,8 +15493,8 @@ object. Uses `defaultDestructuredRootType` for the type string. Defaults to
15449
15493
 
15450
15494
  The type string to set by default for destructured roots. Defaults to "object".
15451
15495
 
15452
- <a name="user-content-eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-10"></a>
15453
- <a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-10"></a>
15496
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
15497
+ <a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
15454
15498
  ##### <code>contexts</code>
15455
15499
 
15456
15500
  Set this to an array of strings representing the AST context (or an object with
@@ -15977,8 +16021,8 @@ You could set this regular expression to a more expansive list, or you
15977
16021
  could restrict it such that even types matching those strings would not
15978
16022
  need destructuring.
15979
16023
 
15980
- <a name="user-content-eslint-plugin-jsdoc-rules-require-param-options-32-contexts-11"></a>
15981
- <a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-11"></a>
16024
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
16025
+ <a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
15982
16026
  ##### <code>contexts</code>
15983
16027
 
15984
16028
  Set this to an array of strings representing the AST context (or an object with
@@ -18746,8 +18790,8 @@ or if it is `Promise<void>` or `Promise<undefined>`.
18746
18790
  <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34"></a>
18747
18791
  #### Options
18748
18792
 
18749
- <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-12"></a>
18750
- <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-12"></a>
18793
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
18794
+ <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
18751
18795
  ##### <code>contexts</code>
18752
18796
 
18753
18797
  Set this to an array of strings representing the AST context (or an object with
@@ -18905,8 +18949,8 @@ Requires that `@returns` tag has `type` value.
18905
18949
  <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35"></a>
18906
18950
  #### Options
18907
18951
 
18908
- <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-13"></a>
18909
- <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-13"></a>
18952
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
18953
+ <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
18910
18954
  ##### <code>contexts</code>
18911
18955
 
18912
18956
  Set this to an array of strings representing the AST context (or an object with
@@ -652,7 +652,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
652
652
  return utils;
653
653
  };
654
654
  const getSettings = context => {
655
- var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12, _context$settings$jsd13;
655
+ var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12, _context$settings$jsd13, _context$settings$jsd14;
656
656
  /* eslint-disable canonical/sort-keys */
657
657
  const settings = {
658
658
  // All rules
@@ -675,7 +675,9 @@ const getSettings = context => {
675
675
  // `require-param-type`, `require-param-description`
676
676
  exemptDestructuredRootsFromChecks: (_context$settings$jsd12 = context.settings.jsdoc) === null || _context$settings$jsd12 === void 0 ? void 0 : _context$settings$jsd12.exemptDestructuredRootsFromChecks,
677
677
  // Many rules, e.g., `check-tag-names`
678
- mode: ((_context$settings$jsd13 = context.settings.jsdoc) === null || _context$settings$jsd13 === void 0 ? void 0 : _context$settings$jsd13.mode) ?? (context.parserPath.includes('@typescript-eslint') ? 'typescript' : 'jsdoc')
678
+ mode: ((_context$settings$jsd13 = context.settings.jsdoc) === null || _context$settings$jsd13 === void 0 ? void 0 : _context$settings$jsd13.mode) ?? (context.parserPath.includes('@typescript-eslint') ? 'typescript' : 'jsdoc'),
679
+ // Many rules
680
+ contexts: (_context$settings$jsd14 = context.settings.jsdoc) === null || _context$settings$jsd14 === void 0 ? void 0 : _context$settings$jsd14.contexts
679
681
  };
680
682
  /* eslint-enable canonical/sort-keys */
681
683
 
@@ -892,6 +894,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
892
894
  if (lastCall && ruleConfig.exit) {
893
895
  ruleConfig.exit({
894
896
  context,
897
+ settings,
895
898
  state,
896
899
  utils
897
900
  });
@@ -1013,7 +1016,7 @@ function iterateJsdoc(iterator, ruleConfig) {
1013
1016
  let contexts;
1014
1017
  if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) {
1015
1018
  var _context$options$2, _contexts, _contexts2;
1016
- contexts = ruleConfig.matchContext && (_context$options$2 = context.options[0]) !== null && _context$options$2 !== void 0 && _context$options$2.match ? context.options[0].match : _jsdocUtils.default.enforcedContexts(context, ruleConfig.contextDefaults);
1019
+ contexts = ruleConfig.matchContext && (_context$options$2 = context.options[0]) !== null && _context$options$2 !== void 0 && _context$options$2.match ? context.options[0].match : _jsdocUtils.default.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings);
1017
1020
  if (contexts) {
1018
1021
  contexts = contexts.map(obj => {
1019
1022
  if (typeof obj === 'object' && !obj.context) {
@@ -1067,6 +1070,7 @@ function iterateJsdoc(iterator, ruleConfig) {
1067
1070
  contextObject['Program:exit'] = () => {
1068
1071
  ruleConfig.exit({
1069
1072
  context,
1073
+ settings,
1070
1074
  state
1071
1075
  });
1072
1076
  };