eslint-plugin-jsdoc 37.2.6 → 37.4.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
@@ -8680,6 +8680,14 @@ function quux () {
8680
8680
 
8681
8681
  }
8682
8682
  // "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(2))","context":"FunctionDeclaration"}]}]
8683
+
8684
+ /**
8685
+ * @implements {Bar|Foo}
8686
+ */
8687
+ function quux () {
8688
+
8689
+ }
8690
+ // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"any"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(2))","context":"FunctionDeclaration"}]}]
8683
8691
  ````
8684
8692
 
8685
8693
 
@@ -16499,6 +16507,22 @@ async function foo() {
16499
16507
  function quux () {}
16500
16508
  // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
16501
16509
  // Message: JSDoc @returns declaration present but return expression not available in function.
16510
+
16511
+ /**
16512
+ * @returns {never} Foo.
16513
+ */
16514
+ function quux () {
16515
+ return undefined;
16516
+ }
16517
+ // Message: JSDoc @returns declaration set with "never" but return expression is present in function.
16518
+
16519
+ /**
16520
+ * @returns {never}
16521
+ */
16522
+ function quux (foo) {
16523
+ return foo;
16524
+ }
16525
+ // Message: JSDoc @returns declaration set with "never" but return expression is present in function.
16502
16526
  ````
16503
16527
 
16504
16528
  The following patterns are not considered problems:
@@ -16629,6 +16653,12 @@ function quux () {
16629
16653
  return undefined;
16630
16654
  }
16631
16655
 
16656
+ /**
16657
+ * @returns {never} Foo.
16658
+ */
16659
+ function quux () {
16660
+ }
16661
+
16632
16662
  /**
16633
16663
  * @returns {void} Foo.
16634
16664
  */
@@ -18424,6 +18454,14 @@ const directThrowAfterArrow = (b) => {
18424
18454
  return a;
18425
18455
  };
18426
18456
  // Message: Missing JSDoc @throws declaration.
18457
+
18458
+ /**
18459
+ * @throws {never}
18460
+ */
18461
+ function quux (foo) {
18462
+ throw new Error('err')
18463
+ }
18464
+ // Message: JSDoc @throws declaration set to "never" but throw value found.
18427
18465
  ````
18428
18466
 
18429
18467
  The following patterns are not considered problems:
@@ -18445,6 +18483,13 @@ function quux (foo) {
18445
18483
  } catch(e) {}
18446
18484
  }
18447
18485
 
18486
+ /**
18487
+ * @throws {object}
18488
+ */
18489
+ function quux (foo) {
18490
+ throw new Error('err')
18491
+ }
18492
+
18448
18493
  /**
18449
18494
  * @inheritdoc
18450
18495
  */
@@ -18488,6 +18533,12 @@ const nested = () => () => {throw new Error('oops');};
18488
18533
  async function foo() {
18489
18534
  throw Error("bar");
18490
18535
  }
18536
+
18537
+ /**
18538
+ * @throws {never}
18539
+ */
18540
+ function quux (foo) {
18541
+ }
18491
18542
  ````
18492
18543
 
18493
18544
 
@@ -19472,6 +19523,23 @@ async function * quux() {}
19472
19523
  */
19473
19524
  const quux = async function * () {}
19474
19525
  // Message: JSDoc @yields declaration present but yield expression not available in function.
19526
+
19527
+ /**
19528
+ * @yields {never} Foo.
19529
+ */
19530
+ function * quux () {
19531
+ yield 5;
19532
+ }
19533
+ // Message: JSDoc @yields declaration set with "never" but yield expression is present in function.
19534
+
19535
+ /**
19536
+ * @next {never}
19537
+ */
19538
+ function * quux (foo) {
19539
+ const a = yield;
19540
+ }
19541
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
19542
+ // Message: JSDoc @next declaration set with "never" but yield expression with return value is present in function.
19475
19543
  ````
19476
19544
 
19477
19545
  The following patterns are not considered problems:
