Skip to content

Commit 746ee88

Browse files
committedFeb 13, 2024·
feat: update function name
1 parent e3eed25 commit 746ee88

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
 

‎lib/plugin/utils/ast-utils.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,25 @@ export function getTsDocTagsOfNode(node: Node, typeChecker: TypeChecker) {
228228
return tagResults;
229229
}
230230

231-
export function getTsDocReturnsOrErrorOfNode(node: Node) {
231+
export function getTsDocErrorsOfNode(node: Node) {
232232
const tsdocParser: TSDocParser = new TSDocParser();
233233
const parserContext: ParserContext = tsdocParser.parseString(
234234
node.getFullText()
235235
);
236236
const docComment: DocComment = parserContext.docComment;
237237

238238
const tagResults = [];
239+
const errorParsingRegex = /{(\d+)} (.*)/;
240+
239241
const introspectTsDocTags = (docComment: DocComment) => {
240-
const blocks = docComment.customBlocks.filter((block) =>
241-
['@throws', '@returns'].includes(block.blockTag.tagName)
242+
const blocks = docComment.customBlocks.filter(
243+
(block) => block.blockTag.tagName === '@throws'
242244
);
243245

244246
blocks.forEach((block) => {
245247
try {
246248
const docValue = renderDocNode(block.content).split('\n')[0].trim();
247-
const regex = /{(\d+)} (.*)/;
248-
const match = docValue.match(regex);
249+
const match = docValue.match(errorParsingRegex);
249250
tagResults.push({
250251
status: match[1],
251252
description: `"${match[2]}"`

‎lib/plugin/visitors/controller-class.visitor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
getDecoratorArguments,
1010
getDecoratorName,
1111
getMainCommentOfNode,
12-
getTsDocReturnsOrErrorOfNode,
12+
getTsDocErrorsOfNode,
1313
getTsDocTagsOfNode
1414
} from '../utils/ast-utils';
1515
import {
@@ -353,7 +353,7 @@ export class ControllerClassVisitor extends AbstractFileVisitor {
353353
}
354354
}
355355

356-
const tags = getTsDocReturnsOrErrorOfNode(node);
356+
const tags = getTsDocErrorsOfNode(node);
357357
if (!tags.length) {
358358
return [];
359359
}

0 commit comments

Comments
 (0)
Please sign in to comment.