From 131a02f3ff566aa5fa4c559b32aebc79f202ad07 Mon Sep 17 00:00:00 2001 From: Stoyan Kolev <36141982+CloudNStoyan@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:27:41 +0200 Subject: [PATCH] fix: tsoa rule not acknowledging success response decorator (#23) * fix valid-alternative-response rule to acknowledge SuccessResponse decorator * bump version --- eslint-plugin-tsoa/package.json | 2 +- eslint-plugin-tsoa/src/eslint-plugin-tsoa.ts | 2 +- .../src/rules/valid-alternative-response.test.ts | 11 +++++++++++ .../src/rules/valid-alternative-response.ts | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/eslint-plugin-tsoa/package.json b/eslint-plugin-tsoa/package.json index bb00a91..81a1509 100644 --- a/eslint-plugin-tsoa/package.json +++ b/eslint-plugin-tsoa/package.json @@ -1,6 +1,6 @@ { "name": "@arabasta/eslint-plugin-tsoa", - "version": "1.1.0", + "version": "1.1.1", "type": "commonjs", "description": "ESLint plugin for tsoa rules", "author": "Stoyan Kolev", diff --git a/eslint-plugin-tsoa/src/eslint-plugin-tsoa.ts b/eslint-plugin-tsoa/src/eslint-plugin-tsoa.ts index 513cc4a..253dba3 100644 --- a/eslint-plugin-tsoa/src/eslint-plugin-tsoa.ts +++ b/eslint-plugin-tsoa/src/eslint-plugin-tsoa.ts @@ -15,7 +15,7 @@ import requirePropertyExampleDecoratorRule from './rules/require-property-exampl const plugin = { meta: { name: '@arabasta/eslint-plugin-tsoa', - version: '1.1.0', + version: '1.1.1', }, configs: {}, rules: { diff --git a/eslint-plugin-tsoa/src/rules/valid-alternative-response.test.ts b/eslint-plugin-tsoa/src/rules/valid-alternative-response.test.ts index 814fe4e..b3cf773 100644 --- a/eslint-plugin-tsoa/src/rules/valid-alternative-response.test.ts +++ b/eslint-plugin-tsoa/src/rules/valid-alternative-response.test.ts @@ -55,6 +55,17 @@ ruleTester.run( } `, }, + { + name: 'when this.noContentResult is used in a method that has the `@SuccessResponse` decorator', + code: normalizeIndent` + class User { + @SuccessResponse(204) + getAllUsers() { + return this.noContentResult(); + } + } + `, + }, { name: 'when this.noContentResult is used in a method that is inside a class that has the correct response decorator', code: normalizeIndent` diff --git a/eslint-plugin-tsoa/src/rules/valid-alternative-response.ts b/eslint-plugin-tsoa/src/rules/valid-alternative-response.ts index 176cd84..c4ae885 100644 --- a/eslint-plugin-tsoa/src/rules/valid-alternative-response.ts +++ b/eslint-plugin-tsoa/src/rules/valid-alternative-response.ts @@ -133,6 +133,10 @@ export default createRule({ node, decoratorName: 'Response', }), + ...getAllDecoratorsWithName({ + node, + decoratorName: 'SuccessResponse', + }), ...getAllDecoratorsWithName({ node: currentClassDeclarationNode, decoratorName: 'Response',