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
@ -100,7 +100,7 @@ describe('Router', () => {
|
||||
await page.heroesHref.click();
|
||||
await browser.sleep(600);
|
||||
const heroEle = page.heroesList.get(4);
|
||||
let text = await heroEle.getText();
|
||||
const text = await heroEle.getText();
|
||||
expect(text.length).toBeGreaterThan(0, 'hero item text length');
|
||||
// remove leading id from text
|
||||
const heroText = text.substr(text.indexOf(' ')).trim();
|
||||
@ -110,11 +110,11 @@ describe('Router', () => {
|
||||
expect(page.heroesList.count()).toBe(0, 'hero list count');
|
||||
expect(page.heroDetail.isPresent()).toBe(true, 'hero detail');
|
||||
expect(page.heroDetailTitle.getText()).toContain(heroText);
|
||||
let inputEle = page.heroDetail.element(by.css('input'));
|
||||
const inputEle = page.heroDetail.element(by.css('input'));
|
||||
await inputEle.sendKeys('-foo');
|
||||
expect(page.heroDetailTitle.getText()).toContain(heroText + '-foo');
|
||||
|
||||
let buttonEle = page.heroDetail.element(by.css('button'));
|
||||
const buttonEle = page.heroDetail.element(by.css('button'));
|
||||
await buttonEle.click();
|
||||
await browser.sleep(600);
|
||||
expect(heroEle.getText()).toContain(heroText + '-foo');
|
||||
@ -166,7 +166,7 @@ describe('Router', () => {
|
||||
const page = getPageStruct();
|
||||
await page.crisisHref.click();
|
||||
let crisisEle = page.crisisList.get(index);
|
||||
let text = await crisisEle.getText();
|
||||
const text = await crisisEle.getText();
|
||||
expect(text.length).toBeGreaterThan(0, 'crisis item text length');
|
||||
// remove leading id from text
|
||||
const crisisText = text.substr(text.indexOf(' ')).trim();
|
||||
@ -174,10 +174,10 @@ describe('Router', () => {
|
||||
await crisisEle.click();
|
||||
expect(page.crisisDetail.isPresent()).toBe(true, 'crisis detail present');
|
||||
expect(page.crisisDetailTitle.getText()).toContain(crisisText);
|
||||
let inputEle = page.crisisDetail.element(by.css('input'));
|
||||
const inputEle = page.crisisDetail.element(by.css('input'));
|
||||
await inputEle.sendKeys('-foo');
|
||||
|
||||
let buttonEle = page.crisisDetail.element(by.buttonText(save ? 'Save' : 'Cancel'));
|
||||
const buttonEle = page.crisisDetail.element(by.buttonText(save ? 'Save' : 'Cancel'));
|
||||
await buttonEle.click();
|
||||
crisisEle = page.crisisList.get(index);
|
||||
if (save) {
|
||||
|
@ -13,7 +13,7 @@ export class AuthGuard implements CanActivate {
|
||||
canActivate(
|
||||
next: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): true|UrlTree {
|
||||
let url: string = state.url;
|
||||
const url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): true|UrlTree {
|
||||
let url: string = state.url;
|
||||
const url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
constructor(private authService: AuthService, private router: Router) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): true|UrlTree {
|
||||
let url: string = state.url;
|
||||
const url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
@ -34,11 +34,11 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
this.authService.redirectUrl = url;
|
||||
|
||||
// Create a dummy session id
|
||||
let sessionId = 123456789;
|
||||
const sessionId = 123456789;
|
||||
|
||||
// Set our navigation extras object
|
||||
// that contains our global query params and fragment
|
||||
let navigationExtras: NavigationExtras = {
|
||||
const navigationExtras: NavigationExtras = {
|
||||
queryParams: { session_id: sessionId },
|
||||
fragment: 'anchor'
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||
constructor(private authService: AuthService, private router: Router) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
let url: string = state.url;
|
||||
const url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
@ -28,7 +28,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||
|
||||
// #docregion, canLoad
|
||||
canLoad(route: Route): boolean {
|
||||
let url = `/${route.path}`;
|
||||
const url = `/${route.path}`;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
@ -41,11 +41,11 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||
this.authService.redirectUrl = url;
|
||||
|
||||
// Create a dummy session id
|
||||
let sessionId = 123456789;
|
||||
const sessionId = 123456789;
|
||||
|
||||
// Set our navigation extras object
|
||||
// that contains our global query params and fragment
|
||||
let navigationExtras: NavigationExtras = {
|
||||
const navigationExtras: NavigationExtras = {
|
||||
queryParams: { session_id: sessionId },
|
||||
fragment: 'anchor'
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ export class LoginComponent {
|
||||
// #docregion preserve
|
||||
// Set our navigation extras object
|
||||
// that passes on our global query params and fragment
|
||||
let navigationExtras: NavigationExtras = {
|
||||
const navigationExtras: NavigationExtras = {
|
||||
queryParamsHandling: 'preserve',
|
||||
preserveFragment: true
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ export class CrisisDetailResolverService implements Resolve<Crisis> {
|
||||
constructor(private cs: CrisisService, private router: Router) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Crisis> | Observable<never> {
|
||||
let id = route.paramMap.get('id');
|
||||
const id = route.paramMap.get('id');
|
||||
|
||||
return this.cs.getCrisis(id).pipe(
|
||||
take(1),
|
||||
|
@ -62,7 +62,7 @@ export class CrisisDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
gotoCrises() {
|
||||
let crisisId = this.crisis ? this.crisis.id : null;
|
||||
const crisisId = this.crisis ? this.crisis.id : null;
|
||||
// Pass along the crisis id if available
|
||||
// so that the CrisisListComponent can select that crisis.
|
||||
// Add a totally useless `foo` parameter for kicks.
|
||||
|
@ -56,7 +56,7 @@ export class CrisisDetailComponent implements OnInit {
|
||||
// #enddocregion canDeactivate
|
||||
|
||||
gotoCrises() {
|
||||
let crisisId = this.crisis ? this.crisis.id : null;
|
||||
const crisisId = this.crisis ? this.crisis.id : null;
|
||||
// Pass along the crisis id if available
|
||||
// so that the CrisisListComponent can select that crisis.
|
||||
// Add a totally useless `foo` parameter for kicks.
|
||||
|
@ -29,7 +29,7 @@ export class CrisisService {
|
||||
addCrisis(name: string) {
|
||||
name = name.trim();
|
||||
if (name) {
|
||||
let crisis = { id: CrisisService.nextCrisisId++, name };
|
||||
const crisis = { id: CrisisService.nextCrisisId++, name };
|
||||
CRISES.push(crisis);
|
||||
this.crises$.next(CRISES);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export class HeroDetailComponent implements OnInit {
|
||||
|
||||
// #docregion snapshot
|
||||
ngOnInit() {
|
||||
let id = this.route.snapshot.paramMap.get('id');
|
||||
const id = this.route.snapshot.paramMap.get('id');
|
||||
|
||||
this.hero$ = this.service.getHero(id);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export class HeroDetailComponent implements OnInit {
|
||||
|
||||
// #docregion gotoHeroes
|
||||
gotoHeroes(hero: Hero) {
|
||||
let heroId = hero ? hero.id : null;
|
||||
const heroId = hero ? hero.id : null;
|
||||
// Pass along the hero id if available
|
||||
// so that the HeroList component can select that hero.
|
||||
// Include a junk 'foo' property for fun.
|
||||
|
@ -38,7 +38,7 @@ export class HeroDetailComponent implements OnInit {
|
||||
|
||||
// #docregion redirect
|
||||
gotoHeroes(hero: Hero) {
|
||||
let heroId = hero ? hero.id : null;
|
||||
const heroId = hero ? hero.id : null;
|
||||
// Pass along the hero id if available
|
||||
// so that the HeroList component can select that hero.
|
||||
// Include a junk 'foo' property for fun.
|
||||
|
Reference in New Issue
Block a user