Skip to content

Commit 4742385

Browse files
devversionmatsko
authored andcommitted
refactor(core): fix misleading tslint schematic message (angular#29320)
Fixes the incorrect failure message or the TSLint rule that is used within Google. The TSLint rule is not part of the public schematic code. Additionally in order to make it easier to understand what action the developer needs to take, we rather print out the expected "static: true/false" statement instead of saying that a query needs to be static or dynamic. Dynamic is ambiguous, as there is no `dynamic: true` option. PR Close angular#29320
1 parent d87b035 commit 4742385

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/core/schematics/migrations/static-queries/google3/explicitQueryTimingRule.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {NgQueryResolveVisitor} from '../angular/ng_query_visitor';
1414
import {QueryTiming} from '../angular/query-definition';
1515
import {getTransformedQueryCallExpr} from '../transform';
1616

17-
const FAILURE_MESSAGE = 'Query does explicitly specify its timing. Read more here: ' +
17+
const FAILURE_MESSAGE = 'Query does not explicitly specify its timing. Read more here: ' +
1818
'https://github.com/angular/angular/pull/28810';
1919

2020
/**
@@ -57,9 +57,8 @@ export class Rule extends Rules.TypedRule {
5757
// Replace the existing query decorator call expression with the
5858
// updated call expression node.
5959
const fix = new Replacement(queryExpr.getStart(), queryExpr.getWidth(), newText);
60-
const timingStr = timing === QueryTiming.STATIC ? 'static' : 'dynamic';
6160
const failureMessage = `${FAILURE_MESSAGE}. Based on analysis of the query it can be ` +
62-
`marked as "${timingStr}".`;
61+
`marked as "{static: ${(timing === QueryTiming.STATIC).toString()}}".`;
6362

6463
failures.push(new RuleFailure(
6564
sourceFile, queryExpr.getStart(), queryExpr.getWidth(), failureMessage, this.ruleName,

packages/core/schematics/test/google3/explicit_query_timing_rule_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('Google3 explicitQueryTiming TSLint rule', () => {
109109
const failures = linter.getResult().failures;
110110

111111
expect(failures.length).toBe(1);
112-
expect(failures[0].getFailure()).toMatch(/analysis of the query.*"static"/);
112+
expect(failures[0].getFailure()).toMatch(/analysis of the query.*"{static: true}"/);
113113
});
114114

115115
it('should report non-explicit dynamic query definitions', () => {
@@ -126,6 +126,6 @@ describe('Google3 explicitQueryTiming TSLint rule', () => {
126126
const failures = linter.getResult().failures;
127127

128128
expect(failures.length).toBe(1);
129-
expect(failures[0].getFailure()).toMatch(/analysis of the query.*"dynamic"/);
129+
expect(failures[0].getFailure()).toMatch(/analysis of the query.*"{static: false}"/);
130130
});
131131
});

0 commit comments

Comments
 (0)