MCPcopy
hub / github.com/lingodotdev/lingo.dev / _hasFileDirective

Function _hasFileDirective

packages/compiler/src/utils/index.ts:201–214  ·  view source on GitHub ↗
(ast: t.Node, directiveValue: string)

Source from the content-addressed store, hash-verified

199}
200
201function _hasFileDirective(ast: t.Node, directiveValue: string): boolean {
202 let hasDirective = false;
203
204 traverse(ast, {
205 Directive(path: NodePath<t.Directive>) {
206 if (path.node.value.value === directiveValue) {
207 hasDirective = true;
208 path.stop(); // Stop traversal as soon as we find the directive
209 }
210 },
211 });
212
213 return hasDirective;
214}
215
216export function hasI18nDirective(ast: t.Node): boolean {
217 return _hasFileDirective(ast, "use i18n");

Callers 3

hasI18nDirectiveFunction · 0.85
hasClientDirectiveFunction · 0.85
hasServerDirectiveFunction · 0.85

Calls 1

traverseFunction · 0.50

Tested by

no test coverage detected