Created
September 16, 2018 06:01
-
-
Save phenomnomnominal/69a685048fdcba627b36a1b535f08403 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
const FAILURE_MESSAGE = (filter: string) => ` | |
Remember to remove "${filter}" once you have finished working on tests. | |
`; | |
class NoFDescribeOrFItWalker extends AbstractWalker { | |
public walk (sourceFile: SourceFile) { | |
const walkNode = (node: Node): void => { | |
if (node.kind === SyntaxKind.CallExpression) { | |
if (node.expression.kind === SyntaxKind.Identifier) { | |
if (node.name === 'fdescribe' || node.name === 'fit') { | |
this.addFailureAtNode(node, FAILURE_MESSAGE(text)); | |
} | |
} | |
} | |
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