(ast: t.Node, directiveValue: string)
| 199 | } |
| 200 | |
| 201 | function _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 | |
| 216 | export function hasI18nDirective(ast: t.Node): boolean { |
| 217 | return _hasFileDirective(ast, "use i18n"); |
no test coverage detected