eslint-plugin-jsdoc 39.8.0 → 39.9.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
@@ -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
@@ -2047,7 +2056,7 @@ An object with any of the following keys set to an integer. Affects spacing:
2047
2056
  - `postTag` - after the tag (e.g., `* @param `)
2048
2057
  - `postType` - after the type (e.g., `* @param {someType} `)
2049
2058
  - `postName` - after the name (e.g., `* @param {someType} name `)
2050
- - `postHyphens` - after any hyphens in the description (e.g., `* @param {someType} name - A description`)
2059
+ - `postHyphen` - after any hyphens in the description (e.g., `* @param {someType} name - A description`)
2051
2060
 
2052
2061
  If a spacing is not defined, it defaults to one.
2053
2062
 
@@ -2855,6 +2864,12 @@ const fn = ( lorem, sit ) => {};
2855
2864
  */
2856
2865
  const fn = ( a, b ) => {};
2857
2866
  // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
2867
+
2868
+ /**
2869
+ * @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description -
2870
+ * Notification description
2871
+ */
2872
+ function quux () {}
2858
2873
  ````
2859
2874
 
2860
2875
 
@@ -6756,8 +6771,8 @@ function is adhering.
6756
6771
  <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10"></a>
6757
6772
  #### Options
6758
6773
 
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>
6774
+ <a name="user-content-eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
6775
+ <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
6761
6776
  ##### <code>contexts</code>
6762
6777
 
6763
6778
  Set this to an array of strings representing the AST context (or an object with
@@ -7091,8 +7106,8 @@ You may also provide an object with `message`:
7091
7106
  }
