(sourceFile: ts.SourceFile)
| 4 | /** Rule that enforces that ternary expressions aren't being nested. */ |
| 5 | export class Rule extends Lint.Rules.AbstractRule { |
| 6 | apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { |
| 7 | return this.applyWithFunction( |
| 8 | sourceFile, |
| 9 | context => { |
| 10 | (function walk(node: ts.Node) { |
| 11 | if (!ts.isConditionalExpression(node)) { |
| 12 | ts.forEachChild(node, walk); |
| 13 | } else if (hasNestedTernary(node)) { |
| 14 | context.addFailureAtNode(node, 'Nested ternary expression are not allowed.'); |
| 15 | } |
| 16 | })(context.sourceFile); |
| 17 | }, |
| 18 | this.getOptions().ruleArguments, |
| 19 | ); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /** Checks whether a ternary expression has another ternary inside of it. */ |
nothing calls this directly
no test coverage detected