eslint-plugin-jsdoc 37.2.5 → 37.2.6

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
@@ -8548,6 +8548,25 @@ function quux () {
8548
8548
  */
8549
8549
  function quux () {
8550
8550
 
8551
+ }
8552
+ // "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(1))","context":":function"}]}]
8553
+ // Message: Syntax is required: :function with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
8554
+
8555
+ /**
8556
+ * @private
8557
+ * Object holding values of some custom enum
8558
+ */
8559
+ const MY_ENUM = Object.freeze({
8560
+ VAL_A: "myvala"
8561
+ } as const);
8562
+ // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=/private|protected/])","context":":declaration","message":"Requiring private/protected tags here"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":"any","message":"@enum required on declarations"}]}]
8563
+ // Message: @enum required on declarations
8564
+
8565
+ /**
8566
+ * @implements {Bar|Foo}
8567
+ */
8568
+ function quux () {
8569
+
8551
8570
  }
8552
8571
  // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"Problematically missing function syntax: `{{context}}` with `{{comment}}`."}]}]
8553
8572
  // Message: Problematically missing function syntax: `FunctionDeclaration` with `JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))`.
@@ -8955,6 +8974,15 @@ function quux () {
8955
8974
  */
8956
8975
  function quux () {
8957
8976
 
8977
+ }
8978
+ // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","message":"The bar one: {{context}}."},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"The foo one: {{context}}."}]}]
8979
+ // Message: The bar one: FunctionDeclaration.
8980
+
8981
+ /**
8982
+ * @implements {Bar|Foo}
8983
+ */
8984
+ function quux () {
8985
+
8958
8986
  }
8959
8987
  // Message: Rule `no-restricted-syntax` is missing a `context` option.
8960
8988
 
@@ -8996,6 +9024,16 @@ function a () {}
8996
9024
  */
8997
9025
  // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
8998
9026
  // Message: Only allowing names not matching `/^opt_/i`.
9027
+
9028
+ /**
9029
+ * @enum {String}
9030
+ * Object holding values of some custom enum
9031
+ */
9032
+ const MY_ENUM = Object.freeze({
9033
+ VAL_A: "myvala"
9034
+ } as const);
9035
+ // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag ~ JsdocTag[tag=/private|protected/])","context":"any","message":"Access modifier tags must come first"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":":declaration","message":"@enum not allowed on declarations"}]}]
9036
+ // Message: @enum not allowed on declarations
8999
9037
  ````
9000
9038
 
9001
9039
  The following patterns are not considered problems:
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _esquery = _interopRequireDefault(require("esquery"));
9
+
8
10
  var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
9
11
 
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -28,14 +30,35 @@ const incrementSelector = (state, selector, comment) => {
28
30
  };
29
31
 
30
32
  var _default = (0, _iterateJsdoc.default)(({
33
+ context,
34
+ node,
31
35
  info: {
32
- selector,
33
36
  comment
34
37
  },
35
38
  state
36
39
  }) => {
40
+ var _foundContext$context;
41
+
42
+ if (!context.options[0]) {
43
+ // Handle error later
44
+ return;
45
+ }
46
+
47
+ const {
48
+ contexts
49
+ } = context.options[0];
50
+ const foundContext = contexts.find(cntxt => {
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
+
59
+ const contextStr = typeof foundContext === 'object' ? (_foundContext$context = foundContext.context) !== null && _foundContext$context !== void 0 ? _foundContext$context : 'any' : foundContext;
37
60
  setDefaults(state);
38
- incrementSelector(state, selector, comment);
61
+ incrementSelector(state, contextStr, comment);
39
62
  }, {
40
63
  contextSelected: true,
41
64
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/noMissingSyntax.js"],"names":["setDefaults","state","selectorMap","incrementSelector","selector","comment","info","contextSelected","exit","context","options","length","report","loc","start","column","line","message","contexts","some","cntxt","contextStr","contextKey","undefined","minimum","Object","values","every","cmmnt","data","end","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,WAAW,GAAIC,KAAD,IAAW;AAC7B,MAAI,CAACA,KAAK,CAACC,WAAX,EAAwB;AACtBD,IAAAA,KAAK,CAACC,W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AAG,EAAE;AACHiB,YAAAA,GAAG,EAAE;AAACd,cAAAA,IAAI,EAAE;AAAP,aADF;AAEHF,YAAAA,KAAK,EAAE;AAACE,cAAAA,IAAI,EAAE;AAAP;AAFJ,WALQ;AASbC,UAAAA;AATa,SAAf;AAYA,eAAO,IAAP;AACD;;AAED,aAAO,KAAP;AACD,KAhCD;AAiCD,GA3DA;;AA4DDc,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,8DADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVpB,QAAAA,QAAQ,EAAE;AACRqB,UAAAA,KAAK,EAAE;AACLC,YAAAA,KAAK,EAAE,CACL;AACEC,cAAAA,IAAI,EAAE;AADR,aADK,EAIL;AACEJ,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVjC,gBAAAA,OAAO,EAAE;AACPoC,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVhC,gBAAAA,OAAO,EAAE;AACPgC,kBAAAA,IAAI,EAAE;AADC,iBAJC;AAOVxB,gBAAAA,OAAO,EAAE;AACPwB,kBAAAA,IAAI,EAAE;AADC,iBAPC;AAUVjB,gBAAAA,OAAO,EAAE;AACPiB,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;AA5DL,CAPY,C","sourcesContent":["import 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 info: {selector, comment},\n state,\n}) => {\n setDefaults(state);\n\n incrementSelector(state, selector, 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","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;AAAD,GAHqB;AAI3BJ,EAAAA;AAJ2B,CAAD,KAKtB;AAAA;;AACJ,MAAI,CAACK,OAAO,CAACG,OAAR,CAAgB,CAAhB,CAAL,EAAyB;AACvB;AACA;AACD;;AAED,QAAM;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doc';\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"}
@@ -5,14 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _esquery = _interopRequireDefault(require("esquery"));
9
+
8
10
  var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
9
11
 
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  var _default = (0, _iterateJsdoc.default)(({
15
+ node,
13
16
  context,
14
17
  info: {
15
- selector,
16
18
  comment
17
19
  },
18
20
  report
@@ -28,7 +30,7 @@ var _default = (0, _iterateJsdoc.default)(({
28
30
  contexts
29
31
  } = context.options[0];
30
32
  const foundContext = contexts.find(cntxt => {
31
- return cntxt === selector || typeof cntxt === 'object' && (!cntxt.context || cntxt.context === 'any' || selector === cntxt.context) && comment === cntxt.comment;
33
+ 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;
32
34
  }); // We are not on the *particular* matching context/comment, so don't assume
33
35
  // we need reporting
34
36
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rules/noRestrictedSyntax.js"],"names":["context","info","selector","comment","report","options","length","contexts","foundContext","find","cntxt","contextStr","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required"],"mappings":";;;;;;;AAAA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,IAAI,EAAE;AAACC,IAAAA,QAAD;AAAWC,IAAAA;AAAX,GAFqB;AAG3BC,EAAAA;AAH2B,CAAD,KAItB;AAAA;;AACJ,MAAI,CAACJ,OAAO,CAACK,OAAR,CAAgBC,MAArB,EAA6B;AAC3BF,IAAAA,MAAM,CAAC,4DAAD,CAAN;AAEA;AACD;;AAED,QAAM;AAACG,IAAAA;AAAD,MAAaP,OAAO,CAACK,OAAR,CAAgB,CAAhB,CAAnB;AAEA,QAAMG,YAAY,GAAGD,QAAQ,CAACE,IAAT,CAAeC,KAAD,IAAW;AAC5C,WAAOA,KAAK,KAAKR,QAAV,IACL,OAAOQ,KAAP,KAAiB,QAAjB,KACC,CAACA,KAAK,CAACV,OAAP,IAAkBU,KAAK,CAACV,OAAN,KAAkB,KAApC,IAA6CE,QAAQ,KAAKQ,KAAK,CAACV,OADjE,KAEEG,OAAO,KAAKO,KAAK,CAACP,OAHtB;AAID,GALoB,CAArB,CATI,CAgBJ;AACA;;AACA,MAAI,CAACK,YAAL,EAAmB;AACjB;AACD;;AAED,QAAMG,UAAU,GAAG,OAAOH,YAAP,KAAwB,QAAxB,4BACjBA,YAAY,CAACR,OADI,yEACO,KADP,GAEjBQ,YAFF;AAGA,QAAMI,OAAO,4BAAGJ,YAAH,aAAGA,YAAH,uBAAGA,YAAY,CAAEI,OAAjB,yEACX,oCADF;AAGAR,EAAAA,MAAM,CAACQ,OAAD,EAAU,IAAV,EAAgB,IAAhB,EAAsB;AAC1BZ,IAAAA,OAAO,EAAEW;AADiB,GAAtB,CAAN;AAGD,CAnCc,EAmCZ;AACDE,EAAAA,eAAe,EAAE,IADhB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,sDADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVd,QAAAA,QAAQ,EAAE;AACRe,UAAAA,KAAK,EAAE;AACLC,YAAAA,KAAK,EAAE,CACL;AACEC,cAAAA,IAAI,EAAE;AADR,aADK,EAIL;AACEJ,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVlB,gBAAAA,OAAO,EAAE;AACPqB,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVxB,gBAAAA,OAAO,EAAE;AACPwB,kBAAAA,IAAI,EAAE;AADC,iBAJC;AAOVZ,gBAAAA,OAAO,EAAE;AACPY,kBAAAA,IAAI,EAAE;AADC;AAPC,eAFd;AAaEA,cAAAA,IAAI,EAAE;AAbR,aAJK;AADF,WADC;AAuBRA,UAAAA,IAAI,EAAE;AAvBE;AADA,OAFd;AA6BEC,MAAAA,QAAQ,EAAE,CAAC,UAAD,CA7BZ;AA8BED,MAAAA,IAAI,EAAE;AA9BR,KADM,CANJ;AAwCJA,IAAAA,IAAI,EAAE;AAxCF;AAFL,CAnCY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n info: {selector, comment},\n report,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `context` option.');\n\n return;\n }\n\n const {contexts} = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n return cntxt === selector ||\n typeof cntxt === 'object' &&\n (!cntxt.context || cntxt.context === 'any' || selector === 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 const message = foundContext?.message ??\n 'Syntax is restricted: {{context}}.';\n\n report(message, null, null, {\n context: contextStr,\n });\n}, {\n contextSelected: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are present.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-restricted-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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: ['contexts'],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noRestrictedSyntax.js"}
1
+ {"version":3,"sources":["../../src/rules/noRestrictedSyntax.js"],"names":["node","context","info","comment","report","options","length","contexts","foundContext","find","cntxt","esquery","matches","parse","contextStr","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required"],"mappings":";;;;;;;AAAA;;AACA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,IAD2B;AAE3BC,EAAAA,OAF2B;AAG3BC,EAAAA,IAAI,EAAE;AAACC,IAAAA;AAAD,GAHqB;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AAAA;;AACJ,MAAI,CAACH,OAAO,CAACI,OAAR,CAAgBC,MAArB,EAA6B;AAC3BF,IAAAA,MAAM,CAAC,4DAAD,CAAN;AAEA;AACD;;AAED,QAAM;AAACG,IAAAA;AAAD,MAAaN,OAAO,CAACI,OAAR,CAAgB,CAAhB,CAAnB;AAEA,QAAMG,YAAY,GAAGD,QAAQ,CAACE,IAAT,CAAeC,KAAD,IAAW;AAC5C,WAAO,OAAOA,KAAP,KAAiB,QAAjB,GACLC,iBAAQC,OAAR,CAAgBZ,IAA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B,kBAAAA,IAAI,EAAE;AADC,iBAJC;AAOVZ,gBAAAA,OAAO,EAAE;AACPY,kBAAAA,IAAI,EAAE;AADC;AAPC,eAFd;AAaEA,cAAAA,IAAI,EAAE;AAbR,aAJK;AADF,WADC;AAuBRA,UAAAA,IAAI,EAAE;AAvBE;AADA,OAFd;AA6BEC,MAAAA,QAAQ,EAAE,CAAC,UAAD,CA7BZ;AA8BED,MAAAA,IAAI,EAAE;AA9BR,KADM,CANJ;AAwCJA,IAAAA,IAAI,EAAE;AAxCF;AAFL,CApCY,C","sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n node,\n context,\n info: {comment},\n report,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `context` option.');\n\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 const message = foundContext?.message ??\n 'Syntax is restricted: {{context}}.';\n\n report(message, null, null, {\n context: contextStr,\n });\n}, {\n contextSelected: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are present.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-restricted-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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: ['contexts'],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noRestrictedSyntax.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.5"
110
+ "version": "37.2.6"
111
111
  }