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
@ -138,15 +138,15 @@ describe('Dependency Injection Tests', () => {
|
||||
});
|
||||
|
||||
it('unauthorized user should have multiple unauthorized heroes', () => {
|
||||
let heroes = element.all(by.css('#unauthorized app-hero-list div'));
|
||||
const heroes = element.all(by.css('#unauthorized app-hero-list div'));
|
||||
expect(heroes.count()).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('unauthorized user should have no secret heroes', () => {
|
||||
let heroes = element.all(by.css('#unauthorized app-hero-list div'));
|
||||
const heroes = element.all(by.css('#unauthorized app-hero-list div'));
|
||||
expect(heroes.count()).toBeGreaterThan(0);
|
||||
|
||||
let filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => {
|
||||
const filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => {
|
||||
return elem.getText().then((text: string) => /secret/.test(text));
|
||||
});
|
||||
|
||||
@ -160,7 +160,7 @@ describe('Dependency Injection Tests', () => {
|
||||
describe('after button click', () => {
|
||||
|
||||
beforeAll((done: any) => {
|
||||
let buttonEle = element.all(by.cssContainingText('button', 'Next User')).get(0);
|
||||
const buttonEle = element.all(by.cssContainingText('button', 'Next User')).get(0);
|
||||
buttonEle.click().then(done, done);
|
||||
});
|
||||
|
||||
@ -170,20 +170,20 @@ describe('Dependency Injection Tests', () => {
|
||||
});
|
||||
|
||||
it('authorized user should have multiple authorized heroes ', () => {
|
||||
let heroes = element.all(by.css('#authorized app-hero-list div'));
|
||||
const heroes = element.all(by.css('#authorized app-hero-list div'));
|
||||
expect(heroes.count()).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('authorized user should have multiple authorized heroes with tree-shakeable HeroesService', () => {
|
||||
let heroes = element.all(by.css('#tspAuthorized app-hero-list div'));
|
||||
const heroes = element.all(by.css('#tspAuthorized app-hero-list div'));
|
||||
expect(heroes.count()).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('authorized user should have secret heroes', () => {
|
||||
let heroes = element.all(by.css('#authorized app-hero-list div'));
|
||||
const heroes = element.all(by.css('#authorized app-hero-list div'));
|
||||
expect(heroes.count()).toBeGreaterThan(0);
|
||||
|
||||
let filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => {
|
||||
const filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => {
|
||||
return elem.getText().then((text: string) => /secret/.test(text));
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { Car, Engine, Tires } from './car';
|
||||
export function simpleCar() {
|
||||
// #docregion car-ctor-instantiation
|
||||
// Simple car with 4 cylinders and Flintstone tires.
|
||||
let car = new Car(new Engine(), new Tires());
|
||||
const car = new Car(new Engine(), new Tires());
|
||||
// #enddocregion car-ctor-instantiation
|
||||
car.description = 'Simple';
|
||||
return car;
|
||||
@ -24,8 +24,8 @@ class Engine2 {
|
||||
export function superCar() {
|
||||
// #docregion car-ctor-instantiation-with-param
|
||||
// Super car with 12 cylinders and Flintstone tires.
|
||||
let bigCylinders = 12;
|
||||
let car = new Car(new Engine2(bigCylinders), new Tires());
|
||||
const bigCylinders = 12;
|
||||
const car = new Car(new Engine2(bigCylinders), new Tires());
|
||||
// #enddocregion car-ctor-instantiation-with-param
|
||||
car.description = 'Super';
|
||||
return car;
|
||||
@ -40,7 +40,7 @@ class MockTires extends Tires { make = 'YokoGoodStone'; }
|
||||
export function testCar() {
|
||||
// #docregion car-ctor-instantiation-with-mocks
|
||||
// Test car with 8 cylinders and YokoGoodStone tires.
|
||||
let car = new Car(new MockEngine(), new MockTires());
|
||||
const car = new Car(new MockEngine(), new MockTires());
|
||||
// #enddocregion car-ctor-instantiation-with-mocks
|
||||
car.description = 'Test';
|
||||
return car;
|
||||
|
@ -4,7 +4,7 @@ import { Engine, Tires, Car } from './car';
|
||||
// BAD pattern!
|
||||
export class CarFactory {
|
||||
createCar() {
|
||||
let car = new Car(this.createEngine(), this.createTires());
|
||||
const car = new Car(this.createEngine(), this.createTires());
|
||||
car.description = 'Factory';
|
||||
return car;
|
||||
}
|
||||
|
@ -26,14 +26,14 @@ export function useInjector() {
|
||||
]
|
||||
});
|
||||
// #docregion injector-call
|
||||
let car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
// #enddocregion injector-call, injector-create-and-call
|
||||
car.description = 'Injector';
|
||||
|
||||
injector = Injector.create({
|
||||
providers: [{ provide: Logger, deps: [] }]
|
||||
});
|
||||
let logger = injector.get(Logger);
|
||||
const logger = injector.get(Logger);
|
||||
logger.log('Injector car.drive() said: ' + car.drive());
|
||||
return car;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { Logger } from '../logger.service';
|
||||
import { UserService } from '../user.service';
|
||||
|
||||
// #docregion factory
|
||||
let heroServiceFactory = (logger: Logger, userService: UserService) => {
|
||||
const heroServiceFactory = (logger: Logger, userService: UserService) => {
|
||||
return new HeroService(logger, userService.user.isAuthorized);
|
||||
};
|
||||
// #enddocregion factory
|
||||
|
@ -17,7 +17,7 @@ export class HeroService {
|
||||
private isAuthorized: boolean) { }
|
||||
|
||||
getHeroes() {
|
||||
let auth = this.isAuthorized ? 'authorized ' : 'unauthorized';
|
||||
const auth = this.isAuthorized ? 'authorized ' : 'unauthorized';
|
||||
this.logger.log(`Getting heroes for ${auth} user.`);
|
||||
return HEROES.filter(hero => this.isAuthorized || !hero.isSecret);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ export class InjectorComponent implements OnInit {
|
||||
}
|
||||
|
||||
get rodent() {
|
||||
let rousDontExist = `R.O.U.S.'s? I don't think they exist!`;
|
||||
const rousDontExist = `R.O.U.S.'s? I don't think they exist!`;
|
||||
return this.injector.get(ROUS, rousDontExist);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ export class EvenBetterLogger extends Logger {
|
||||
constructor(private userService: UserService) { super(); }
|
||||
|
||||
log(message: string) {
|
||||
let name = this.userService.user.name;
|
||||
const name = this.userService.user.name;
|
||||
super.log(`Message to ${name}: ${message}`);
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,7 @@ export class Provider9Component implements OnInit {
|
||||
import { Optional } from '@angular/core';
|
||||
// #enddocregion import-optional
|
||||
|
||||
let someMessage = 'Hello from the injected logger';
|
||||
const someMessage = 'Hello from the injected logger';
|
||||
|
||||
@Component({
|
||||
selector: 'provider-10',
|
||||
|
@ -8,8 +8,8 @@ export class User {
|
||||
}
|
||||
|
||||
// TODO: get the user; don't 'new' it.
|
||||
let alice = new User('Alice', true);
|
||||
let bob = new User('Bob', false);
|
||||
const alice = new User('Alice', true);
|
||||
const bob = new User('Bob', false);
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
Reference in New Issue
Block a user