From c9fec08cc8a75689d034a75a13cddc319daf688d Mon Sep 17 00:00:00 2001 From: Quramy Date: Fri, 15 Mar 2024 12:30:20 +0900 Subject: [PATCH] chore: Remove unused functions --- src/ts-ast-util/tag-utils.test.ts | 24 ++---------------------- src/ts-ast-util/tag-utils.ts | 12 ------------ 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/ts-ast-util/tag-utils.test.ts b/src/ts-ast-util/tag-utils.test.ts index b2a47367..eeab862f 100644 --- a/src/ts-ast-util/tag-utils.test.ts +++ b/src/ts-ast-util/tag-utils.test.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; -import { findAllNodes, findNode } from './utilily-functions'; +import { findAllNodes } from './utilily-functions'; import type { TagConfig, StrictTagCondition } from './types'; -import { parseTagConfig, getTemplateNodeUnder, isTagged, getTagName } from './tag-utils'; +import { parseTagConfig, getTemplateNodeUnder, getTagName } from './tag-utils'; describe(parseTagConfig, () => { test.each([ @@ -190,23 +190,3 @@ describe(getTagName, () => { expect(actual).toBe(undefined); }); }); - -describe(isTagged, () => { - it('should return true when the tag condition is matched', () => { - // prettier-ignore - const text = 'function myTag(...args: any[]) { return "" }' + '\n' - + 'const x = myTag`query { }`'; - const s = ts.createSourceFile('input.ts', text, ts.ScriptTarget.Latest, true); - const node = findNode(s, text.length - 3) as ts.Node; - expect(isTagged(node, 'myTag')).toBeTruthy(); - }); - - it('should return true when the tag condition is not matched', () => { - // prettier-ignore - const text = 'function myTag(...args: any[]) { return "" }' + '\n' - + 'const x = myTag`query { }`'; - const s = ts.createSourceFile('input.ts', text, ts.ScriptTarget.Latest, true); - const node = findNode(s, text.length - 3) as ts.Node; - expect(isTagged(node, 'MyTag')).toBeFalsy(); - }); -}); diff --git a/src/ts-ast-util/tag-utils.ts b/src/ts-ast-util/tag-utils.ts index 8c8f4b41..573f9247 100644 --- a/src/ts-ast-util/tag-utils.ts +++ b/src/ts-ast-util/tag-utils.ts @@ -92,15 +92,3 @@ export function getTagName( } return undefined; } - -export function hasTagged(node: ts.Node | undefined, condition: string | undefined, source?: ts.SourceFile) { - if (!node) return; - if (!ts.isTaggedTemplateExpression(node)) return false; - const tagNode = node; - return tagNode.tag.getText(source) === condition; -} - -export function isTagged(node: ts.Node | undefined, condition: string | undefined, source?: ts.SourceFile) { - if (!node) return false; - return hasTagged(node.parent, condition, source); -}