build(docs-infra): remove the `no-string-literal` tslint rule to align with CLI (#39018)

This commit removes the `no-string-literal: false` tslint rule to
more closely align `tslint.json` with the one generated by the latest
Angular CLI for new apps.

PR Close #39018
This commit is contained in:
George Kalpakas 2020-09-29 18:26:19 +03:00 committed by Joey Perrott
parent be98a45dd9
commit 2cc3ac0299
12 changed files with 28 additions and 29 deletions

View File

@ -968,23 +968,23 @@ describe('AppComponent', () => {
// Initially, `isTransitoning` is true. // Initially, `isTransitoning` is true.
expect(component.isTransitioning).toBe(true); expect(component.isTransitioning).toBe(true);
expect(toolbar.classes['transitioning']).toBe(true); expect(toolbar.classes.transitioning).toBe(true);
triggerDocViewerEvent('docRendered'); triggerDocViewerEvent('docRendered');
fixture.detectChanges(); fixture.detectChanges();
expect(component.isTransitioning).toBe(false); expect(component.isTransitioning).toBe(false);
expect(toolbar.classes['transitioning']).toBeFalsy(); expect(toolbar.classes.transitioning).toBeFalsy();
// While a document is being rendered, `isTransitoning` is set to true. // While a document is being rendered, `isTransitoning` is set to true.
triggerDocViewerEvent('docReady'); triggerDocViewerEvent('docReady');
fixture.detectChanges(); fixture.detectChanges();
expect(component.isTransitioning).toBe(true); expect(component.isTransitioning).toBe(true);
expect(toolbar.classes['transitioning']).toBe(true); expect(toolbar.classes.transitioning).toBe(true);
triggerDocViewerEvent('docRendered'); triggerDocViewerEvent('docRendered');
fixture.detectChanges(); fixture.detectChanges();
expect(component.isTransitioning).toBe(false); expect(component.isTransitioning).toBe(false);
expect(toolbar.classes['transitioning']).toBeFalsy(); expect(toolbar.classes.transitioning).toBeFalsy();
}); });
it('should update the sidenav state as soon as a new document is inserted (but not before)', () => { it('should update the sidenav state as soon as a new document is inserted (but not before)', () => {
@ -1031,15 +1031,15 @@ describe('AppComponent', () => {
navigateTo('guide/pipes'); navigateTo('guide/pipes');
expect(component.pageId).toEqual('guide-pipes'); expect(component.pageId).toEqual('guide-pipes');
expect(container.properties['id']).toEqual('guide-pipes'); expect(container.properties.id).toEqual('guide-pipes');
navigateTo('news'); navigateTo('news');
expect(component.pageId).toEqual('news'); expect(component.pageId).toEqual('news');
expect(container.properties['id']).toEqual('news'); expect(container.properties.id).toEqual('news');
navigateTo(''); navigateTo('');
expect(component.pageId).toEqual('home'); expect(component.pageId).toEqual('home');
expect(container.properties['id']).toEqual('home'); expect(container.properties.id).toEqual('home');
}); });
it('should not be affected by changes to the query', () => { it('should not be affected by changes to the query', () => {
@ -1050,7 +1050,7 @@ describe('AppComponent', () => {
navigateTo('guide/other?search=http'); navigateTo('guide/other?search=http');
expect(component.pageId).toEqual('guide-other'); expect(component.pageId).toEqual('guide-other');
expect(container.properties['id']).toEqual('guide-other'); expect(container.properties.id).toEqual('guide-other');
}); });
}); });
@ -1125,7 +1125,7 @@ describe('AppComponent', () => {
function checkHostClass(type: string, value: string) { function checkHostClass(type: string, value: string) {
const host = fixture.debugElement; const host = fixture.debugElement;
const classes: string = host.properties['className']; const classes: string = host.properties.className;
const classArray = classes.split(' ').filter(c => c.indexOf(`${type}-`) === 0); const classArray = classes.split(' ').filter(c => c.indexOf(`${type}-`) === 0);
expect(classArray.length).toBeLessThanOrEqual(1, `"${classes}" should have only one class matching ${type}-*`); expect(classArray.length).toBeLessThanOrEqual(1, `"${classes}" should have only one class matching ${type}-*`);
expect(classArray).toEqual([`${type}-${value}`], `"${classes}" should contain ${type}-${value}`); expect(classArray).toEqual([`${type}-${value}`], `"${classes}" should contain ${type}-${value}`);

View File

@ -147,7 +147,7 @@ export class AppComponent implements OnInit {
// Compute the version picker list from the current version and the versions in the navigation map // Compute the version picker list from the current version and the versions in the navigation map
combineLatest([ combineLatest([
this.navigationService.versionInfo, this.navigationService.versionInfo,
this.navigationService.navigationViews.pipe(map(views => views['docVersions'])), this.navigationService.navigationViews.pipe(map(views => views.docVersions)),
]).subscribe(([versionInfo, versions]) => { ]).subscribe(([versionInfo, versions]) => {
// TODO(pbd): consider whether we can lookup the stable and next versions from the internet // TODO(pbd): consider whether we can lookup the stable and next versions from the internet
const computedVersions: NavigationNode[] = [ const computedVersions: NavigationNode[] = [
@ -167,10 +167,10 @@ export class AppComponent implements OnInit {
}); });
this.navigationService.navigationViews.subscribe(views => { this.navigationService.navigationViews.subscribe(views => {
this.footerNodes = views['Footer'] || []; this.footerNodes = views.Footer || [];
this.sideNavNodes = views['SideNav'] || []; this.sideNavNodes = views.SideNav || [];
this.topMenuNodes = views['TopBar'] || []; this.topMenuNodes = views.TopBar || [];
this.topMenuNarrowNodes = views['TopBarNarrow'] || this.topMenuNodes; this.topMenuNarrowNodes = views.TopBarNarrow || this.topMenuNodes;
}); });
this.navigationService.versionInfo.subscribe(vi => this.versionInfo = vi); this.navigationService.versionInfo.subscribe(vi => this.versionInfo = vi);

View File

@ -20,13 +20,13 @@ export class PrettyPrinter {
} }
private getPrettyPrintOne(): Promise<PrettyPrintOne> { private getPrettyPrintOne(): Promise<PrettyPrintOne> {
const ppo = (window as any)['prettyPrintOne']; const ppo = (window as any).prettyPrintOne;
return ppo ? Promise.resolve(ppo) : return ppo ? Promise.resolve(ppo) :
// `prettyPrintOne` is not on `window`, which means `prettify.js` has not been loaded yet. // `prettyPrintOne` is not on `window`, which means `prettify.js` has not been loaded yet.
// Import it; ad a side-effect it will add `prettyPrintOne` on `window`. // Import it; ad a side-effect it will add `prettyPrintOne` on `window`.
import('assets/js/prettify.js' as any) import('assets/js/prettify.js' as any)
.then( .then(
() => (window as any)['prettyPrintOne'], () => (window as any).prettyPrintOne,
err => { err => {
const msg = `Cannot get prettify.js from server: ${err.message}`; const msg = `Cannot get prettify.js from server: ${err.message}`;
this.logger.error(new Error(msg)); this.logger.error(new Error(msg));

View File

@ -63,7 +63,7 @@ describe('ContributorListComponent', () => {
it('should set the query to the "GDE" group when user selects "GDE"', () => { it('should set the query to the "GDE" group when user selects "GDE"', () => {
component = getComponent(); component = getComponent();
component.selectGroup('GDE'); component.selectGroup('GDE');
expect(locationService.searchResult['group']).toBe('GDE'); expect(locationService.searchResult.group).toBe('GDE');
}); });
it('should set the query to the first group when user selects unknown name', () => { it('should set the query to the first group when user selects unknown name', () => {
@ -71,7 +71,7 @@ describe('ContributorListComponent', () => {
component.selectGroup('GDE'); // a legit group that isn't the first component.selectGroup('GDE'); // a legit group that isn't the first
component.selectGroup('foo'); // not a legit group name component.selectGroup('foo'); // not a legit group name
expect(locationService.searchResult['group']).toBe('Angular'); expect(locationService.searchResult.group).toBe('Angular');
}); });
//// Test Helpers //// //// Test Helpers ////

View File

@ -29,7 +29,7 @@ export class ContributorListComponent implements OnInit {
private locationService: LocationService) { } private locationService: LocationService) { }
ngOnInit() { ngOnInit() {
const groupName = this.locationService.search()['group'] || ''; const groupName = this.locationService.search().group || '';
// no need to unsubscribe because `contributors` completes // no need to unsubscribe because `contributors` completes
this.contributorService.contributors this.contributorService.contributors
.subscribe(grps => { .subscribe(grps => {

View File

@ -63,7 +63,7 @@ describe('ResourceListComponent', () => {
it('should set the query to the "education" category when user selects "education"', () => { it('should set the query to the "education" category when user selects "education"', () => {
component = getComponent(); component = getComponent();
component.selectCategory('education'); component.selectCategory('education');
expect(locationService.searchResult['category']).toBe('education'); expect(locationService.searchResult.category).toBe('education');
}); });
it('should set the query to the first category when user selects unknown name', () => { it('should set the query to the first category when user selects unknown name', () => {
@ -71,7 +71,7 @@ describe('ResourceListComponent', () => {
component.selectCategory('education'); // a legit group that isn't the first component.selectCategory('education'); // a legit group that isn't the first
component.selectCategory('foo'); // not a legit group name component.selectCategory('foo'); // not a legit group name
expect(locationService.searchResult['category']).toBe('development'); expect(locationService.searchResult.category).toBe('development');
}); });
//// Test Helpers //// //// Test Helpers ////

View File

@ -20,7 +20,7 @@ export class ResourceListComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
const category = this.locationService.search()['category'] || ''; const category = this.locationService.search().category || '';
// Not using async pipe because cats appear twice in template // Not using async pipe because cats appear twice in template
// No need to unsubscribe because categories observable completes. // No need to unsubscribe because categories observable completes.
this.resourceService.categories.subscribe(cats => { this.resourceService.categories.subscribe(cats => {

View File

@ -86,7 +86,7 @@ describe('NavigationService', () => {
]; ];
beforeEach(() => { beforeEach(() => {
navService.navigationViews.subscribe(views => view = views['sideNav']); navService.navigationViews.subscribe(views => view = views.sideNav);
httpMock.expectOne({}).flush({sideNav}); httpMock.expectOne({}).flush({sideNav});
}); });
@ -254,7 +254,7 @@ describe('NavigationService', () => {
{...v, ...{ tooltip: v.title + '.'}}) {...v, ...{ tooltip: v.title + '.'}})
); );
navService.navigationViews.subscribe(views => actualDocVersions = views['docVersions']); navService.navigationViews.subscribe(views => actualDocVersions = views.docVersions);
}); });
it('should extract the docVersions', () => { it('should extract the docVersions', () => {

View File

@ -41,7 +41,7 @@ export class SearchBoxComponent implements AfterViewInit {
* When we first show this search box we trigger a search if there is a search query in the URL * When we first show this search box we trigger a search if there is a search query in the URL
*/ */
ngAfterViewInit() { ngAfterViewInit() {
const query = this.locationService.search()['search']; const query = this.locationService.search().search;
if (query) { if (query) {
this.query = this.decodeQuery(query); this.query = this.decodeQuery(query);
this.doSearch(); this.doSearch();

View File

@ -11,7 +11,7 @@ export class Deployment {
* The deployment mode set from the environment provided at build time; * The deployment mode set from the environment provided at build time;
* or overridden by the `mode` query parameter: e.g. `...?mode=archive` * or overridden by the `mode` query parameter: e.g. `...?mode=archive`
*/ */
mode: string = this.location.search()['mode'] || environment.mode; mode: string = this.location.search().mode || environment.mode;
constructor(private location: LocationService) {} constructor(private location: LocationService) {}
} }

View File

@ -14,7 +14,7 @@ export class GaService {
private previousUrl: string; private previousUrl: string;
constructor(@Inject(WindowToken) private window: Window) { constructor(@Inject(WindowToken) private window: Window) {
this.ga('create', environment['gaId'] , 'auto'); this.ga('create', environment.gaId , 'auto');
} }
locationChanged(url: string) { locationChanged(url: string) {
@ -34,7 +34,7 @@ export class GaService {
} }
ga(...args: any[]) { ga(...args: any[]) {
const gaFn = (this.window as any)['ga']; const gaFn = (this.window as any).ga;
if (gaFn) { if (gaFn) {
gaFn(...args); gaFn(...args);
} }

View File

@ -62,7 +62,6 @@
"ignore-params" "ignore-params"
], ],
"no-redundant-jsdoc": true, "no-redundant-jsdoc": true,
"no-string-literal": false,
"no-switch-case-fall-through": true, "no-switch-case-fall-through": true,
"no-var-requires": false, "no-var-requires": false,
"object-literal-key-quotes": false, "object-literal-key-quotes": false,