refactor(docs-infra): fix docs examples for tslint rule prefer-const
(#38143)
This commit updates the docs examples to be compatible with the `prefer-const` tslint rule. This is in preparation of updating the docs examples `tslint.json` to match the one generated for new Angular CLI apps in a future commit. PR Close #38143
This commit is contained in:

committed by
Alex Rickabaugh

parent
07a003352d
commit
01db37435f
@ -6,7 +6,7 @@ describe('Testing Example', () => {
|
||||
beforeAll(() => browser.get(''));
|
||||
|
||||
function getPageElts() {
|
||||
let navElts = element.all(by.css('app-root nav a'));
|
||||
const navElts = element.all(by.css('app-root nav a'));
|
||||
|
||||
return {
|
||||
navElts,
|
||||
@ -20,13 +20,13 @@ describe('Testing Example', () => {
|
||||
});
|
||||
|
||||
it(`has views ${expectedViewNames}`, async () => {
|
||||
let viewNames = getPageElts().navElts.map(async (el: ElementFinder) => await el.getText());
|
||||
const viewNames = getPageElts().navElts.map(async (el: ElementFinder) => await el.getText());
|
||||
|
||||
expect(viewNames).toEqual(expectedViewNames);
|
||||
});
|
||||
|
||||
it('has dashboard as the active view', () => {
|
||||
let page = getPageElts();
|
||||
const page = getPageElts();
|
||||
|
||||
expect(page.appDashboard.isPresent()).toBeTruthy();
|
||||
});
|
||||
|
@ -28,13 +28,13 @@ export class DashboardComponent implements OnInit {
|
||||
|
||||
// #docregion goto-detail
|
||||
gotoDetail(hero: Hero) {
|
||||
let url = `/heroes/${hero.id}`;
|
||||
const url = `/heroes/${hero.id}`;
|
||||
this.router.navigateByUrl(url);
|
||||
}
|
||||
// #enddocregion goto-detail
|
||||
|
||||
get title() {
|
||||
let cnt = this.heroes.length;
|
||||
const cnt = this.heroes.length;
|
||||
return cnt === 0 ? 'No Heroes' :
|
||||
cnt === 1 ? 'Top Hero' : `Top ${cnt} Heroes`;
|
||||
}
|
||||
|
@ -310,11 +310,11 @@ export class MyIfChildComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
|
||||
for (let propName in changes) {
|
||||
for (const propName in changes) {
|
||||
this.ngOnChangesCounter += 1;
|
||||
let prop = changes[propName];
|
||||
let cur = JSON.stringify(prop.currentValue);
|
||||
let prev = JSON.stringify(prop.previousValue);
|
||||
const prop = changes[propName];
|
||||
const cur = JSON.stringify(prop.currentValue);
|
||||
const prev = JSON.stringify(prop.previousValue);
|
||||
this.changeLog.push(`${propName}: currentValue = ${cur}, previousValue = ${prev}`);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ describe('HttpClient testing', () => {
|
||||
});
|
||||
|
||||
it('can test multiple requests', () => {
|
||||
let testData: Data[] = [
|
||||
const testData: Data[] = [
|
||||
{ name: 'bob' }, { name: 'carol' },
|
||||
{ name: 'ted' }, { name: 'alice' }
|
||||
];
|
||||
|
@ -5,7 +5,7 @@ import { TitleCasePipe } from './title-case.pipe';
|
||||
// #docregion excerpt, mini-excerpt
|
||||
describe('TitleCasePipe', () => {
|
||||
// This pipe is a pure, stateless function so no need for BeforeEach
|
||||
let pipe = new TitleCasePipe();
|
||||
const pipe = new TitleCasePipe();
|
||||
|
||||
it('transforms "abc" to "Abc"', () => {
|
||||
expect(pipe.transform('abc')).toBe('Abc');
|
||||
|
@ -21,7 +21,7 @@ export function advance(f: ComponentFixture<any>): void {
|
||||
* Although officially deprecated, some browsers (phantom) don't accept the preferred "new Event(eventName)"
|
||||
*/
|
||||
export function newEvent(eventName: string, bubbles = false, cancelable = false) {
|
||||
let evt = document.createEvent('CustomEvent'); // MUST be 'CustomEvent'
|
||||
const evt = document.createEvent('CustomEvent'); // MUST be 'CustomEvent'
|
||||
evt.initCustomEvent(eventName, bubbles, cancelable, null);
|
||||
return evt;
|
||||
}
|
||||
|
Reference in New Issue
Block a user