1 | import * as Lint from "tslint";
|
2 | import * as ts from "typescript";
|
3 |
|
4 | import { GeneralRuleUtils } from "./utils/GeneralRuleUtils";
|
5 |
|
6 | const RULE_ID = "tsf-folders-test-with-breakpoint";
|
7 |
|
8 | export class Rule extends Lint.Rules.AbstractRule {
|
9 | apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
10 | if (!GeneralRuleUtils.isInTestFile(sourceFile.fileName)) {
|
11 | return [];
|
12 | }
|
13 |
|
14 | const walker = new StatementsWalker(sourceFile, this.getOptions());
|
15 | this.applyWithWalker(walker);
|
16 |
|
17 | return walker.getFailures();
|
18 | }
|
19 | }
|
20 |
|
21 | class StatementsWalker extends Lint.RuleWalker {
|
22 | visitCallExpression(node: ts.CallExpression) {
|
23 | const text = node.getText();
|
24 |
|
25 | if (text.startsWith("browser.debug")) {
|
26 | this.addFailureAtNode(
|
27 | node.getFirstToken(),
|
28 | GeneralRuleUtils.buildFailureString("do not hard code breakpoints in the test", RULE_ID)
|
29 | );
|
30 | }
|
31 |
|
32 | super.visitCallExpression(node);
|
33 | }
|
34 | }
|