mirror of
https://github.com/angular/angular.git
synced 2026-11-29 09:57:50 -05:00
For quite a while it is an unspoken convention to add a trailing new-line files within the Angular repository. This was never enforced automatically, but has been frequently raised in pull requests through manual review. This commit sets up a lint rule so that this is "officially" enforced and doesn't require manual review. PR Close #42478
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {assertDefined, throwError} from '../util/assert';
|
|
import {TNode, TNodeType, toTNodeTypeAsString} from './interfaces/node';
|
|
|
|
export function assertTNodeType(
|
|
tNode: TNode|null, expectedTypes: TNodeType, message?: string): void {
|
|
assertDefined(tNode, 'should be called with a TNode');
|
|
if ((tNode.type & expectedTypes) === 0) {
|
|
throwError(
|
|
message ||
|
|
`Expected [${toTNodeTypeAsString(expectedTypes)}] but got ${
|
|
toTNodeTypeAsString(tNode.type)}.`);
|
|
}
|
|
}
|
|
|
|
export function assertPureTNodeType(type: TNodeType) {
|
|
if (!(type === TNodeType.Element || //
|
|
type === TNodeType.Text || //
|
|
type === TNodeType.Container || //
|
|
type === TNodeType.ElementContainer || //
|
|
type === TNodeType.Icu || //
|
|
type === TNodeType.Projection || //
|
|
type === TNodeType.Placeholder)) {
|
|
throwError(`Expected TNodeType to have only a single type selected, but got ${
|
|
toTNodeTypeAsString(type)}.`);
|
|
}
|
|
}
|