@@ -19575,6 +19643,12 @@ function * quux () {
19575
19643
  function * quux () {
19576
19644
  }
19577
19645
 
19646
+ /**
19647
+ * @yields {never} Foo.
19648
+ */
19649
+ function * quux () {
19650
+ }
19651
+
19578
19652
  /**
19579
19653
  * @yields {void} Foo.
19580
19654
  */
@@ -19781,6 +19855,14 @@ function * quux (foo) {
19781
19855
  const a = yield 5;
19782
19856
  }
19783
19857
  // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
19858
+
19859
+ /**
19860
+ * @next {never}
19861
+ */
19862
+ function * quux (foo) {
19863
+
19864
+ }
19865
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
19784
19866
  ````
19785
19867
 
19786
19868
 
@@ -20526,6 +20608,27 @@ parseArray = function(parser) {
20526
20608
  };
20527
20609
  // Settings: {"jsdoc":{"mode":"closure"}}
20528
20610
  // Message: Syntax error in namepath: R<~
20611
+
20612
+ /**
20613
+ * @suppress
20614
+ */
20615
+ function quux () {}
20616
+ // Settings: {"jsdoc":{"mode":"closure"}}
20617
+ // Message: Tag @suppress must have a type in "closure" mode.
20618
+
20619
+ /**
20620
+ * @suppress {visibility} sth
20621
+ */
20622
+ function quux () {}
20623
+ // Settings: {"jsdoc":{"mode":"closure"}}
20624
+ // Message: @suppress should not have a name in "closure" mode.
20625
+
20626
+ /**
20627
+ * @suppress {visibility|blah}
20628
+ */
20629
+ function quux () {}
20630
+ // Settings: {"jsdoc":{"mode":"closure"}}
20631
+ // Message: Syntax error in supresss type: blah
20529
20632
  ````
20530
20633
 
20531
20634
  The following patterns are not considered problems:
@@ -20841,6 +20944,13 @@ type ComplicatedType<T, U, V, W, X> = never
20841
20944
  */
20842
20945
  class quux {}
20843
20946
  // Settings: {"jsdoc":{"mode":"typescript"}}
20947
+
20948
+ /**
20949
+ * @suppress {visibility|underscore}
20950
+ */
20951
+ function quux() {
20952
+ }
20953
+ // Settings: {"jsdoc":{"mode":"closure"}}
20844
20954
  ````
20845
20955
 
20846
20956
 
@@ -140,7 +140,7 @@ const getDefaultTagStructureForMode = mode => {
140
140
  ['typeAllowed', true]])], ['see', new Map([// Signature allows for "namepath" or text, so user must configure to
141
141
  // 'namepath-referencing' to enforce checks
142
142
  ['nameContents', 'text']])], ['static', new Map([// Does not show a signature nor show curly brackets in the example
143
- ['typeAllowed', isClosureOrPermissive]])], ['template', new Map([['nameContents', isJsdoc ? 'text' : 'namepath-referencing'], // Though defines `nameContents: 'namepath-defining'` in a sense, it is
143
+ ['typeAllowed', isClosureOrPermissive]])], ['suppress', new Map([['nameContents', !isClosure], ['typeRequired', isClosure]])], ['template', new Map([['nameContents', isJsdoc ? 'text' : 'namepath-referencing'], // Though defines `nameContents: 'namepath-defining'` in a sense, it is
144
144
  // not parseable in the same way for template (e.g., allowing commas),
145
145
  // so not adding
146
146
  ['typeAllowed', isTypescriptOrClosure || isPermissive]])], ['this', new Map([// Signature seems to require a "namepath" (and no counter-examples)
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/getDefaultTagStructureForMode.js"],"names":["getDefaultTagStructureForMode","mode","isJsdoc","isClosure","isTypescript","isPermissive","isJsdocOrTypescript","isTypescriptOrClosure","isClosureOrPermissive","isJsdocTypescriptOrPermissive","Map"],"mappings":";;;;;;;AAAA,MAAMA,6BAA6B,GAAIC,IAAD,IAAU;AAC9C,QAAMC,OAAO,GAAGD,IAAI,KAAK,OAAzB;AACA,QAAME,SAAS,GAAGF,IAAI,KAAK,SAA3B;AACA,QAAMG,YAAY,GAAGH,IAAI,KAAK,YAA9B;AACA,QAAMI,YAAY,GAAGJ,IAAI,KAAK,YAA9B;AAEA,QAAMK,mBAAmB,GAAGJ,OAAO,IAAIE,YAAvC;AACA,QAAMG,qBAAqB,GAAGH,YAAY,IAAID,SAA9C;AACA,QAAMK,qBAAqB,GAAGL,SAAS,IAAIE,YAA3C;AACA,QAAMI,6BAA6B,GAAGH,mBAAmB,IAAID,YAA7D,CAT8C,CAW9C;AACA;AACA;AACA;A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AQ,CACf;AACA;AACA,GAAC,cAAD,EAAiBR,OAAO,GAAG,sBAAH,GAA4B,KAApD,CAHe,EAKf,CAAC,cAAD,EAAiBK,qBAAjB,CALe,EAOf;AACA,GAAC,oBAAD,EAAuBL,OAAvB,CARe,CAAR,CAAT,CA9Wa,EAyXb,CAAC,QAAD,EAAW,IAAIQ,GAAJ,CAAQ,CACjB;AACA,GAAC,aAAD,EAAgB,IAAhB,CAFiB,CAAR,CAAX,CAzXa,EA8Xb,CAAC,MAAD,EAAS,IAAIA,GAAJ,CAAQ,CACf;AACA;AACA,GAAC,cAAD,EAAiB,IAAjB,CAHe,CAAR,CAAT,CA9Xa,EAoYb,CAAC,SAAD,EAAY,IAAIA,GAAJ,CAAQ,CAClB;AACA;AACA,GAAC,cAAD,EAAiB,mBAAjB,CAHkB,EAKlB;AACA,GAAC,cAAD,EAAiBD,6BAAjB,CANkB,EAQlB;AACA,GAAC,aAAD,EAAgB,IAAhB,CATkB,EAWlB;AACA,GAAC,oBAAD,EAAuB,IAAvB,CAZkB,CAAR,CAAZ,CApYa,EAmZb,CAAC,KAAD,EAAQ,IAAIC,GAAJ,CAAQ,CACd;AACA,GAAC,cAAD,EAAiB,mBAAjB,CAFc,EAId;AACA,GAAC,aAAD,EAAgB,IAAhB,CALc,CAAR,CAAR,CAnZa,EA2Zb,CAAC,QAAD,EAAW,IAAIA,GAAJ,CAAQ,CACjB;AACA,GAAC,aAAD,EAAgB,IAAhB,CAFiB,CAAR,CAAX,CA3Za,EA+Zb,CAAC,OAAD,EAAU,IAAIA,GAAJ,CAAQ,CAChB;AACA,GAAC,aAAD,EAAgB,IAAhB,CAFgB,CAAR,CAAV,CA/Za,CAAR,CAAP;AAoaD,CA7cD;;eA+ceV,6B","sourcesContent":["const getDefaultTagStructureForMode = (mode) => {\n const isJsdoc = mode === 'jsdoc';\n const isClosure = mode === 'closure';\n const isTypescript = mode === 'typescript';\n const isPermissive = mode === 'permissive';\n\n const isJsdocOrTypescript = isJsdoc || isTypescript;\n const isTypescriptOrClosure = isTypescript || isClosure;\n const isClosureOrPermissive = isClosure || isPermissive;\n const isJsdocTypescriptOrPermissive = isJsdocOrTypescript || isPermissive;\n\n // Properties:\n // `nameContents` - 'namepath-referencing'|'namepath-defining'|'text'|false\n // `typeAllowed` - boolean\n // `nameRequired` - boolean\n // `typeRequired` - boolean\n // `typeOrNameRequired` - boolean\n\n // All of `typeAllowed` have a signature with \"type\" except for\n // `augments`/`extends` (\"namepath\")\n // `param`/`arg`/`argument` (no signature)\n // `property`/`prop` (no signature)\n // `modifies` (undocumented)\n\n // None of the `nameContents: 'namepath-defining'` show as having curly\n // brackets for their name/namepath\n\n // Among `namepath-defining` and `namepath-referencing`, these do not seem\n // to allow curly brackets in their doc signature or examples (`modifies`\n // references namepaths within its type brackets and `param` is\n // name-defining but not namepath-defining, so not part of these groups)\n\n // Todo: Should support special processing for \"name\" as distinct from\n // \"namepath\" (e.g., param can't define a namepath)\n\n // Once checking inline tags:\n // Todo: Re: `typeOrNameRequired`, `@link` (or @linkcode/@linkplain) seems\n // to require a namepath OR URL and might be checked as such.\n // Todo: Should support a `tutorialID` type (for `@tutorial` block and\n // inline)\n\n return new Map([\n ['alias', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['arg', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `param`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['argument', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `param`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['augments', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // Does not show curly brackets in either the signature or examples\n ['typeAllowed', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['borrows', new Map([\n // `borrows` has a different format, however, so needs special parsing;\n // seems to require both, and as \"namepath\"'s\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['callback', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', true],\n ])],\n\n ['class', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n\n ['const', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n ['constant', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n ['constructor', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n\n ['define', new Map([\n ['typeRequired', isClosure],\n ])],\n\n ['emits', new Map([\n // Signature seems to require a \"name\" (of an event) and no counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['enum', new Map([\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['event', new Map([\n // The doc signature of `event` seems to require a \"name\"\n ['nameRequired', true],\n\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['exception', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['export', new Map([\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['extends', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // Does not show curly brackets in either the signature or examples\n ['typeAllowed', isTypescriptOrClosure || isPermissive],\n\n ['nameRequired', isJsdoc],\n\n // \"namepath\"\n ['typeOrNameRequired', isTypescriptOrClosure || isPermissive],\n ])],\n\n ['external', new Map([\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n\n // \"name\" (and a special syntax for the `external` name)\n ['nameRequired', true],\n ])],\n\n ['fires', new Map([\n // Signature seems to require a \"name\" (of an event) and no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['function', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n ['func', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['host', new Map([\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n\n // See `external`\n ['nameRequired', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['interface', new Map([\n // Allows for \"name\" in signature, but indicates as optional\n [\n 'nameContents',\n isJsdocTypescriptOrPermissive ? 'namepath-defining' : false,\n ],\n ])],\n\n ['implements', new Map([\n // Shows curly brackets in the doc signature and examples\n // \"typeExpression\"\n ['typeRequired', true],\n ])],\n\n ['lends', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['listens', new Map([\n // Signature seems to require a \"name\" (of an event) and no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['member', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['memberof', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples),\n // though it allows an incomplete namepath ending with connecting symbol\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n ['memberof!', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples),\n // though it allows an incomplete namepath ending with connecting symbol\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['method', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n ['mixes', new Map([\n // Signature seems to require a \"OtherObjectPath\" with no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n\n // \"OtherObjectPath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['mixin', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['modifies', new Map([\n // Has no documentation, but test example has curly brackets, and\n // \"name\" would be suggested rather than \"namepath\" based on example;\n // not sure if name is required\n ['typeAllowed', true],\n ])],\n\n ['module', new Map([\n // Optional \"name\" and no curly brackets\n // this block impacts `no-undefined-types` and `valid-types` (search for\n // \"isNamepathDefiningTag|tagMightHaveNamepath|tagMightHaveEitherTypeOrNamePosition\")\n ['nameContents', isJsdoc ? 'namepath-defining' : 'text'],\n\n // Shows the signature with curly brackets but not in the example\n ['typeAllowed', true],\n ])],\n\n ['name', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['namespace', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Shows the signature with curly brackets but not in the example\n ['typeAllowed', true],\n ])],\n ['package', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['param', new Map([\n ['nameContents', 'namepath-defining'],\n\n // Though no signature provided requiring, per\n // https://jsdoc.app/tags-param.html:\n // \"The @param tag requires you to specify the name of the parameter you\n // are documenting.\"\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['private', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['prop', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `property`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['property', new Map([\n ['nameContents', 'namepath-defining'],\n\n // No docs indicate required, but since parallel to `param`, we treat as\n // such:\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['protected', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['public', new Map([\n // Does not show a signature nor show curly brackets in the example\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['returns', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ['return', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['see', new Map([\n // Signature allows for \"namepath\" or text, so user must configure to\n // 'namepath-referencing' to enforce checks\n ['nameContents', 'text'],\n ])],\n\n ['static', new Map([\n // Does not show a signature nor show curly brackets in the example\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['template', new Map([\n ['nameContents', isJsdoc ? 'text' : 'namepath-referencing'],\n\n // Though defines `nameContents: 'namepath-defining'` in a sense, it is\n // not parseable in the same way for template (e.g., allowing commas),\n // so not adding\n ['typeAllowed', isTypescriptOrClosure || isPermissive],\n ])],\n\n ['this', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n // Not used with namepath in Closure/TypeScript, however\n ['nameContents', isJsdoc ? 'namepath-referencing' : false],\n\n ['typeRequired', isTypescriptOrClosure],\n\n // namepath\n ['typeOrNameRequired', isJsdoc],\n ])],\n\n ['throws', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['type', new Map([\n // Shows curly brackets in the doc signature and examples\n // \"typeName\"\n ['typeRequired', true],\n ])],\n\n ['typedef', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', isJsdocTypescriptOrPermissive],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['var', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['yields', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ['yield', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ]);\n};\n\nexport default getDefaultTagStructureForMode;\n"],"file":"getDefaultTagStructureForMode.js"}
1
+ {"version":3,"sources":["../src/getDefaultTagStructureForMode.js"],"names":["getDefaultTagStructureForMode","mode","isJsdoc","isClosure","isTypescript","isPermissive","isJsdocOrTypescript","isTypescriptOrClosure","isClosureOrPermissive","isJsdocTypescriptOrPermissive","Map"],"mappings":";;;;;;;AAAA,MAAMA,6BAA6B,GAAIC,IAAD,IAAU;AAC9C,QAAMC,OAAO,GAAGD,IAAI,KAAK,OAAzB;AACA,QAAME,SAAS,GAAGF,IAAI,KAAK,SAA3B;AACA,QAAMG,YAAY,GAAGH,IAAI,KAAK,YAA9B;AACA,QAAMI,YAAY,GAAGJ,IAAI,KAAK,YAA9B;AAEA,QAAMK,mBAAmB,GAAGJ,OAAO,IAAIE,YAAvC;AACA,QAAMG,qBAAqB,GAAGH,YAAY,IAAID,SAA9C;AACA,QAAMK,qBAAqB,GAAGL,SAAS,IAAIE,YAA3C;AACA,QAAMI,6BAA6B,GAAGH,mBAAmB,IAAID,YAA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P;AAyaD,CAldD;;eAodeV,6B","sourcesContent":["const getDefaultTagStructureForMode = (mode) => {\n const isJsdoc = mode === 'jsdoc';\n const isClosure = mode === 'closure';\n const isTypescript = mode === 'typescript';\n const isPermissive = mode === 'permissive';\n\n const isJsdocOrTypescript = isJsdoc || isTypescript;\n const isTypescriptOrClosure = isTypescript || isClosure;\n const isClosureOrPermissive = isClosure || isPermissive;\n const isJsdocTypescriptOrPermissive = isJsdocOrTypescript || isPermissive;\n\n // Properties:\n // `nameContents` - 'namepath-referencing'|'namepath-defining'|'text'|false\n // `typeAllowed` - boolean\n // `nameRequired` - boolean\n // `typeRequired` - boolean\n // `typeOrNameRequired` - boolean\n\n // All of `typeAllowed` have a signature with \"type\" except for\n // `augments`/`extends` (\"namepath\")\n // `param`/`arg`/`argument` (no signature)\n // `property`/`prop` (no signature)\n // `modifies` (undocumented)\n\n // None of the `nameContents: 'namepath-defining'` show as having curly\n // brackets for their name/namepath\n\n // Among `namepath-defining` and `namepath-referencing`, these do not seem\n // to allow curly brackets in their doc signature or examples (`modifies`\n // references namepaths within its type brackets and `param` is\n // name-defining but not namepath-defining, so not part of these groups)\n\n // Todo: Should support special processing for \"name\" as distinct from\n // \"namepath\" (e.g., param can't define a namepath)\n\n // Once checking inline tags:\n // Todo: Re: `typeOrNameRequired`, `@link` (or @linkcode/@linkplain) seems\n // to require a namepath OR URL and might be checked as such.\n // Todo: Should support a `tutorialID` type (for `@tutorial` block and\n // inline)\n\n return new Map([\n ['alias', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['arg', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `param`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['argument', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `param`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['augments', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // Does not show curly brackets in either the signature or examples\n ['typeAllowed', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['borrows', new Map([\n // `borrows` has a different format, however, so needs special parsing;\n // seems to require both, and as \"namepath\"'s\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['callback', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', true],\n ])],\n\n ['class', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n\n ['const', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n ['constant', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n ['constructor', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n ['typeAllowed', true],\n ])],\n\n ['define', new Map([\n ['typeRequired', isClosure],\n ])],\n\n ['emits', new Map([\n // Signature seems to require a \"name\" (of an event) and no counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['enum', new Map([\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['event', new Map([\n // The doc signature of `event` seems to require a \"name\"\n ['nameRequired', true],\n\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['exception', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['export', new Map([\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['extends', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // Does not show curly brackets in either the signature or examples\n ['typeAllowed', isTypescriptOrClosure || isPermissive],\n\n ['nameRequired', isJsdoc],\n\n // \"namepath\"\n ['typeOrNameRequired', isTypescriptOrClosure || isPermissive],\n ])],\n\n ['external', new Map([\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n\n // \"name\" (and a special syntax for the `external` name)\n ['nameRequired', true],\n ])],\n\n ['fires', new Map([\n // Signature seems to require a \"name\" (of an event) and no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['function', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n ['func', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['host', new Map([\n // Appears to require a \"name\" in its signature, albeit somewhat\n // different from other \"name\"'s (including as described\n // at https://jsdoc.app/about-namepaths.html )\n ['nameContents', 'namepath-defining'],\n\n // See `external`\n ['nameRequired', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['interface', new Map([\n // Allows for \"name\" in signature, but indicates as optional\n [\n 'nameContents',\n isJsdocTypescriptOrPermissive ? 'namepath-defining' : false,\n ],\n ])],\n\n ['implements', new Map([\n // Shows curly brackets in the doc signature and examples\n // \"typeExpression\"\n ['typeRequired', true],\n ])],\n\n ['lends', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['listens', new Map([\n // Signature seems to require a \"name\" (of an event) and no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n ])],\n\n ['member', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['memberof', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples),\n // though it allows an incomplete namepath ending with connecting symbol\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n ['memberof!', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples),\n // though it allows an incomplete namepath ending with connecting symbol\n ['nameContents', 'namepath-referencing'],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['method', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n ['mixes', new Map([\n // Signature seems to require a \"OtherObjectPath\" with no\n // counter-examples\n ['nameContents', 'namepath-referencing'],\n\n // \"OtherObjectPath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['mixin', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n ])],\n\n ['modifies', new Map([\n // Has no documentation, but test example has curly brackets, and\n // \"name\" would be suggested rather than \"namepath\" based on example;\n // not sure if name is required\n ['typeAllowed', true],\n ])],\n\n ['module', new Map([\n // Optional \"name\" and no curly brackets\n // this block impacts `no-undefined-types` and `valid-types` (search for\n // \"isNamepathDefiningTag|tagMightHaveNamepath|tagMightHaveEitherTypeOrNamePosition\")\n ['nameContents', isJsdoc ? 'namepath-defining' : 'text'],\n\n // Shows the signature with curly brackets but not in the example\n ['typeAllowed', true],\n ])],\n\n ['name', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['namespace', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Shows the signature with curly brackets but not in the example\n ['typeAllowed', true],\n ])],\n ['package', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['param', new Map([\n ['nameContents', 'namepath-defining'],\n\n // Though no signature provided requiring, per\n // https://jsdoc.app/tags-param.html:\n // \"The @param tag requires you to specify the name of the parameter you\n // are documenting.\"\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['private', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['prop', new Map([\n ['nameContents', 'namepath-defining'],\n\n // See `property`\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['property', new Map([\n ['nameContents', 'namepath-defining'],\n\n // No docs indicate required, but since parallel to `param`, we treat as\n // such:\n ['nameRequired', true],\n\n // Has no formal signature in the docs but shows curly brackets\n // in the examples\n ['typeAllowed', true],\n ])],\n\n ['protected', new Map([\n // Shows the signature with curly brackets but not in the example\n // \"typeExpression\"\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['public', new Map([\n // Does not show a signature nor show curly brackets in the example\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['returns', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ['return', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['see', new Map([\n // Signature allows for \"namepath\" or text, so user must configure to\n // 'namepath-referencing' to enforce checks\n ['nameContents', 'text'],\n ])],\n\n ['static', new Map([\n // Does not show a signature nor show curly brackets in the example\n ['typeAllowed', isClosureOrPermissive],\n ])],\n\n ['suppress', new Map([\n ['nameContents', !isClosure],\n ['typeRequired', isClosure],\n ])],\n\n ['template', new Map([\n ['nameContents', isJsdoc ? 'text' : 'namepath-referencing'],\n\n // Though defines `nameContents: 'namepath-defining'` in a sense, it is\n // not parseable in the same way for template (e.g., allowing commas),\n // so not adding\n ['typeAllowed', isTypescriptOrClosure || isPermissive],\n ])],\n\n ['this', new Map([\n // Signature seems to require a \"namepath\" (and no counter-examples)\n // Not used with namepath in Closure/TypeScript, however\n ['nameContents', isJsdoc ? 'namepath-referencing' : false],\n\n ['typeRequired', isTypescriptOrClosure],\n\n // namepath\n ['typeOrNameRequired', isJsdoc],\n ])],\n\n ['throws', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n\n ['type', new Map([\n // Shows curly brackets in the doc signature and examples\n // \"typeName\"\n ['typeRequired', true],\n ])],\n\n ['typedef', new Map([\n // Seems to require a \"namepath\" in the signature (with no\n // counter-examples)\n ['nameContents', 'namepath-defining'],\n\n // \"namepath\"\n ['nameRequired', isJsdocTypescriptOrPermissive],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n\n // \"namepath\"\n ['typeOrNameRequired', true],\n ])],\n\n ['var', new Map([\n // Allows for \"name\"'s in signature, but indicated as optional\n ['nameContents', 'namepath-defining'],\n\n // Has example showing curly brackets but not in doc signature\n ['typeAllowed', true],\n ])],\n\n ['yields', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ['yield', new Map([\n // Shows curly brackets in the signature and in the examples\n ['typeAllowed', true],\n ])],\n ]);\n};\n\nexport default getDefaultTagStructureForMode;\n"],"file":"getDefaultTagStructureForMode.js"}
@@ -49,13 +49,7 @@ var _default = (0, _iterateJsdoc.default)(({
49
49
  } = context.options[0];
50
50
  const foundContext = contexts.find(cntxt => {
51
51
  return typeof cntxt === 'string' ? _esquery.default.matches(node, _esquery.default.parse(cntxt)) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(node, _esquery.default.parse(cntxt.context))) && comment === cntxt.comment;
52
- }); // We are not on the *particular* matching context/comment, so don't assume
53
- // we need reporting
54
-
55
- if (!foundContext) {
56
- return;
57
- }
58
-
52
+ });
59
53
  const contextStr = typeof foundContext === 'object' ? (_foundContext$context = foundContext.context) !== null && _foundContext$context !== void 0 ? _foundContext$context : 'any' : foundContext;
60
54
  setDefaults(state);
61
55
  incrementSelector(state, contextStr, comment);
@@ -121,6 +115,7 @@ var _default = (0, _iterateJsdoc.default)(({
121
115
  });
122
116
  },
123
117
 
118
+ matchContext: true,
124
119
  meta: {
125
120
  docs: {
126
121
  description: 'Reports when certain comment structures are always expected.',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/noMissingSyntax.js"],"names":["setDefaults","state","selectorMap","incrementSelector","selector","comment","context","node","info","options","contexts","foundContext","find","cntxt","esquery","matches","parse","contextStr","contextSelected","exit","length","report","loc","start","column","line","message","some","contextKey","undefined","minimum","Object","values","every","cmmnt","data","end","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA,MAAMA,WAAW,GAAIC,KAAD,IAAW;AAC7B,MAAI,CAACA,KAAK,CAACC,WAAX,EAAwB;AACtBD,IAAAA,KAAK,CAACC,WAAN,GAAoB,EAApB;AACD;AACF,CAJD;;AAMA,MAAMC,iBAAiB,GAAG,CAACF,KAAD,EAAQG,QAAR,EAAkBC,OAAlB,KAA8B;AACtD,MAAI,CAACJ,KAAK,CAACC,WAAN,CAAkBE,QAAlB,CAAL,EAAkC;AAChCH,IAAAA,KAAK,CAACC,WAAN,CAAkBE,QAAlB,IAA8B,EAA9B;AACD;;AAED,MAAI,CAACH,KAAK,CAACC,WAAN,CAAkBE,QAAlB,EAA4BC,OAA5B,CAAL,EAA2C;AACzCJ,IAAAA,KAAK,CAACC,WAAN,CAAkBE,QAAlB,EAA4BC,OAA5B,IAAuC,CAAvC;AACD;;AAEDJ,EAAAA,KAAK,CAACC,WAAN,CAAkBE,QAAlB,EAA4BC,OAA5B;AACD,CAVD;;eAYe,2BAAa,CAAC;AAC3BC,EAAAA,OAD2B;AAE3BC,EAAAA,IAF2B;AAG3BC,EAAAA,IAAI,EAAE;AAACH,IAAAA;AA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Fd;AAgCEA,MAAAA,IAAI,EAAE;AAhCR,KADM,CANJ;AA0CJA,IAAAA,IAAI,EAAE;AA1CF;AA5DL,CAjCY,C","sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n info: {comment},\n state,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n const {contexts} = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(node, esquery.parse(cntxt)) :\n (!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context))) &&\n comment === cntxt.comment;\n });\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 contextStr = typeof foundContext === 'object' ?\n foundContext.context ?? 'any' :\n foundContext;\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, comment);\n}, {\n contextSelected: true,\n exit ({\n context, state,\n }) {\n if (!context.options.length) {\n context.report({\n loc: {\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `context` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n const {\n contexts,\n } = context.options[0];\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = cntxt?.comment ?? '';\n\n const contextKey = contextStr === 'any' ? undefined : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (cntxt?.minimum ?? 1)) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (cntxt?.minimum ?? 1);\n }))\n ) {\n const message = cntxt?.message ?? 'Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {line: 1},\n start: {line: 1},\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-missing-syntax',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noMissingSyntax.js"}
1
+ {"version":3,"sources":["../../src/rules/noMissingSyntax.js"],"names":["setDefaults","state","selectorMap","incrementSelector","selector","comment","context","node","info","options","contexts","foundContext","find","cntxt","esquery","matches","parse","contextStr","contextSelected","exit","length","report","loc","start","column","line","message","some","contextKey","undefined","minimum","Object","values","every","cmmnt","data","end","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA,MAAMA,WAAW,GAAIC,KAAD,IAAW;AAC7B,MAAI,CAACA,KAAK,CAACC,WAAX,EAAwB;AACtBD,IAAAA,KAAK,CAACC,WAAN,GAAoB,EAApB;AACD;AACF,CAJD;;AAMA,MAAMC,iBAAiB,GAAG,CAACF,KAAD,EAAQG,QAAR,EAAkBC,OAAlB,KAA8B;AACtD,MAAI,CAACJ,KAAK,CAACC,WAAN,CAAkBE,QAAlB,CAAL,EAAkC;AAChCH,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cAAAA,UAAU,EAAE;AACVxC,gBAAAA,OAAO,EAAE;AACP2C,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIV1C,gBAAAA,OAAO,EAAE;AACP0C,kBAAAA,IAAI,EAAE;AADC,iBAJC;AAOVtB,gBAAAA,OAAO,EAAE;AACPsB,kBAAAA,IAAI,EAAE;AADC,iBAPC;AAUVlB,gBAAAA,OAAO,EAAE;AACPkB,kBAAAA,IAAI,EAAE;AADC;AAVC,eAFd;AAgBEA,cAAAA,IAAI,EAAE;AAhBR,aAJK;AADF,WADC;AA0BRA,UAAAA,IAAI,EAAE;AA1BE;AADA,OAFd;AAgCEA,MAAAA,IAAI,EAAE;AAhCR,KADM,CANJ;AA0CJA,IAAAA,IAAI,EAAE;AA1CF;AA7DL,CA3BY,C","sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n info: {comment},\n state,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n const {contexts} = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(node, esquery.parse(cntxt)) :\n (!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context))) &&\n comment === cntxt.comment;\n });\n\n const contextStr = typeof foundContext === 'object' ?\n foundContext.context ?? 'any' :\n foundContext;\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, comment);\n}, {\n contextSelected: true,\n exit ({\n context, state,\n }) {\n if (!context.options.length) {\n context.report({\n loc: {\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `context` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n const {\n contexts,\n } = context.options[0];\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = cntxt?.comment ?? '';\n\n const contextKey = contextStr === 'any' ? undefined : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (cntxt?.minimum ?? 1)) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (cntxt?.minimum ?? 1);\n }))\n ) {\n const message = cntxt?.message ?? 'Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {line: 1},\n start: {line: 1},\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-missing-syntax',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noMissingSyntax.js"}
@@ -65,10 +65,18 @@ var _default = (0, _iterateJsdoc.default)(({
65
65
  if (tags.length > 1) {
66
66
  report(`Found more than one @${tagName} declaration.`);
67
67
  return;
68
+ }
69
+
70
+ const [tag] = tags;
71
+ const returnNever = tag.type.trim() === 'never';
72
+
73
+ if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {
74
+ report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`);
75
+ return;
68
76
  } // In case a return value is declared in JSDoc, we also expect one in the code.
69
77
 
70
78
 
71
- if ((reportMissingReturnForUndefinedTypes || utils.hasDefinedTypeTag(tags[0])) && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) && (!exemptGenerators || !node.generator)) {
79
+ if (!returnNever && (reportMissingReturnForUndefinedTypes || utils.hasDefinedTypeTag(tag)) && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) && (!exemptGenerators || !node.generator)) {
72
80
  report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
73
81
  }
74
82
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/requireReturnsCheck.js"],"names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","hasDefinedTypeTag","hasValueOrExecutorHasNonEmptyResolveValue","generator","meta","docs","description","url","schema","additionalProperties","properties","default","type"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,OAAO,GAAG,CAACC,KAAD,EAAQC,QAAR,KAAqB;AACnC,QAAMC,WAAW,GAAG,CAClB;AACA;AACA;AACA;AACA;AACA,YANkB,EAOlB,SAPkB,EASlB;AACA;AACA,SAXkB,EAYlB,aAZkB,EAalB,WAbkB,CAApB;;AAgBA,MAAID,QAAQ,CAACE,IAAT,KAAkB,SAAtB,EAAiC;AAC/B;AACAD,IAAAA,WAAW,CAACE,IAAZ,CAAiB,QAAjB;AACD;;AAED,SAAOJ,KAAK,CAACK,OAAN,CAAcH,WAAd,KACLF,KAAK,CAACM,aAAN,EADK,IAELN,KAAK,CAACO,WAAN,CAAkB,WAAlB,CAFK,IAGLN,QAAQ,CAACE,IAAT,KAAkB,SAAlB,IAA+BH,KAAK,CAACO,WAAN,CAAkB,QAAlB,CAHjC;AAID,CA1BD;;eA4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I,EAAE;AACJC,MAAAA,WAAW,EAAE,iGADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVnB,QAAAA,WAAW,EAAE;AACXoB,UAAAA,OAAO,EAAE,IADE;AAEXC,UAAAA,IAAI,EAAE;AAFK,SADH;AAKVpB,QAAAA,gBAAgB,EAAE;AAChBoB,UAAAA,IAAI,EAAE;AADU,SALR;AAQVnB,QAAAA,oCAAoC,EAAE;AACpCkB,UAAAA,OAAO,EAAE,KAD2B;AAEpCC,UAAAA,IAAI,EAAE;AAF8B;AAR5B,OAFd;AAeEA,MAAAA,IAAI,EAAE;AAfR,KADM,CALJ;AAwBJA,IAAAA,IAAI,EAAE;AAxBF;AADL,CA5CY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.isAsync()) {\n return;\n }\n\n const tagName = utils.getPreferredTagName({tagName: 'returns'});\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if ((reportMissingReturnForUndefinedTypes || utils.hasDefinedTypeTag(tags[0])) && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) && (!exemptGenerators || !node.generator)) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireReturnsCheck.js"}
1
+ {"version":3,"sources":["../../src/rules/requireReturnsCheck.js"],"names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","returnNever","type","trim","hasValueOrExecutorHasNonEmptyResolveValue","hasDefinedTypeTag","generator","meta","docs","description","url","schema","additionalProperties","properties","default"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,OAAO,GAAG,CAACC,KAAD,EAAQC,QAAR,KAAqB;AACnC,QAAMC,WAAW,GAAG,CAClB;AACA;AACA;AACA;AACA;AACA,YANkB,EAOlB,SAPkB,EASlB;AACA;AACA,SAXkB,EAYlB,aAZkB,EAalB,WAbkB,CAApB;;AAgBA,MAAID,QAAQ,CAACE,IAAT,KAAkB,SAAtB,EAAiC;AAC/B;AACAD,IAAAA,WAAW,CAACE,IAAZ,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A,MAAIF,WAAW,IAAItB,KAAK,CAACyB,yCAAN,CAAgD,KAAhD,CAAnB,EAA2E;AACzEf,IAAAA,MAAM,CAAE,UAASM,OAAQ,6EAAnB,CAAN;AAEA;AACD,GAxCG,CA0CJ;;;AACA,MACE,CAACM,WAAD,KAEET,oCAAoC,IACpCb,KAAK,CAAC0B,iBAAN,CAAwBL,GAAxB,CAHF,KAKA,CAACrB,KAAK,CAACyB,yCAAN,CACCd,WADD,CALD,KAOM,CAACC,gBAAD,IAAqB,CAACH,IAAI,CAACkB,SAPjC,CADF,EASE;AACAjB,IAAAA,MAAM,CAAE,UAASM,OAAQ,uEAAnB,CAAN;AACD;AACF,CA7Dc,EA6DZ;AACDY,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,iGADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVvB,QAAAA,WAAW,EAAE;AACXwB,UAAAA,OAAO,EAAE,IADE;AAEXZ,UAAAA,IAAI,EAAE;AAFK,SADH;AAKVX,QAAAA,gBAAgB,EAAE;AAChBW,UAAAA,IAAI,EAAE;AADU,SALR;AAQVV,QAAAA,oCAAoC,EAAE;AACpCsB,UAAAA,OAAO,EAAE,KAD2B;AAEpCZ,UAAAA,IAAI,EAAE;AAF8B;AAR5B,OAFd;AAeEA,MAAAA,IAAI,EAAE;AAfR,KADM,CALJ;AAwBJA,IAAAA,IAAI,EAAE;AAxBF;AADL,CA7DY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.isAsync()) {\n return;\n }\n\n const tagName = utils.getPreferredTagName({tagName: 'returns'});\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [tag] = tags;\n\n const returnNever = tag.type.trim() === 'never';\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n utils.hasDefinedTypeTag(tag)\n ) &&\n !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) && (!exemptGenerators || !node.generator)\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireReturnsCheck.js"}
@@ -52,6 +52,10 @@ var _default = (0, _iterateJsdoc.default)(({
52
52
 
53
53
  const shouldReport = () => {
54
54
  if (!missingThrowsTag) {
55
+ if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {
56
+ report(`JSDoc @${tagName} declaration set to "never" but throw value found.`);
57
+ }
58
+
55
59
  return false;
56
60
  }
57
61
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/requireThrows.js"],"names":["canSkip","utils","hasATag","avoidDocs","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","hasThrowValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","context","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAIC,KAAD,IAAW;AACzB,SAAOA,KAAK,CAACC,OAAN,CAAc,CACnB;AACA;AACA;AACA;AACA;AACA,YANmB,EAOnB,SAPmB,EASnB;AACA,QAVmB,CAAd,KAYLD,KAAK,CAACE,SAAN,EAZF;AAaD,CAdD;;eAgBe,2BAAa,CAAC;AAC3BC,EAAAA,MAD2B;AAE3BH,EAAAA;AAF2B,CAAD,KAGtB;AACJ;AACA;AACA,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB;AAClB;AACD;;AAED,QAAMI,OAAO,GAAGJ,KAAK,CAACK,mBAAN,CAA0B;AAACD,IAAAA,OAAO,EAAE;AAAV,GAA1B,CAAhB;;AACA,MAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,QAAME,IAAI,GAAGN,KAAK,CAACO,OAAN,CAAcH,OAAd,CAAb;AACA,QAAMI,iBAAiB,GAAGR,KAAK,CAACS,mBAAN,EAA1B,CAbI,CAeJ;;AACA,QAAM,CAACC,GAAD,IAAQJ,IAAd;AAC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terateJsdoc from '../iterateJsdoc';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * @param {*} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = utils.getPreferredTagName({tagName: 'throws'});\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [tag] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-throws',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireThrows.js"}
1
+ {"version":3,"sources":["../../src/rules/requireThrows.js"],"names":["canSkip","utils","hasATag","avoidDocs","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","type","trim","hasThrowValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAIC,KAAD,IAAW;AACzB,SAAOA,KAAK,CAACC,OAAN,CAAc,CACnB;AACA;AACA;AACA;AACA;AACA,YANmB,EAOnB,SAPmB,EASnB;AACA,QAVmB,CAAd,KAYLD,KAAK,CAACE,SAAN,EAZF;AAaD,CAdD;;eAgBe,2BAAa,CAAC;AAC3BC,EAAAA,MAD2B;AAE3BH,EAAAA;AAF2B,CAAD,KAGtB;AACJ;AACA;AACA,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB;AAClB;AACD;;AAED,QAAMI,OAAO,GAAGJ,KAAK,CAACK,mBAAN,CAA0B;AAACD,IAAAA,OAAO,EAAE;AAAV,GAA1B,CAAhB;;AACA,MAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,QAAME,IAAI,GAAGN,KAAK,CAACO,OAAN,CAAcH,OAAd,CAAb;AACA,QAAMI,iBAAiB,GAAGR,KAAK,CAACS,mBAAN,EAA1B,CAbI,CAeJ;;AACA,QAAM,CAACC,GAAD,IAAQJ,IAAd;AACA,QAAMK,gBAAgB,GAAG,OAAOD,GAAP,KAAe,WAAf,IAA8BA,GAAG,KAAK,IAA/D;;AAEA,QAAME,YAAY,GAAG,MAAM;AACzB,QAAI,CAACD,gBAAL,EAAuB;AACrB,UAAID,GAAG,CAACG,IAAJ,CAASC,IAAT,OAAoB,OAApB,IAA+BN,iBAA/B,IAAoDR,KAAK,CAACe,aAAN,EAAxD,EAA+E;AAC7EZ,QAAAA,MAAM,CAAE,UAASC,OAAQ,oDAAnB,CAAN;AACD;;AAED,aAAO,KAAP;AACD;;AAED,WAAOI,iBAAiB,IAAIR,KAAK,CAACe,aAAN,EAA5B;AACD,GAVD;;AAYA,MAAIH,YAAY,EAAhB,EAAoB;AAClBT,IAAAA,MAAM,CAAE,kBAAiBC,OAAQ,eAA3B,CAAN;AACD;AACF,CArCc,EAqCZ;AACDY,EAAAA,eAAe,EAAE,IADhB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,gDADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVC,QAAAA,QAAQ,EAAE;AACRC,UAAAA,KAAK,EAAE;AACLC,YAAAA,KAAK,EAAE,CACL;AACEb,cAAAA,IAAI,EAAE;AADR,aADK,EAIL;AACES,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVI,gBAAAA,OAAO,EAAE;AACPd,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVe,gBAAAA,OAAO,EAAE;AACPf,kBAAAA,IAAI,EAAE;AADC;AAJC,eAFd;AAUEA,cAAAA,IAAI,EAAE;AAVR,aAJK;AADF,WADC;AAoBRA,UAAAA,IAAI,EAAE;AApBE,SADA;AAuBVgB,QAAAA,UAAU,EAAE;AACVJ,UAAAA,KAAK,EAAE;AACLZ,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI;AAvBF,OAFd;AAgCEA,MAAAA,IAAI,EAAE;AAhCR,KADM,CALJ;AAyCJA,IAAAA,IAAI,EAAE;AAzCF;AAFL,CArCY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * @param {*} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = utils.getPreferredTagName({tagName: 'throws'});\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [tag] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {\n report(`JSDoc @${tagName} declaration set to \"never\" but throw value found.`);\n }\n\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-throws',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireThrows.js"}
@@ -69,6 +69,14 @@ var _default = (0, _iterateJsdoc.default)(({
69
69
 
70
70
  if (preferredYieldTagName) {
71
71
  const shouldReportYields = () => {
72
+ if (yieldTag.type.trim() === 'never') {
73
+ if (utils.hasYieldValue()) {
74
+ report(`JSDoc @${preferredYieldTagName} declaration set with "never" but yield expression is present in function.`);
75
+ }
76
+
77
+ return false;
78
+ }
79
+
72
80
  if (checkGeneratorsOnly && !utils.isGenerator()) {
73
81
  return true;
74
82
  }
@@ -87,6 +95,14 @@ var _default = (0, _iterateJsdoc.default)(({
87
95
 
88
96
  if (preferredNextTagName) {
89
97
  const shouldReportNext = () => {
98
+ if (nextTag.type.trim() === 'never') {
99
+ if (utils.hasYieldReturnValue()) {
100
+ report(`JSDoc @${preferredNextTagName} declaration set with "never" but yield expression with return value is present in function.`);
101
+ }
102
+
103
+ return false;
104
+ }
105
+
90
106
  if (checkGeneratorsOnly && !utils.isGenerator()) {
91
107
  return true;
92
108
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/requireYieldsCheck.js"],"names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","checkTagName","report","tagName","preferredTagName","getPreferredTagName","tags","getTags","length","context","next","checkGeneratorsOnly","options","preferredYieldTagName","yieldTag","shouldReportYields","isGenerator","hasDefinedTypeTag","hasYieldValue","preferredNextTagName","nextTag","shouldReportNext","hasYieldReturnValue","meta","docs","description","url","schema","additionalProperties","properties","default","type","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,OAAO,GAAG,CAACC,KAAD,EAAQC,QAAR,KAAqB;AACnC,QAAMC,WAAW,GAAG,CAClB;AACA;AACA;AACA;AACA;AACA,YANkB,EAOlB,SAPkB,EASlB;AACA;AACA,SAXkB,EAYlB,aAZkB,EAclB;AACA,aAfkB,CAApB;;AAkBA,MAAID,QAAQ,CAACE,IAAT,KAAkB,SAAtB,EAAiC;AAC/B;AACAD,IAAAA,WAAW,CAACE,IAAZ,CAAiB,QAAjB;AACD;;AAED,SAAOJ,KAAK,CAACK,OAAN,CAAcH,WAAd,KACLF,KAAK,CAACM,aAAN,EADK,IAELN,KAAK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;AACEH,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVM,gBAAAA,OAAO,EAAE;AACPJ,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVtB,gBAAAA,OAAO,EAAE;AACPsB,kBAAAA,IAAI,EAAE;AADC;AAJC,eAFd;AAUEA,cAAAA,IAAI,EAAE;AAVR,aAJK;AADF,WADC;AAoBRA,UAAAA,IAAI,EAAE;AApBE,SALA;AA2BVK,QAAAA,UAAU,EAAE;AACVH,UAAAA,KAAK,EAAE;AACLF,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI,SA3BF;AAiCVrB,QAAAA,IAAI,EAAE;AACJoB,UAAAA,OAAO,EAAE,KADL;AAEJC,UAAAA,IAAI,EAAE;AAFF;AAjCI,OAFd;AAwCEA,MAAAA,IAAI,EAAE;AAxCR,KADM,CALJ;AAiDJA,IAAAA,IAAI,EAAE;AAjDF;AADL,CAnDY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a yield is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing yield.\n 'abstract',\n 'virtual',\n\n // Constructor functions do not have a yield value\n // so we can bail here, too.\n 'class',\n 'constructor',\n\n // This seems to imply a class as well\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = utils.getPreferredTagName({tagName});\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length === 0) {\n return [];\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n\n return [];\n }\n\n return [preferredTagName, tags[0]];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n settings,\n utils,\n}) => {\n if (canSkip(utils, settings)) {\n return;\n }\n\n const {\n next = false,\n checkGeneratorsOnly = false,\n } = context.options[0] || {};\n\n const [preferredYieldTagName, yieldTag] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(yieldTag) && !utils.hasYieldValue();\n };\n\n // In case a yield value is declared in JSDoc, we also expect one in the code.\n if (shouldReportYields()) {\n report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`);\n }\n }\n\n if (next) {\n const [preferredNextTagName, nextTag] = checkTagName(\n utils, report, 'next',\n );\n if (preferredNextTagName) {\n const shouldReportNext = () => {\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(nextTag) && !utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`);\n }\n }\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-yields-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkGeneratorsOnly: {\n default: false,\n type: 'boolean',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireYieldsCheck.js"}
1
+ {"version":3,"sources":["../../src/rules/requireYieldsCheck.js"],"names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","checkTagName","report","tagName","preferredTagName","getPreferredTagName","tags","getTags","length","context","next","checkGeneratorsOnly","options","preferredYieldTagName","yieldTag","shouldReportYields","type","trim","hasYieldValue","isGenerator","hasDefinedTypeTag","preferredNextTagName","nextTag","shouldReportNext","hasYieldReturnValue","meta","docs","description","url","schema","additionalProperties","properties","default","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,OAAO,GAAG,CAACC,KAAD,EAAQC,QAAR,KAAqB;AACnC,QAAMC,WAAW,GAAG,CAClB;AACA;AACA;AACA;AACA;AACA,YANkB,EAOlB,SAPkB,EASlB;AACA;AACA,SAXkB,EAYlB,aAZkB,EAclB;AACA,aAfkB,CAApB;;AAkBA,MAAID,QAAQ,CAACE,IAAT,KAAkB,SAAtB,EAAiC;AAC/B;AACAD,IAAAA,WAAW,CAACE,IAAZ,CAAiB,QAAjB;AACD;;AAED,SAAOJ,KAAK,CAACK,OAAN,CAAcH,WAAd,KACLF,KAAK,CAACM,aAAN,EADK,IAELN,KAAK,CAACO,WAAN,CAAkB,WAAlB,CAFK,IAGLN,QAAQ,CAACE,IAAT,KAAkB,SAAlB,IAA+BH,KAAK,CAACO,WAAN,CAAkB,QAAlB,CAHjC;AAID,CA5BD;;AA8BA,MAAMC,YAAY,GAAG,CAACR,KAAD,EAAQS,MAAR,EAAgBC,OAAhB,KAA4B;AAC/C,QAAMC,gBAAgB,GAAGX,KAAK,CAACY,mBAAN,CAA0B;AAACF,IAAAA;AAAD,GAA1B,CAAzB;;AACA,MAAI,CAACC,gBAAL,EAAuB;AACrB,WAAO,EAAP;AACD;;AAED,QAAME,IAAI,GAAGb,KAAK,CAACc,OAAN,CAAcH,gBAAd,CAAb;;AAEA,MAAIE,IAAI,CAACE,MAAL,KAAgB,CAApB,EAAuB;AACrB,WAAO,EAAP;AACD;;AAED,M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PpB,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVP,gBAAAA,OAAO,EAAE;AACPO,kBAAAA,IAAI,EAAE;AADC;AAJC,eAFd;AAUEA,cAAAA,IAAI,EAAE;AAVR,aAJK;AADF,WADC;AAoBRA,UAAAA,IAAI,EAAE;AApBE,SALA;AA2BVqB,QAAAA,UAAU,EAAE;AACVH,UAAAA,KAAK,EAAE;AACLlB,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI,SA3BF;AAiCVN,QAAAA,IAAI,EAAE;AACJsB,UAAAA,OAAO,EAAE,KADL;AAEJhB,UAAAA,IAAI,EAAE;AAFF;AAjCI,OAFd;AAwCEA,MAAAA,IAAI,EAAE;AAxCR,KADM,CALJ;AAiDJA,IAAAA,IAAI,EAAE;AAjDF;AADL,CAnEY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a yield is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing yield.\n 'abstract',\n 'virtual',\n\n // Constructor functions do not have a yield value\n // so we can bail here, too.\n 'class',\n 'constructor',\n\n // This seems to imply a class as well\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = utils.getPreferredTagName({tagName});\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length === 0) {\n return [];\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n\n return [];\n }\n\n return [preferredTagName, tags[0]];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n settings,\n utils,\n}) => {\n if (canSkip(utils, settings)) {\n return;\n }\n\n const {\n next = false,\n checkGeneratorsOnly = false,\n } = context.options[0] || {};\n\n const [preferredYieldTagName, yieldTag] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (yieldTag.type.trim() === 'never') {\n if (utils.hasYieldValue()) {\n report(`JSDoc @${preferredYieldTagName} declaration set with \"never\" but yield expression is present in function.`);\n }\n\n return false;\n }\n\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(yieldTag) && !utils.hasYieldValue();\n };\n\n // In case a yield value is declared in JSDoc, we also expect one in the code.\n if (shouldReportYields()) {\n report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`);\n }\n }\n\n if (next) {\n const [preferredNextTagName, nextTag] = checkTagName(\n utils, report, 'next',\n );\n if (preferredNextTagName) {\n const shouldReportNext = () => {\n if (nextTag.type.trim() === 'never') {\n if (utils.hasYieldReturnValue()) {\n report(`JSDoc @${preferredNextTagName} declaration set with \"never\" but yield expression with return value is present in function.`);\n }\n\n return false;\n }\n\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(nextTag) && !utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`);\n }\n }\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-yields-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkGeneratorsOnly: {\n default: false,\n type: 'boolean',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireYieldsCheck.js"}
@@ -12,6 +12,10 @@ var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
14
  const asExpression = /as\s+/u;
15
+ const suppressTypes = new Set([// https://github.com/google/closure-compiler/wiki/@suppress-annotations
16
+ // https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154
17
+ 'accessControls', 'checkDebuggerStatement', 'checkPrototypalTypes', 'checkRegExp', 'checkTypes', 'checkVars', 'closureDepMethodUsageChecks', 'const', 'constantProperty', 'deprecated', 'duplicate', 'es5Strict', 'externsValidation', 'extraProvide', 'extraRequire', 'globalThis', 'invalidCasts', 'lateProvide', 'legacyGoogScopeRequire', 'lintChecks', 'messageConventions', 'misplacedTypeAnnotation', 'missingOverride', 'missingPolyfill', 'missingProperties', 'missingProvide', 'missingRequire', 'missingSourcesWarnings', 'moduleLoad', 'nonStandardJsDocs', 'partialAlias', 'polymer', 'reportUnknownTypes', 'strictMissingProperties', 'strictModuleDepCheck', 'strictPrimitiveOperators', 'suspiciousCode', // Not documented in enum
18
+ 'switch', 'transitionalSuspiciousCodeWarnings', 'undefinedNames', 'undefinedVars', 'underscore', 'unknownDefines', 'untranspilableFeatures', 'unusedLocalVariables', 'unusedPrivateMembers', 'useOfGoogProvide', 'uselessCode', 'visibility', 'with']);
15
19
 
16
20
  const tryParsePathIgnoreError = path => {
17
21
  try {
@@ -120,6 +124,27 @@ var _default = (0, _iterateJsdoc.default)(({
120
124
  continue;
121
125
  }
122
126
 
127
+ if (tag.tag === 'suppress' && mode === 'closure') {
128
+ let parsedTypes;
129
+
130
+ try {
131
+ parsedTypes = (0, _jsdocTypePrattParser.tryParse)(tag.type);
132
+ } catch {// Ignore
133
+ }
134
+
135
+ if (parsedTypes) {
136
+ (0, _jsdocTypePrattParser.traverse)(parsedTypes, node => {
137
+ const {
138
+ value: type
139
+ } = node;
140
+
141
+ if (type !== undefined && !suppressTypes.has(type)) {
142
+ report(`Syntax error in supresss type: ${type}`, null, tag);
143
+ }
144
+ });
145
+ }
146
+ }
147
+
123
148
  const otherModeMaps = ['jsdoc', 'typescript', 'closure', 'permissive'].filter(mde => {
124
149
  return mde !== mode;
125
150
  }).map(mde => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/validTypes.js"],"names":["asExpression","tryParsePathIgnoreError","path","jsdoc","report","utils","context","settings","allowEmptyNamepaths","options","mode","tag","tags","validNamepathParsing","namepath","tagName","handled","startsWith","endChar","slice","includes","startChar","charAt","validTypeParsing","type","thisNamepath","getTagDescription","replace","trim","test","thatNamepath","name","otherModeMaps","filter","mde","map","getTagStructureForMode","tagMightHaveNamePosition","modeInfo","mightHaveTypePosition","tagMightHaveTypePosition","tagMustHaveNamePosition","mustHaveTypePosition","tagMustHaveTypePosition","tagMissingRequiredTypeOrNamepath","hasTypePosition","Boolean","hasNameOrNamepathPosition","tagMightHaveNamepath","parseClosureTemplateTag","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperies","properties","default"],"mappings":";;;;;;;AAAA;;AAGA;;;;AAEA,MAAMA,YAAY,GAAG,QAArB;;AAEA,MAAMC,uBAAuB,GAAIC,IAAD,IAAU;AACxC,MAAI;AACF,wCAASA,IAAT;AAEA,WAAO,IAAP;AACD,GAJD,CAIE,MAAM,CACN;AACD;;AAED,SAAO,KAAP;AACD,CAVD,C,CAYA;;;eACe,2BAAa,CAAC;AAC3BC,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA,KAH2B;AAI3BC,EAAAA,OAJ2B;AAK3BC,EAAAA;AAL2B,CAAD,KAMtB;AACJ,QAAM;AACJC,IAAAA,mBAAmB,GAAG;AADlB,MAEFF,OAAO,CA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AO,CAACnC,GAAG,CAACa,IAAL,CAAjE;;AACA,QAAIqB,eAAJ,EAAqB;AACnBtB,MAAAA,gBAAgB,CAACZ,GAAG,CAACa,IAAL,CAAhB;AACD,KAjJ2B,CAmJ5B;;;AACA,UAAMuB,yBAAyB,GAAG,CAChCN,uBAAuB,KAAK,KAA5B,IACApC,KAAK,CAAC2C,oBAAN,CAA2BrC,GAAG,CAACA,GAA/B,CAFgC,KAG7BmC,OAAO,CAACnC,GAAG,CAACoB,IAAL,CAHZ;;AAKA,QAAIgB,yBAAJ,EAA+B;AAC7B,UAAIrC,IAAI,KAAK,OAAT,IAAoBC,GAAG,CAACA,GAAJ,KAAY,UAApC,EAAgD;AAC9C,aAAK,MAAMG,QAAX,IAAuBT,KAAK,CAAC4C,uBAAN,CAA8BtC,GAA9B,CAAvB,EAA2D;AACzDE,UAAAA,oBAAoB,CAACC,QAAD,CAApB;AACD;AACF,OAJD,MAIO;AACLD,QAAAA,oBAAoB,CAACF,GAAG,CAACoB,IAAL,EAAWpB,GAAG,CAACA,GAAf,CAApB;AACD;AACF;AACF;AACF,CA/Kc,EA+KZ;AACDuC,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,uFADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACVjD,QAAAA,mBAAmB,EAAE;AACnBkD,UAAAA,OAAO,EAAE,KADU;AAEnBlC,UAAAA,IAAI,EAAE;AAFa;AADX,OAFd;AAQEA,MAAAA,IAAI,EAAE;AARR,KADM,CALJ;AAiBJA,IAAAA,IAAI,EAAE;AAjBF;AAFL,CA/KY,C","sourcesContent":["import {\n tryParse, parse,\n} from 'jsdoc-type-pratt-parser';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst asExpression = /as\\s+/u;\n\nconst tryParsePathIgnoreError = (path) => {\n try {\n tryParse(path);\n\n return true;\n } catch {\n // Keep the original error for including the whole type\n }\n\n return false;\n};\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n settings,\n}) => {\n const {\n allowEmptyNamepaths = false,\n } = context.options[0] || {};\n const {mode} = settings;\n\n for (const tag of jsdoc.tags) {\n const validNamepathParsing = function (namepath, tagName) {\n if (tryParsePathIgnoreError(namepath)) {\n return true;\n }\n\n let handled = false;\n\n if (tagName) {\n // eslint-disable-next-line default-case\n switch (tagName) {\n case 'module': {\n if (!namepath.startsWith('module:')) {\n handled = tryParsePathIgnoreError(`module:${namepath}`);\n }\n\n break;\n }\n\n case 'memberof': case 'memberof!': {\n const endChar = namepath.slice(-1);\n if (['#', '.', '~'].includes(endChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(0, -1));\n }\n\n break;\n }\n\n case 'borrows': {\n const startChar = namepath.charAt();\n if (['#', '.', '~'].includes(startChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(1));\n }\n }\n }\n }\n\n if (!handled) {\n report(`Syntax error in namepath: ${namepath}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n const validTypeParsing = function (type) {\n try {\n if (mode === 'permissive') {\n tryParse(type);\n } else {\n parse(type, mode);\n }\n } catch {\n report(`Syntax error in type: ${type}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n if (tag.tag === 'borrows') {\n const thisNamepath = utils.getTagDescription(tag).replace(asExpression, '')\n .trim();\n\n if (!asExpression.test(utils.getTagDescription(tag)) || !thisNamepath) {\n report(`@borrows must have an \"as\" expression. Found \"${utils.getTagDescription(tag)}\"`, null, tag);\n\n continue;\n }\n\n if (validNamepathParsing(thisNamepath, 'borrows')) {\n const thatNamepath = tag.name;\n\n validNamepathParsing(thatNamepath);\n }\n\n continue;\n }\n\n const otherModeMaps = ['jsdoc', 'typescript', 'closure', 'permissive'].filter(\n (mde) => {\n return mde !== mode;\n },\n ).map((mde) => {\n return utils.getTagStructureForMode(mde);\n });\n\n const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps);\n if (tagMightHaveNamePosition !== true && tag.name) {\n const modeInfo = tagMightHaveNamePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag);\n\n continue;\n }\n\n const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps);\n if (mightHaveTypePosition !== true && tag.type) {\n const modeInfo = mightHaveTypePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED NAME\n const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps);\n\n // Don't handle `@param` here though it does require name as handled by\n // `require-param-name` (`@property` would similarly seem to require one,\n // but is handled by `require-property-name`)\n if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![\n 'param', 'arg', 'argument',\n 'property', 'prop',\n ].includes(tag.tag) &&\n (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))\n ) {\n const modeInfo = tagMustHaveNamePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE\n const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);\n if (mustHaveTypePosition !== false && !tag.type) {\n const modeInfo = mustHaveTypePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE OR NAME/NAMEPATH\n const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps);\n if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) {\n const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // VALID TYPE\n const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);\n if (hasTypePosition) {\n validTypeParsing(tag.type);\n }\n\n // VALID NAME/NAMEPATH\n const hasNameOrNamepathPosition = (\n tagMustHaveNamePosition !== false ||\n utils.tagMightHaveNamepath(tag.tag)\n ) && Boolean(tag.name);\n\n if (hasNameOrNamepathPosition) {\n if (mode !== 'jsdoc' && tag.tag === 'template') {\n for (const namepath of utils.parseClosureTemplateTag(tag)) {\n validNamepathParsing(namepath);\n }\n } else {\n validNamepathParsing(tag.name, tag.tag);\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types',\n },\n schema: [\n {\n additionalProperies: false,\n properties: {\n allowEmptyNamepaths: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"validTypes.js"}
1
+ {"version":3,"sources":["../../src/rules/validTypes.js"],"names":["asExpression","suppressTypes","Set","tryParsePathIgnoreError","path","jsdoc","report","utils","context","settings","allowEmptyNamepaths","options","mode","tag","tags","validNamepathParsing","namepath","tagName","handled","startsWith","endChar","slice","includes","startChar","charAt","validTypeParsing","type","thisNamepath","getTagDescription","replace","trim","test","thatNamepath","name","parsedTypes","node","value","undefined","has","otherModeMaps","filter","mde","map","getTagStructureForMode","tagMightHaveNamePosition","modeInfo","mightHaveTypePosition","tagMightHaveTypePosition","tagMustHaveNamePosition","mustHaveTypePosition","tagMustHaveTypePosition","tagMissingRequiredTypeOrNamepath","hasTypePosition","Boolean","hasNameOrNamepathPosition","tagMightHaveNamepath","parseClosureTemplateTag","iterateAllJsdocs","meta","docs","description","url","schema","addition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AApB;AACD;AACF,OAJD,MAIO;AACLD,QAAAA,oBAAoB,CAACF,GAAG,CAACoB,IAAL,EAAWpB,GAAG,CAACA,GAAf,CAApB;AACD;AACF;AACF;AACF,CAlMc,EAkMZ;AACD4C,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,uFADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACVtD,QAAAA,mBAAmB,EAAE;AACnBuD,UAAAA,OAAO,EAAE,KADU;AAEnBvC,UAAAA,IAAI,EAAE;AAFa;AADX,OAFd;AAQEA,MAAAA,IAAI,EAAE;AARR,KADM,CALJ;AAiBJA,IAAAA,IAAI,EAAE;AAjBF;AAFL,CAlMY,C","sourcesContent":["import {\n tryParse, parse, traverse,\n} from 'jsdoc-type-pratt-parser';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst asExpression = /as\\s+/u;\n\nconst suppressTypes = new Set([\n // https://github.com/google/closure-compiler/wiki/@suppress-annotations\n // https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154\n 'accessControls',\n 'checkDebuggerStatement',\n 'checkPrototypalTypes',\n 'checkRegExp',\n 'checkTypes',\n 'checkVars',\n 'closureDepMethodUsageChecks',\n 'const',\n 'constantProperty',\n 'deprecated',\n 'duplicate',\n 'es5Strict',\n 'externsValidation',\n 'extraProvide',\n 'extraRequire',\n 'globalThis',\n 'invalidCasts',\n 'lateProvide',\n 'legacyGoogScopeRequire',\n 'lintChecks',\n 'messageConventions',\n 'misplacedTypeAnnotation',\n 'missingOverride',\n 'missingPolyfill',\n 'missingProperties',\n 'missingProvide',\n 'missingRequire',\n 'missingSourcesWarnings',\n 'moduleLoad',\n 'nonStandardJsDocs',\n 'partialAlias',\n 'polymer',\n 'reportUnknownTypes',\n 'strictMissingProperties',\n 'strictModuleDepCheck',\n 'strictPrimitiveOperators',\n 'suspiciousCode',\n\n // Not documented in enum\n 'switch',\n 'transitionalSuspiciousCodeWarnings',\n 'undefinedNames',\n 'undefinedVars',\n 'underscore',\n 'unknownDefines',\n 'untranspilableFeatures',\n 'unusedLocalVariables',\n 'unusedPrivateMembers',\n 'useOfGoogProvide',\n 'uselessCode',\n 'visibility',\n 'with',\n]);\n\nconst tryParsePathIgnoreError = (path) => {\n try {\n tryParse(path);\n\n return true;\n } catch {\n // Keep the original error for including the whole type\n }\n\n return false;\n};\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n settings,\n}) => {\n const {\n allowEmptyNamepaths = false,\n } = context.options[0] || {};\n const {mode} = settings;\n\n for (const tag of jsdoc.tags) {\n const validNamepathParsing = function (namepath, tagName) {\n if (tryParsePathIgnoreError(namepath)) {\n return true;\n }\n\n let handled = false;\n\n if (tagName) {\n // eslint-disable-next-line default-case\n switch (tagName) {\n case 'module': {\n if (!namepath.startsWith('module:')) {\n handled = tryParsePathIgnoreError(`module:${namepath}`);\n }\n\n break;\n }\n\n case 'memberof': case 'memberof!': {\n const endChar = namepath.slice(-1);\n if (['#', '.', '~'].includes(endChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(0, -1));\n }\n\n break;\n }\n\n case 'borrows': {\n const startChar = namepath.charAt();\n if (['#', '.', '~'].includes(startChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(1));\n }\n }\n }\n }\n\n if (!handled) {\n report(`Syntax error in namepath: ${namepath}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n const validTypeParsing = function (type) {\n try {\n if (mode === 'permissive') {\n tryParse(type);\n } else {\n parse(type, mode);\n }\n } catch {\n report(`Syntax error in type: ${type}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n if (tag.tag === 'borrows') {\n const thisNamepath = utils.getTagDescription(tag).replace(asExpression, '')\n .trim();\n\n if (!asExpression.test(utils.getTagDescription(tag)) || !thisNamepath) {\n report(`@borrows must have an \"as\" expression. Found \"${utils.getTagDescription(tag)}\"`, null, tag);\n\n continue;\n }\n\n if (validNamepathParsing(thisNamepath, 'borrows')) {\n const thatNamepath = tag.name;\n\n validNamepathParsing(thatNamepath);\n }\n\n continue;\n }\n\n if (tag.tag === 'suppress' && mode === 'closure') {\n let parsedTypes;\n\n try {\n parsedTypes = tryParse(tag.type);\n } catch {\n // Ignore\n }\n\n if (parsedTypes) {\n traverse(parsedTypes, (node) => {\n const {value: type} = node;\n if (type !== undefined && !suppressTypes.has(type)) {\n report(`Syntax error in supresss type: ${type}`, null, tag);\n }\n });\n }\n }\n\n const otherModeMaps = ['jsdoc', 'typescript', 'closure', 'permissive'].filter(\n (mde) => {\n return mde !== mode;\n },\n ).map((mde) => {\n return utils.getTagStructureForMode(mde);\n });\n\n const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps);\n if (tagMightHaveNamePosition !== true && tag.name) {\n const modeInfo = tagMightHaveNamePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag);\n\n continue;\n }\n\n const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps);\n if (mightHaveTypePosition !== true && tag.type) {\n const modeInfo = mightHaveTypePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED NAME\n const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps);\n\n // Don't handle `@param` here though it does require name as handled by\n // `require-param-name` (`@property` would similarly seem to require one,\n // but is handled by `require-property-name`)\n if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![\n 'param', 'arg', 'argument',\n 'property', 'prop',\n ].includes(tag.tag) &&\n (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))\n ) {\n const modeInfo = tagMustHaveNamePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE\n const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);\n if (mustHaveTypePosition !== false && !tag.type) {\n const modeInfo = mustHaveTypePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE OR NAME/NAMEPATH\n const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps);\n if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) {\n const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // VALID TYPE\n const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);\n if (hasTypePosition) {\n validTypeParsing(tag.type);\n }\n\n // VALID NAME/NAMEPATH\n const hasNameOrNamepathPosition = (\n tagMustHaveNamePosition !== false ||\n utils.tagMightHaveNamepath(tag.tag)\n ) && Boolean(tag.name);\n\n if (hasNameOrNamepathPosition) {\n if (mode !== 'jsdoc' && tag.tag === 'template') {\n for (const namepath of utils.parseClosureTemplateTag(tag)) {\n validNamepathParsing(namepath);\n }\n } else {\n validNamepathParsing(tag.name, tag.tag);\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types',\n },\n schema: [\n {\n additionalProperies: false,\n properties: {\n allowEmptyNamepaths: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"validTypes.js"}
package/package.json CHANGED
@@ -107,5 +107,5 @@
107
107
  "test-index": "cross-env BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 12000 test/rules/index.js",
108
108
  "test-no-cov": "cross-env BABEL_ENV=test mocha --reporter dot --recursive --require @babel/register --timeout 12000"
109
109
  },
110
- "version": "37.2.6"
110
+ "version": "37.4.0"
111
111
  }