Created
September 16, 2018 05:41
-
-
Save phenomnomnominal/2d3f63c2eea5fcf48aa353dc56e2710e to your computer and use it in GitHub Desktop.
Walking a TypeScript AST and looking for an Identifier inside a CallExpression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbstractWalker } from 'tslint'; | |
import { forEachChild, Node, SourceFile, SyntaxKind } from 'typescript'; | |
class NoFDescribeOrFItWalker extends AbstractWalker { | |
public walk (sourceFile: SourceFile) { | |
const walkNode = (node: Node): void => { | |
if (node.kind === SyntaxKind.CallExpression) { | |
if (node.expression.kind === SyntaxKind.Identifier) { | |
// possible rule match! | |
} | |
} | |
return forEachChild(node, walkNode); | |
}; | |
return forEachChild(sourceFile, walkNode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🙏 Thanks you