From 4f8b716c13fc89ac63aa0969c41e81ff7e137a56 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Tue, 29 Sep 2020 18:26:19 +0300 Subject: [PATCH] build(docs-infra): update the `object-literal-key-quotes` tslint rule to align with CLI (#39018) This commit updates the `object-literal-key-quotes` tslint rule to more closely align `tslint.json` with the one generated by the latest Angular CLI for new apps. PR Close #39018 --- aio/src/app/app.component.spec.ts | 50 ++++---- .../api/api-list.component.spec.ts | 112 +++++++++--------- .../resource/resource.service.spec.ts | 95 ++++++++------- aio/tslint.json | 5 +- 4 files changed, 132 insertions(+), 130 deletions(-) diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index 19edc805eb593..03ab16fe9f749 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -782,7 +782,7 @@ describe('AppComponent', () => { it('should grab focus when the / key is pressed', () => { const searchBox: SearchBoxComponent = fixture.debugElement.query(By.directive(SearchBoxComponent)).componentInstance; spyOn(searchBox, 'focus'); - window.document.dispatchEvent(new KeyboardEvent('keyup', { 'key': '/' })); + window.document.dispatchEvent(new KeyboardEvent('keyup', { key: '/' })); fixture.detectChanges(); expect(searchBox.focus).toHaveBeenCalled(); }); @@ -791,7 +791,7 @@ describe('AppComponent', () => { const searchBox: SearchBoxComponent = fixture.debugElement.query(By.directive(SearchBoxComponent)).componentInstance; spyOn(searchBox, 'focus'); component.showSearchResults = true; - window.document.dispatchEvent(new KeyboardEvent('keyup', { 'key': 'Escape' })); + window.document.dispatchEvent(new KeyboardEvent('keyup', { key: 'Escape' })); fixture.detectChanges(); expect(searchBox.focus).toHaveBeenCalled(); }); @@ -1311,42 +1311,42 @@ class TestHttpClient { // tslint:disable:quotemark navJson = { - "TopBar": [ + TopBar: [ { - "url": "features", - "title": "Features" + url: 'features', + title: 'Features', }, { - "url": "no-title", - "title": "No Title" + url: 'no-title', + title: 'No Title', }, ], - "SideNav": [ + SideNav: [ { - "title": "Core", - "tooltip": "Learn the core capabilities of Angular", - "children": [ + title: 'Core', + tooltip: 'Learn the core capabilities of Angular', + children: [ { - "url": "guide/pipes", - "title": "Pipes", - "tooltip": "Pipes transform displayed values within a template." + url: 'guide/pipes', + title: 'Pipes', + tooltip: 'Pipes transform displayed values within a template.', }, { - "url": "guide/bags", - "title": "Bags", - "tooltip": "Pack your bags for a code adventure." - } - ] + url: 'guide/bags', + title: 'Bags', + tooltip: 'Pack your bags for a code adventure.', + }, + ], }, { - "url": "api", - "title": "API", - "tooltip": "Details of the Angular classes and values." - } + url: 'api', + title: 'API', + tooltip: 'Details of the Angular classes and values.', + }, ], - "docVersions": TestHttpClient.docVersions, + docVersions: TestHttpClient.docVersions, - "__versionInfo": TestHttpClient.versionInfo, + __versionInfo: TestHttpClient.versionInfo, }; get(url: string) { diff --git a/aio/src/app/custom-elements/api/api-list.component.spec.ts b/aio/src/app/custom-elements/api/api-list.component.spec.ts index 0c7a18a667075..fb97db2c38767 100644 --- a/aio/src/app/custom-elements/api/api-list.component.spec.ts +++ b/aio/src/app/custom-elements/api/api-list.component.spec.ts @@ -223,77 +223,77 @@ class TestApiService { // tslint:disable:quotemark const apiSections: ApiSection[] = [ { - "name": "common", - "title": "common", - "path": "api/common", - "deprecated": false, - "items": [ + name: 'common', + title: 'common', + path: 'api/common', + deprecated: false, + items: [ { - "name": "class_1", - "title": "Class 1", - "path": "api/common/class_1", - "docType": "class", - "stability": "experimental", - "securityRisk": false, + name: 'class_1', + title: 'Class 1', + path: 'api/common/class_1', + docType: 'class', + stability: 'experimental', + securityRisk: false, }, { - "name": "class_2", - "title": "Class 2", - "path": "api/common/class_2", - "docType": "class", - "stability": "stable", - "securityRisk": false, + name: 'class_2', + title: 'Class 2', + path: 'api/common/class_2', + docType: 'class', + stability: 'stable', + securityRisk: false, }, { - "name": "directive_1", - "title": "Directive 1", - "path": "api/common/directive_1", - "docType": "directive", - "stability": "stable", - "securityRisk": true, + name: 'directive_1', + title: 'Directive 1', + path: 'api/common/directive_1', + docType: 'directive', + stability: 'stable', + securityRisk: true, }, { - "name": "pipe_1", - "title": "Pipe 1", - "path": "api/common/pipe_1", - "docType": "pipe", - "stability": "stable", - "securityRisk": true, + name: 'pipe_1', + title: 'Pipe 1', + path: 'api/common/pipe_1', + docType: 'pipe', + stability: 'stable', + securityRisk: true, }, - ] + ], }, { - "name": "core", - "title": "core", - "path": "api/core", - "deprecated": false, - "items": [ + name: 'core', + title: 'core', + path: 'api/core', + deprecated: false, + items: [ { - "name": "class_3", - "title": "Class 3", - "path": "api/core/class_3", - "docType": "class", - "stability": "experimental", - "securityRisk": false, + name: 'class_3', + title: 'Class 3', + path: 'api/core/class_3', + docType: 'class', + stability: 'experimental', + securityRisk: false, }, { - "name": "function_1", - "title": "Function 1", - "path": "api/core/function 1", - "docType": "function", - "stability": "deprecated", - "securityRisk": true, + name: 'function_1', + title: 'Function 1', + path: 'api/core/function 1', + docType: 'function', + stability: 'deprecated', + securityRisk: true, }, { - "name": "const_1", - "title": "Const 1", - "path": "api/core/const_1", - "docType": "const", - "stability": "stable", - "securityRisk": false, - } - ] - } + name: 'const_1', + title: 'Const 1', + path: 'api/core/const_1', + docType: 'const', + stability: 'stable', + securityRisk: false, + }, + ], + }, ]; function getApiSections() { return apiSections; } diff --git a/aio/src/app/custom-elements/resource/resource.service.spec.ts b/aio/src/app/custom-elements/resource/resource.service.spec.ts index 2d9f3a4d5ba7a..032c11d32509d 100644 --- a/aio/src/app/custom-elements/resource/resource.service.spec.ts +++ b/aio/src/app/custom-elements/resource/resource.service.spec.ts @@ -86,62 +86,61 @@ describe('ResourceService', () => { }); function getTestResources() { - // tslint:disable:quotemark return { - "Cat 3": { - "order": 3, - "subCategories": { - "Cat3 SubCat1": { - "order": 2, - "resources": { - "Cat3 SubCat1 Res1": { - "desc": "Meetup in Barcelona, Spain. ", - "title": "Angular Beers", - "url": "http://www.meetup.com/AngularJS-Beers/" + 'Cat 3': { + order: 3, + subCategories: { + 'Cat3 SubCat1': { + order: 2, + resources: { + 'Cat3 SubCat1 Res1': { + desc: 'Meetup in Barcelona, Spain. ', + title: 'Angular Beers', + url: 'http://www.meetup.com/AngularJS-Beers/', }, - "Cat3 SubCat1 Res2": { - "desc": "Angular Camps in Barcelona, Spain.", - "title": "Angular Camp", - "url": "http://angularcamp.org/" - } - } + 'Cat3 SubCat1 Res2': { + desc: 'Angular Camps in Barcelona, Spain.', + title: 'Angular Camp', + url: 'http://angularcamp.org/', + }, + }, }, - "Cat3 SubCat2": { - "order": 1, - "resources": { - "Cat3 SubCat2 Res1": { - "desc": "A community index of components and libraries", - "title": "Catalog of Angular Components & Libraries", - "url": "https://a/b/c" - } - } + 'Cat3 SubCat2': { + order: 1, + resources: { + 'Cat3 SubCat2 Res1': { + desc: 'A community index of components and libraries', + title: 'Catalog of Angular Components & Libraries', + url: 'https://a/b/c', + }, + }, }, - } + }, }, - "Cat 1": { - "order": 1, - "subCategories": { - "Cat1 SubCat1": { - "order": 1, - "resources": { - "S S S": { - "desc": "SSS", - "title": "Sssss", - "url": "http://s/s/s" + 'Cat 1': { + order: 1, + subCategories: { + 'Cat1 SubCat1': { + order: 1, + resources: { + 'S S S': { + desc: 'SSS', + title: 'Sssss', + url: 'http://s/s/s', }, - "A A A": { - "desc": "AAA", - "title": "Aaaa", - "url": "http://a/a/a" + 'A A A': { + desc: 'AAA', + title: 'Aaaa', + url: 'http://a/a/a', }, - "Z Z Z": { - "desc": "ZZZ", - "title": "Zzzzz", - "url": "http://z/z/z" - } - } + 'Z Z Z': { + desc: 'ZZZ', + title: 'Zzzzz', + url: 'http://z/z/z', + }, + }, }, }, - } + }, }; } diff --git a/aio/tslint.json b/aio/tslint.json index fd042372491d5..05ee64c9b0629 100644 --- a/aio/tslint.json +++ b/aio/tslint.json @@ -64,7 +64,10 @@ "no-redundant-jsdoc": true, "no-switch-case-fall-through": true, "no-var-requires": false, - "object-literal-key-quotes": false, + "object-literal-key-quotes": [ + true, + "as-needed" + ], "only-arrow-functions": false, "quotemark": [ true,