MCPcopy Create free account
hub / github.com/angular/components / apply

Method apply

tools/tslint-rules/noNestedTernaryRule.ts:6–20  ·  view source on GitHub ↗
(sourceFile: ts.SourceFile)

Source from the content-addressed store, hash-verified

4/** Rule that enforces that ternary expressions aren't being nested. */
5export 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. */

Callers

nothing calls this directly

Calls 2

hasNestedTernaryFunction · 0.85
getOptionsMethod · 0.45

Tested by

no test coverage detected