Created
September 16, 2018 06:39
-
-
Save phenomnomnominal/5110392042c5bda05537f2f644471ab8 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
// Dependencies: | |
import { tsquery } from '@phenomnomnominal/tsquery'; | |
import { Fix, Replacement, RuleFailure, Rules } from 'tslint'; | |
import { SourceFile } from 'typescript'; | |
// Constants: | |
const FDESCRIBE_FIT_QUERY = 'CallExpression > Identifier[name=/^f(describe|it)$/]'; | |
const FAILURE_MESSAGE = (filter: string) => ` | |
Remember to remove "${filter}" once you have finished working on tests. | |
`; | |
export class Rule extends Rules.AbstractRule { | |
public apply (sourceFile: SourceFile): Array<RuleFailure> { | |
return tsquery(sourceFile, FDESCRIBE_FIT_QUERY).map(result => { | |
return new RuleFailure(result.getSourceFile(), result.getStart(), result.getEnd(), FAILURE_MESSAGE(result.name as string), this.ruleName); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment