eslint-plugin-jsdoc 51.1.3 → 51.2.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.
@@ -16,6 +16,7 @@ const removeType = ({
16
16
  tokens.type = '';
17
17
  };
18
18
  var _default = exports.default = (0, _iterateJsdoc.default)(({
19
+ node,
19
20
  utils
20
21
  }) => {
21
22
  if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {
@@ -31,10 +32,22 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
31
32
  });
32
33
  }
33
34
  }
35
+ if (node?.type === 'ClassDeclaration') {
36
+ const propertyTags = utils.getPresentTags(['prop', 'property']);
37
+ for (const tag of propertyTags) {
38
+ if (tag.type) {
39
+ utils.reportJSDoc(`Types are not permitted on @${tag.tag} in the supplied context.`, tag, () => {
40
+ for (const source of tag.source) {
41
+ removeType(source);
42
+ }
43
+ });
44
+ }
45
+ }
46
+ }
34
47
  }, {
35
48
  contextDefaults: ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
36
49
  // Add this to above defaults
37
- 'TSMethodSignature'],
50
+ 'TSMethodSignature', 'ClassDeclaration'],
38
51
  meta: {
39
52
  docs: {
40
53
  description: 'This rule reports types being used on `@param` or `@returns`.',
@@ -1 +1 @@
1
- {"version":3,"file":"noTypes.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","removeType","tokens","postTag","type","_default","exports","iterateJsdoc","utils","isIteratingFunction","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {import('comment-parser').Line} line\n */\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n utils,\n}) => {\n if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n}, {\n contextDefaults: [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature',\n ],\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header',\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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA,MAAMG,UAAU,GAAGA,CAAC;EAClBC;AACF,CAAC,KAAK;EACJA,MAAM,CAACC,OAAO,GAAG,EAAE;EACnBD,MAAM,CAACE,IAAI,GAAG,EAAE;AAClB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEa,IAAAO,qBAAY,EAAC,CAAC;EAC3BC;AACF,CAAC,KAAK;EACJ,IAAI,CAACA,KAAK,CAACC,mBAAmB,CAAC,CAAC,IAAI,CAACD,KAAK,CAACE,iBAAiB,CAAC,CAAC,EAAE;IAC9D;EACF;EAEA,MAAM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efault","require","e","__esModule","default","removeType","tokens","postTag","type","_default","exports","iterateJsdoc","node","utils","isIteratingFunction","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","propertyTags","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {import('comment-parser').Line} line\n */\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n node,\n utils,\n}) => {\n if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n\n if (node?.type === 'ClassDeclaration') {\n const propertyTags = utils.getPresentTags([\n 'prop', 'property',\n ]);\n for (const tag of propertyTags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag} in the supplied context.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n }\n}, {\n contextDefaults: [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature', 'ClassDeclaration',\n ],\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header',\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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n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KAAK,CAACM,WAAW,CAAC,+BAA+BD,GAAG,CAACA,GAAG,2BAA2B,EAAEA,GAAG,EAAE,MAAM;UAC9F,KAAK,MAAME,MAAM,IAAIF,GAAG,CAACE,MAAM,EAAE;YAC/Bf,UAAU,CAACe,MAAM,CAAC;UACpB;QACF,CAAC,CAAC;MACJ;IACF;EACF;AACF,CAAC,EAAE;EACDE,eAAe,EAAE,CACf,yBAAyB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB;EAC3F;EACA,mBAAmB,EAAE,kBAAkB,CACxC;EACDC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,+DAA+D;MAC5EC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEzB,IAAI,EAAE;YACR,CAAC,EACD;cACEqB,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACP1B,IAAI,EAAE;gBACR,CAAC;gBACD2B,OAAO,EAAE;kBACP3B,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA4B,MAAA,CAAA1B,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
package/package.json CHANGED
@@ -160,5 +160,5 @@
160
160
  "test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
161
161
  "test-index": "npm run test-no-cov -- test/rules/index.js"
162
162
  },
163
- "version": "51.1.3"
163
+ "version": "51.2.0"
164
164
  }
@@ -11,6 +11,7 @@ const removeType = ({
11
11
  };
12
12
 
13
13
  export default iterateJsdoc(({
14
+ node,
14
15
  utils,
15
16
  }) => {
16
17
  if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {
@@ -30,11 +31,26 @@ export default iterateJsdoc(({
30
31
  });
31
32
  }
32
33
  }
34
+
35
+ if (node?.type === 'ClassDeclaration') {
36
+ const propertyTags = utils.getPresentTags([
37
+ 'prop', 'property',
38
+ ]);
39
+ for (const tag of propertyTags) {
40
+ if (tag.type) {
41
+ utils.reportJSDoc(`Types are not permitted on @${tag.tag} in the supplied context.`, tag, () => {
42
+ for (const source of tag.source) {
43
+ removeType(source);
44
+ }
45
+ });
46
+ }
47
+ }
48
+ }
33
49
  }, {
34
50
  contextDefaults: [
35
51
  'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
36
52
  // Add this to above defaults
37
- 'TSMethodSignature',
53
+ 'TSMethodSignature', 'ClassDeclaration',
38
54
  ],
39
55
  meta: {
40
56
  docs: {