| 12345678910111213141516171819202122232425262728293031323334 |
- import * as ESTree from 'estree';
- import { NodeGuards } from './NodeGuards';
- export class NodeLiteralUtils {
- /**
- * @param {Literal} literalNode
- * @returns {literalNode is (SimpleLiteral & {value: string})}
- */
- public static isStringLiteralNode (literalNode: ESTree.Literal): literalNode is ESTree.Literal & {value: string} {
- return typeof literalNode.value === 'string';
- }
- /**
- * @param {Literal} literalNode
- * @param {Node} parentNode
- * @returns {boolean}
- */
- public static isProhibitedLiteralNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): boolean {
- if (NodeGuards.isPropertyNode(parentNode) && !parentNode.computed && parentNode.key === literalNode) {
- return true;
- }
- if (NodeGuards.isImportDeclarationNode(parentNode)) {
- return true;
- }
- if (NodeGuards.isExportAllDeclarationNode(parentNode) || NodeGuards.isExportNamedDeclarationNode(parentNode)) {
- return true;
- }
- return false;
- }
- }
|