Skip to content

Commit

Permalink
fix(eslint-plugin-nestjs-tools): improve ambiguous condition
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Sep 19, 2024
1 parent 74f04bf commit 6821758
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/eslint-plugin/src/lib/return-class-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,16 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({
if (extractedTypes.every(isValidReturnType)) {
return;
}
const returnStatements = node.value?.body?.body?.filter((node) => node.type === 'ReturnStatement') ?? [];
const methodReturnsClassInstance = returnStatements.every((returnStatement) =>
returnStatement.argument
? doesReturnClassInstance(returnStatement.argument, typeName, extractedTypes)
: false,
);

const returnStatements = node.value?.body?.body?.filter((node) => node.type === 'ReturnStatement');
const methodReturnsClassInstance = returnStatements
? returnStatements.every((returnStatement) =>
returnStatement.argument
? doesReturnClassInstance(returnStatement.argument, typeName, extractedTypes)
: false,
)
: false;

if (!methodReturnsClassInstance) {
context.report({
node,
Expand Down

0 comments on commit 6821758

Please sign in to comment.