7092
7107
  ```
7093
7108
 
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>
7109
+ <a name="user-content-eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
7110
+ <a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
7096
7111
  ##### <code>contexts</code>
7097
7112
 
7098
7113
  Set this to an array of strings representing the AST context (or an object with
@@ -8922,8 +8937,8 @@ the presence of ES6 default parameters (bearing in mind that such
8922
8937
  "defaults" are only applied when the supplied value is missing or
8923
8938
  `undefined` but not for `null` or other "falsey" values).
8924
8939
 
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>
8940
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
8941
+ <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
8927
8942
  ##### <code>contexts</code>
8928
8943
 
8929
8944
  Set this to an array of strings representing the AST context (or an object with
@@ -9113,8 +9128,8 @@ not report if there were only a function declaration of the name "ignoreMe"
9113
9128
  <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17"></a>
9114
9129
  #### Options
9115
9130
 
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>
9131
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
9132
+ <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
9118
9133
  ##### <code>contexts</code>
9119
9134
 
9120
9135
  Set this to an array of strings representing the AST context (or an object with
@@ -9159,6 +9174,15 @@ function quux () {
9159
9174
  */
9160
9175
  function quux () {
9161
9176
 
9177
+ }
9178
+ // Settings: {"jsdoc":{"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}}
9179
+ // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
9180
+
9181
+ /**
9182
+ * @implements {Bar|Foo}
9183
+ */
9184
+ function quux () {
9185
+
9162
9186
  }
9163
9187
  // "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
9188
  // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
@@ -9206,7 +9230,7 @@ function quux () {
9206
9230
  function quux () {
9207
9231
 
9208
9232
  }
9209
- // Message: Rule `no-missing-syntax` is missing a `context` option.
9233
+ // Message: Rule `no-missing-syntax` is missing a `contexts` option.
9210
9234
 
9211
9235
  /**
9212
9236
  * @implements {Bar|Foo}
@@ -9590,8 +9614,8 @@ is designed to do), you can just use ESLint's rule.
9590
9614
  <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19"></a>
9591
9615
  #### Options
9592
9616
 
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>
9617
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
9618
+ <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
9595
9619
  ##### <code>contexts</code>
9596
9620
 
9597
9621
  Set this to an array of strings representing the AST context (or an object with
@@ -9669,7 +9693,16 @@ function quux () {
9669
9693
  function quux () {
9670
9694
 
9671
9695
  }
9672
- // Message: Rule `no-restricted-syntax` is missing a `context` option.
9696
+ // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
9697
+
9698
+ /**
9699
+ * @implements {Bar|Foo}
9700
+ */
9701
+ function quux () {
9702
+
9703
+ }
9704
+ // Settings: {"jsdoc":{"contexts":["FunctionDeclaration"]}}
9705
+ // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
9673
9706
 
9674
9707
  /**
9675
9708
  * @param opt_a
@@ -9911,8 +9944,8 @@ the type information would be redundant with TypeScript.
9911
9944
  <a name="eslint-plugin-jsdoc-rules-no-types-options-20"></a>
9912
9945
  #### Options
9913
9946
 
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>
9947
+ <a name="user-content-eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
9948
+ <a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
9916
9949
  ##### <code>contexts</code>
9917
9950
 
9918
9951
  Set this to an array of strings representing the AST context (or an object with
@@ -11922,6 +11955,16 @@ class quux {
11922
11955
  // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
11923
11956
  // Message: Missing JSDoc @description declaration.
11924
11957
 
11958
+ /**
11959
+ *
11960
+ */
11961
+ class quux {
11962
+
11963
+ }
11964
+ // Settings: {"jsdoc":{"contexts":["ClassDeclaration"]}}
11965
+ // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
11966
+ // Message: Missing JSDoc @description declaration.
11967
+
11925
11968
  /**
11926
11969
  *
11927
11970
  */
@@ -12406,8 +12449,8 @@ exemption of the rule.
12406
12449
  Boolean to indicate that no-argument functions should not be reported for
12407
12450
  missing `@example` declarations.
12408
12451
 
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>
12452
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
12453
+ <a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
12411
12454
  ##### <code>contexts</code>
12412
12455
 
12413
12456
  Set this to an array of strings representing the AST context (or an object with
@@ -13311,8 +13354,8 @@ An object with the following optional boolean keys which all default to
13311
13354
  - `FunctionExpression`
13312
13355
  - `MethodDefinition`
13313
13356
 
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>
13357
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
13358
+ <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
13316
13359
  ##### <code>contexts</code>
13317
13360
 
13318
13361
  Set this to an array of strings or objects representing the additional AST
@@ -13512,6 +13555,13 @@ export const test = () => {
13512
13555
 
13513
13556
  export const test = () => {
13514
13557
 
13558
+ };
13559
+ // Settings: {"jsdoc":{"contexts":["ArrowFunctionExpression"]}}
13560
+ // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true}]
13561
+ // Message: Missing JSDoc comment.
13562
+
13563
+ export const test = () => {
13564
+
13515
13565
  };
13516
13566
  // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[{"context":"ArrowFunctionExpression"}],"publicOnly":true}]
13517
13567
  // Message: Missing JSDoc comment.
@@ -15091,8 +15141,8 @@ string. Defaults to `false`.
15091
15141
  The description string to set by default for destructured roots. Defaults to
15092
15142
  "The root object".
15093
15143
 
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>
15144
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
15145
+ <a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
15096
15146
  ##### <code>contexts</code>
15097
15147
 
15098
15148
  Set this to an array of strings representing the AST context (or an object with
@@ -15289,8 +15339,8 @@ Requires that all function parameters have names.
15289
15339
  <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30"></a>
15290
15340
  #### Options
15291
15341
 
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>
15342
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
15343
+ <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
15294
15344
  ##### <code>contexts</code>
15295
15345
 
15296
15346
  Set this to an array of strings representing the AST context (or an object with
@@ -15449,8 +15499,8 @@ object. Uses `defaultDestructuredRootType` for the type string. Defaults to
15449
15499
 
15450
15500
  The type string to set by default for destructured roots. Defaults to "object".
15451
15501
 
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>
15502
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
15503
+ <a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
15454
15504
  ##### <code>contexts</code>
15455
15505
 
15456
15506
  Set this to an array of strings representing the AST context (or an object with
@@ -15977,8 +16027,8 @@ You could set this regular expression to a more expansive list, or you
15977
16027
  could restrict it such that even types matching those strings would not
15978
16028
  need destructuring.
15979
16029
 
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>
16030
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
16031
+ <a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
15982
16032
  ##### <code>contexts</code>
15983
16033
 
15984
16034
  Set this to an array of strings representing the AST context (or an object with
@@ -18746,8 +18796,8 @@ or if it is `Promise<void>` or `Promise<undefined>`.
18746
18796
  <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34"></a>
18747
18797
  #### Options
18748
18798
 
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>
18799
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
18800
+ <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
18751
18801
  ##### <code>contexts</code>
18752
18802
 
18753
18803
  Set this to an array of strings representing the AST context (or an object with
@@ -18905,8 +18955,8 @@ Requires that `@returns` tag has `type` value.
18905
18955
  <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35"></a>
18906
18956
  #### Options
18907
18957
 
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>
18958
+ <a name="user-content-eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
18959
+ <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
18910
18960
  ##### <code>contexts</code>
18911
18961
 
18912
18962
  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
  };