From d5ced77d311e1bcbcfc1296816ea2cf45086facc Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Sun, 19 Dec 2021 19:43:44 +0100 Subject: [PATCH] refactor(docs-infra): fix eslint issues for aio ugrade-* examples (#44534) fix the eslint issues in the aio/content/examples/upgrade-* folders and remove their ignorePattern in the examples eslintrc file PR Close #44534 --- aio/content/examples/.eslintrc.json | 3 +-- .../examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts | 6 +++++- .../src/app/a-to-ajs-transclusion/hero-detail.component.ts | 1 + .../src/app/upgrade-io/hero-detail.component.ts | 1 + .../src/app/upgrade-static/hero-detail.component.ts | 1 + .../app/core/checkmark/checkmark.filter.ts | 4 +--- .../app/core/phone/phone.service.ts | 7 +++---- .../examples/upgrade-phonecat-2-hybrid/app/app.module.ts | 4 ++-- .../app/core/phone/phone.service.ts | 2 +- .../app/phone-detail/phone-detail.component.ajs.ts | 2 +- .../app/phone-detail/phone-detail.component.ts | 2 +- .../app/phone-list/phone-list.component.ajs.ts | 2 +- .../app/phone-list/phone-list.component.spec.ts | 6 +++--- .../app/phone-list/phone-list.component.ts | 2 +- .../app/phone-list/phone-list.component.spec.ts | 6 +++--- 15 files changed, 26 insertions(+), 23 deletions(-) diff --git a/aio/content/examples/.eslintrc.json b/aio/content/examples/.eslintrc.json index 5c0863d1032..b1b25254dc0 100644 --- a/aio/content/examples/.eslintrc.json +++ b/aio/content/examples/.eslintrc.json @@ -2,8 +2,7 @@ "root": true, "ignorePatterns": [ "*.js", - "styleguide/**/*.avoid.ts", - "upgrade-*" // TODO: Fix the code in the upgrade-* directories (which causes too many errors) and remove this entry. + "styleguide/**/*.avoid.ts" ], "overrides": [ { diff --git a/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts b/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts index 91e8e03d03e..5c4e8de3e51 100644 --- a/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts @@ -52,7 +52,11 @@ describe('Lazy Loading AngularJS Tests', () => { } // Wait for the AngularJS bundle to download and initialize - await browser.wait(ExpectedConditions.presenceOf(element(by.css('app-root app-angular-js'))), 5000, 'AngularJS app'); + await browser.wait( + ExpectedConditions.presenceOf(element(by.css('app-root app-angular-js'))), + 5000, + 'AngularJS app' + ); // Run the protractor pre-bootstrap logic and resumeBootstrap // Based on https://github.com/angular/protractor/blob/5.3.0/lib/browser.ts#L950-L969 diff --git a/aio/content/examples/upgrade-module/src/app/a-to-ajs-transclusion/hero-detail.component.ts b/aio/content/examples/upgrade-module/src/app/a-to-ajs-transclusion/hero-detail.component.ts index 8b799aa4a70..94025abd85e 100644 --- a/aio/content/examples/upgrade-module/src/app/a-to-ajs-transclusion/hero-detail.component.ts +++ b/aio/content/examples/upgrade-module/src/app/a-to-ajs-transclusion/hero-detail.component.ts @@ -18,6 +18,7 @@ import { UpgradeComponent } from '@angular/upgrade/static'; import { Hero } from '../hero'; @Directive({ + // eslint-disable-next-line @angular-eslint/directive-selector selector: 'hero-detail' }) export class HeroDetailDirective extends UpgradeComponent { diff --git a/aio/content/examples/upgrade-module/src/app/upgrade-io/hero-detail.component.ts b/aio/content/examples/upgrade-module/src/app/upgrade-io/hero-detail.component.ts index 4d74a1bea14..6fcec761a98 100644 --- a/aio/content/examples/upgrade-module/src/app/upgrade-io/hero-detail.component.ts +++ b/aio/content/examples/upgrade-module/src/app/upgrade-io/hero-detail.component.ts @@ -24,6 +24,7 @@ import { UpgradeComponent } from '@angular/upgrade/static'; import { Hero } from '../hero'; @Directive({ + // eslint-disable-next-line @angular-eslint/directive-selector selector: 'hero-detail' }) export class HeroDetailDirective extends UpgradeComponent { diff --git a/aio/content/examples/upgrade-module/src/app/upgrade-static/hero-detail.component.ts b/aio/content/examples/upgrade-module/src/app/upgrade-static/hero-detail.component.ts index 959ff16b013..8844bfa576b 100644 --- a/aio/content/examples/upgrade-module/src/app/upgrade-static/hero-detail.component.ts +++ b/aio/content/examples/upgrade-module/src/app/upgrade-static/hero-detail.component.ts @@ -15,6 +15,7 @@ import { Directive, ElementRef, Injector, SimpleChanges } from '@angular/core'; import { UpgradeComponent } from '@angular/upgrade/static'; @Directive({ + // eslint-disable-next-line @angular-eslint/directive-selector selector: 'hero-detail' }) export class HeroDetailDirective extends UpgradeComponent { diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/checkmark/checkmark.filter.ts b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/checkmark/checkmark.filter.ts index 62ab33c755e..3bb3a9cf66e 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/checkmark/checkmark.filter.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/checkmark/checkmark.filter.ts @@ -1,6 +1,4 @@ // #docregion angular. module('core'). - filter('checkmark', () => { - return (input: boolean) => input ? '\u2713' : '\u2718'; - }); + filter('checkmark', () => (input: boolean) => input ? '\u2713' : '\u2718'); diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.ts b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.ts index 63fad780060..38b3d86a74c 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.ts @@ -2,13 +2,12 @@ angular. module('core.phone'). factory('Phone', ['$resource', - ($resource: angular.resource.IResourceService) => { - return $resource('phones/:phoneId.json', {}, { + ($resource: angular.resource.IResourceService) => + $resource('phones/:phoneId.json', {}, { query: { method: 'GET', params: {phoneId: 'phones'}, isArray: true } - }); - } + }) ]); diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/app.module.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/app.module.ts index 1b1bd9d2dfe..487be686d6a 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/app.module.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/app.module.ts @@ -1,6 +1,6 @@ // #docplaster // #docregion bare -import { NgModule } from '@angular/core'; +import { DoBootstrap, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; // #enddocregion bare // #docregion upgrademodule @@ -61,7 +61,7 @@ import { PhoneDetailComponent } from './phone-detail/phone-detail.component'; // #enddocregion routeparams // #docregion bare, upgrademodule, httpclientmodule, phonelist }) -export class AppModule { +export class AppModule implements DoBootstrap { // #enddocregion bare constructor(private upgrade: UpgradeModule) { } ngDoBootstrap() { diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.ts index c5b4702e950..119d2f1d33b 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.ts @@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; // #docregion downgrade-injectable -declare var angular: angular.IAngularStatic; +declare const angular: angular.IAngularStatic; import { downgradeInjectable } from '@angular/upgrade/static'; // #enddocregion downgrade-injectable diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts index dfd2ae43029..e8c5aae1d85 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts @@ -1,5 +1,5 @@ // #docregion -declare var angular: angular.IAngularStatic; +declare const angular: angular.IAngularStatic; import { Phone, PhoneData } from '../core/phone/phone.service'; class PhoneDetailController { diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ts index f0216b9bc21..c6a8f7eda11 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ts @@ -1,4 +1,4 @@ -declare var angular: angular.IAngularStatic; +declare const angular: angular.IAngularStatic; import { downgradeComponent } from '@angular/upgrade/static'; import { Component } from '@angular/core'; diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ajs.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ajs.ts index 81eac1cd81e..c0843c77267 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ajs.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ajs.ts @@ -1,5 +1,5 @@ // #docregion -declare var angular: angular.IAngularStatic; +declare const angular: angular.IAngularStatic; import { Phone, PhoneData } from '../core/phone/phone.service'; class PhoneListController { diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.spec.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.spec.ts index 822129c8922..2f73c288b83 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.spec.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.spec.ts @@ -29,7 +29,7 @@ describe('PhoneList', () => { .configureTestingModule({ declarations: [PhoneListComponent], providers: [ - {provide: ActivatedRoute, useValue: new ActivatedRouteMock({params: {'phoneId': 1}})}, + {provide: ActivatedRoute, useValue: new ActivatedRouteMock({params: {phoneId: 1}})}, {provide: Location, useClass: SpyLocation}, {provide: Phone, useClass: MockPhone}, ], @@ -44,7 +44,7 @@ describe('PhoneList', () => { it('should create "phones" model with 2 phones fetched from xhr', () => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelectorAll('.phone-list-item').length).toBe(2); expect(compiled.querySelector('.phone-list-item:nth-child(1)').textContent) .toContain('Motorola DROID'); @@ -54,7 +54,7 @@ describe('PhoneList', () => { xit('should set the default value of orderProp model', () => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('select option:last-child').selected).toBe(true); }); }); diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts index 903b46a6d6e..7950d94dc5b 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts @@ -1,5 +1,5 @@ // #docregion downgrade-component -declare var angular: angular.IAngularStatic; +declare const angular: angular.IAngularStatic; import { downgradeComponent } from '@angular/upgrade/static'; // #enddocregion downgrade-component diff --git a/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.spec.ts b/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.spec.ts index 198db572593..ca8b7b821f6 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.spec.ts +++ b/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.spec.ts @@ -33,7 +33,7 @@ describe('PhoneList', () => { .configureTestingModule({ declarations: [PhoneListComponent], providers: [ - {provide: ActivatedRoute, useValue: new ActivatedRouteMock({params: {'phoneId': 1}})}, + {provide: ActivatedRoute, useValue: new ActivatedRouteMock({params: {phoneId: 1}})}, {provide: Location, useClass: SpyLocation}, {provide: Phone, useClass: MockPhone}, ], @@ -49,7 +49,7 @@ describe('PhoneList', () => { it('should create "phones" model with 2 phones fetched from xhr', () => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelectorAll('.phone-list-item').length).toBe(2); expect(compiled.querySelector('.phone-list-item:nth-child(1)').textContent) .toContain('Motorola DROID'); @@ -59,7 +59,7 @@ describe('PhoneList', () => { xit('should set the default value of orderProp model', () => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('select option:last-child').selected).toBe(true); }); });