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
This commit is contained in:
Dario Piotrowicz 2021-12-19 19:43:44 +01:00 committed by Dylan Hunn
parent c7ac2dfcf8
commit d5ced77d31
15 changed files with 26 additions and 23 deletions

View file

@ -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": [
{

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -1,6 +1,4 @@
// #docregion
angular.
module('core').
filter('checkmark', () => {
return (input: boolean) => input ? '\u2713' : '\u2718';
});
filter('checkmark', () => (input: boolean) => input ? '\u2713' : '\u2718');

View file

@ -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
}
});
}
})
]);

View file

@ -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() {

View file

@ -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

View file

@ -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 {

View file

@ -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';

View file

@ -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 {

View file

@ -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);
});
});

View file

@ -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

View file

@ -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);
});
});