From 1b731713683d67c630a485bf9f8c680d1bc718af Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 24 Jun 2024 19:52:05 +0800 Subject: [PATCH] fix(`no-types`): add `TSMethodSignature`; fixes #1249 --- src/rules/noTypes.js | 6 +++++- test/rules/assertions/noTypes.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/rules/noTypes.js b/src/rules/noTypes.js index 527891a15..5f7e5b835 100644 --- a/src/rules/noTypes.js +++ b/src/rules/noTypes.js @@ -31,7 +31,11 @@ export default iterateJsdoc(({ } } }, { - contextDefaults: true, + contextDefaults: [ + 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction', + // Add this to above defaults + 'TSMethodSignature' + ], meta: { docs: { description: 'This rule reports types being used on `@param` or `@returns`.', diff --git a/test/rules/assertions/noTypes.js b/test/rules/assertions/noTypes.js index e323d8167..6c2bfb789 100644 --- a/test/rules/assertions/noTypes.js +++ b/test/rules/assertions/noTypes.js @@ -1,3 +1,5 @@ +import * as typescriptEslintParser from '@typescript-eslint/parser'; + export default { invalid: [ { @@ -226,6 +228,33 @@ export default { } `, }, + { + code: ` + export interface B { + /** + * @param {string} paramA + */ + methodB(paramB: string): void + } + `, + errors: [ + { + line: 4, + message: 'Types are not permitted on @param.', + }, + ], + languageOptions: { + parser: typescriptEslintParser + }, + output: ` + export interface B { + /** + * @param paramA + */ + methodB(paramB: string): void + } + `, + } ], valid: [ {