build(aio): update tslint and codelyzer (#23234)

PR Close #23234
This commit is contained in:
Igor Minar 2018-04-14 00:44:09 -07:00 committed by Jason Aden
parent 0a536af093
commit 103846a51d
20 changed files with 132 additions and 94 deletions

View File

@ -105,7 +105,7 @@
"canonical-path": "^0.0.2",
"chalk": "^2.1.0",
"cjson": "^0.5.0",
"codelyzer": "~2.0.0",
"codelyzer": "~4.2.1",
"concurrently": "^3.4.0",
"cross-spawn": "^5.1.0",
"css-selector-parser": "^1.3.0",
@ -146,14 +146,14 @@
"shelljs": "^0.7.7",
"tree-kill": "^1.1.0",
"ts-node": "^3.3.0",
"tslint": "~4.5.0",
"tslint": "~5.9.1",
"typescript": "~2.7.2",
"uglify-js": "^3.0.15",
"unist-util-filter": "^0.2.1",
"unist-util-source": "^1.0.1",
"unist-util-visit": "^1.1.1",
"unist-util-visit-parents": "^1.1.1",
"vrsource-tslint-rules": "^4.0.1",
"vrsource-tslint-rules": "^5.8.2",
"watchr": "^3.0.1",
"webpack-cli": "^2.0.14",
"xregexp": "^4.0.0",

View File

@ -64,13 +64,13 @@ describe('AppComponent', () => {
const de = fixture.debugElement;
const docViewerDe = de.query(By.css('aio-doc-viewer'));
documentService = de.injector.get(DocumentService) as DocumentService;
documentService = de.injector.get<DocumentService>(DocumentService);
docViewer = docViewerDe.nativeElement;
docViewerComponent = docViewerDe.componentInstance;
hamburger = de.query(By.css('.hamburger')).nativeElement;
locationService = de.injector.get(LocationService) as any;
locationService = de.injector.get<any>(LocationService);
sidenav = de.query(By.directive(MatSidenav)).componentInstance;
tocService = de.injector.get(TocService);
tocService = de.injector.get<TocService>(TocService);
return waitForDoc && awaitDocRendered();
};
@ -463,7 +463,7 @@ describe('AppComponent', () => {
let scrollToTopSpy: jasmine.Spy;
beforeEach(() => {
scrollService = fixture.debugElement.injector.get(ScrollService);
scrollService = fixture.debugElement.injector.get<ScrollService>(ScrollService);
scrollSpy = spyOn(scrollService, 'scroll');
scrollToTopSpy = spyOn(scrollService, 'scrollToTop');
});

View File

@ -97,11 +97,11 @@ describe('ApiListComponent', () => {
});
});
describe('initial critera from location', () => {
describe('initial criteria from location', () => {
let locationService: TestLocationService;
beforeEach(() => {
locationService = <any> fixture.componentRef.injector.get(LocationService);
locationService = fixture.componentRef.injector.get<any>(LocationService);
});
function expectOneItem(name: string, section: string, type: string, stability: string) {
@ -110,7 +110,7 @@ describe('ApiListComponent', () => {
component.filteredSections.subscribe(filtered => {
expect(filtered.length).toBe(1, 'sections');
expect(filtered[0].name).toBe(section, 'section name');
const items = filtered[0].items.filter(item => item.show);
const items = filtered[0].items.filter(i => i.show);
expect(items.length).toBe(1, 'items');
const item = items[0];
@ -168,7 +168,7 @@ describe('ApiListComponent', () => {
let locationService: TestLocationService;
beforeEach(() => {
locationService = <any> fixture.componentRef.injector.get(LocationService);
locationService = fixture.componentRef.injector.get<any>(LocationService);
});
it('should have query', () => {

View File

@ -16,9 +16,9 @@ import { ApiSection, ApiService } from './api.service';
import { Option } from 'app/shared/select/select.component';
class SearchCriteria {
query? = '';
status? = 'all';
type? = 'all';
query ? = '';
status ? = 'all';
type ? = 'all';
}
@Component({

View File

@ -21,7 +21,7 @@ describe('ApiService', () => {
]
});
service = injector.get(ApiService);
service = injector.get<ApiService>(ApiService);
httpMock = injector.get(HttpTestingController);
});

View File

@ -15,18 +15,18 @@ import { CodeComponent } from './code.component';
*/
@Component({
selector: 'code-example',
template: `
template: `
<!-- Content projection is used to get the content HTML provided to this component -->
<div #content style="display: none"><ng-content></ng-content></div>
<header *ngIf="title">{{title}}</header>
<aio-code [ngClass]="classes"
[language]="language"
[linenums]="linenums"
[path]="path"
[region]="region"
[hideCopy]="hidecopy"
<aio-code [ngClass]="classes"
[language]="language"
[linenums]="linenums"
[path]="path"
[region]="region"
[hideCopy]="hidecopy"
[title]="title">
</aio-code>
`,

View File

@ -87,7 +87,7 @@ describe('CodeTabsComponent', () => {
region="region-B"
title="title-B">
Code example 2
</code-pane>
</code-pane>
</code-tabs>
`
})

View File

@ -24,7 +24,7 @@ export interface TabInfo {
template: `
<!-- Use content projection so that the provided HTML's code-panes can be split into tabs -->
<div #content style="display: none"><ng-content></ng-content></div>
<mat-tab-group class="code-tab-group" disableRipple>
<mat-tab style="overflow-y: hidden;" *ngFor="let tab of tabs">
<ng-template mat-tab-label>
@ -37,7 +37,7 @@ export interface TabInfo {
[region]="tab.region"
[title]="tab.title">
</aio-code>
</mat-tab>
</mat-tab>
</mat-tab-group>
`,
})

View File

@ -19,7 +19,7 @@ describe('ContributorService', () => {
]
});
contribService = injector.get(ContributorService);
contribService = injector.get<ContributorService>(ContributorService);
httpMock = injector.get(HttpTestingController);
});

View File

@ -11,5 +11,5 @@ export class Contributor {
website?: string;
twitter?: string;
bio?: string;
isFlipped? = false;
isFlipped ? = false;
}

View File

@ -18,7 +18,7 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
type: TocType = 'None';
isCollapsed = true;
isEmbedded = false;
@ViewChildren('tocItem') private items: QueryList<ElementRef>;
@ViewChildren('createTocItem') private items: QueryList<ElementRef>;
private onDestroy = new Subject();
private primaryMax = 4;
tocList: TocItem[];
@ -90,5 +90,5 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
}
function count<T>(array: T[], fn: (item: T) => boolean) {
return array.reduce((count, item) => fn(item) ? count + 1 : count, 0);
return array.reduce((result, item) => fn(item) ? result + 1 : result, 0);
}

View File

@ -36,7 +36,8 @@ interface SvgIconMap {
export class CustomIconRegistry extends MatIconRegistry {
private preloadedSvgElements: SvgIconMap = {};
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document,
@Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {
super(http, sanitizer, document);
this.loadSvgElements(svgIcons);
}

View File

@ -1,5 +1,5 @@
import { Inject, Injectable } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
import { DOCUMENT } from '@angular/common';
import { fromEvent, Observable, ReplaySubject, Subject } from 'rxjs';
import { auditTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';

View File

@ -1,5 +1,6 @@
import { DOCUMENT } from '@angular/common';
import { ReflectiveInjector } from '@angular/core';
import { DOCUMENT, DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { Subject } from 'rxjs';
import { ScrollItem, ScrollSpyInfo, ScrollSpyService } from 'app/shared/scroll-spy.service';
@ -33,8 +34,8 @@ describe('TocService', () => {
describe('tocList', () => {
it('should emit the latest value to new subscribers', () => {
const expectedValue1 = tocItem('Heading A');
const expectedValue2 = tocItem('Heading B');
const expectedValue1 = createTocItem('Heading A');
const expectedValue2 = createTocItem('Heading B');
let value1: TocItem[]|undefined;
let value2: TocItem[]|undefined;
@ -48,8 +49,8 @@ describe('TocService', () => {
});
it('should emit the same values to all subscribers', () => {
const expectedValue1 = tocItem('Heading A');
const expectedValue2 = tocItem('Heading B');
const expectedValue1 = createTocItem('Heading A');
const expectedValue2 = createTocItem('Heading B');
const emittedValues: TocItem[][] = [];
tocService.tocList.subscribe(v => emittedValues.push(v));
@ -149,8 +150,8 @@ describe('TocService', () => {
describe('should clear tocList', () => {
beforeEach(() => {
// Start w/ dummy data from previous usage
const expectedValue1 = tocItem('Heading A');
const expectedValue2 = tocItem('Heading B');
const expectedValue1 = createTocItem('Heading A');
const expectedValue2 = createTocItem('Heading B');
tocService.tocList.next([expectedValue1, expectedValue2]);
expect(lastTocList).not.toEqual([]);
});
@ -369,7 +370,7 @@ class MockScrollSpyService {
}
}
function tocItem(title: string, level = 'h2', href = '', content = title) {
function createTocItem(title: string, level = 'h2', href = '', content = title) {
return { title, href, level, content };
}

View File

@ -1,5 +1,6 @@
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable } from '@angular/core';
import { DOCUMENT, DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ReplaySubject } from 'rxjs';
import { ScrollSpyInfo, ScrollSpyService } from 'app/shared/scroll-spy.service';

17
aio/src/tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"aio",
"camelCase"
],
"component-selector": [
true,
"element",
"aio",
"kebab-case"
]
}
}

View File

@ -39,14 +39,14 @@ describe('site App', function() {
navItemHeadings.each(heading => testNavItemHeading(heading!, 1));
// Helpers
function expectToBeCollapsed(element: ElementFinder) {
expect(element.getAttribute('class')).toMatch(/\bcollapsed\b/);
expect(element.getAttribute('class')).not.toMatch(/\bexpanded\b/);
function expectToBeCollapsed(elementFinder: ElementFinder) {
expect(elementFinder.getAttribute('class')).toMatch(/\bcollapsed\b/);
expect(elementFinder.getAttribute('class')).not.toMatch(/\bexpanded\b/);
}
function expectToBeExpanded(element: ElementFinder) {
expect(element.getAttribute('class')).not.toMatch(/\bcollapsed\b/);
expect(element.getAttribute('class')).toMatch(/\bexpanded\b/);
function expectToBeExpanded(elementFinder: ElementFinder) {
expect(elementFinder.getAttribute('class')).not.toMatch(/\bcollapsed\b/);
expect(elementFinder.getAttribute('class')).toMatch(/\bexpanded\b/);
}
function testNavItemHeading(heading: ElementFinder, level: number) {

View File

@ -21,7 +21,7 @@ export class SitePage {
getNavItem(pattern: RegExp) {
return element.all(by.css('aio-nav-item .vertical-menu-item'))
.filter(element => element.getText().then(text => pattern.test(text)))
.filter(elementFinder => elementFinder.getText().then(text => pattern.test(text)))
.first();
}
getNavItemHeadings(parent: ElementFinder, level: number) {
@ -49,10 +49,10 @@ export class SitePage {
return this.docViewer.getText();
}
getInnerHtml(element) {
getInnerHtml(elementFinder) {
// `getInnerHtml` was removed from webDriver and this is the workaround.
// See https://github.com/angular/protractor/blob/master/CHANGELOG.md#breaking-changes
return browser.executeScript('return arguments[0].innerHTML;', element);
return browser.executeScript('return arguments[0].innerHTML;', elementFinder);
}
getScrollTop() {
@ -63,8 +63,8 @@ export class SitePage {
return browser.executeScript('window.scrollTo(0, document.body.scrollHeight)');
}
click(element: ElementFinder) {
return element.click().then(() => browser.waitForAngular());
click(elementFinder: ElementFinder) {
return elementFinder.click().then(() => browser.waitForAngular());
}
enterSearch(query: string) {

View File

@ -11,6 +11,9 @@
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": true,
@ -55,7 +58,7 @@
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
@ -88,7 +91,6 @@
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
@ -100,8 +102,6 @@
"check-type"
],
"directive-selector": [true, "attribute", "aio", "camelCase"],
"component-selector": [true, "element", "aio", "kebab-case"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
@ -110,9 +110,6 @@
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
"directive-class-suffix": true
}
}

View File

@ -914,7 +914,7 @@ babar@0.0.3:
dependencies:
colors "~0.6.2"
babel-code-frame@^6.16.0, babel-code-frame@^6.20.0, babel-code-frame@^6.26.0:
babel-code-frame@^6.16.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
dependencies:
@ -1845,7 +1845,7 @@ buffer@^4.3.0:
ieee754 "^1.1.4"
isarray "^1.0.0"
builtin-modules@^1.0.0:
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
@ -2333,9 +2333,9 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
codelyzer@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/codelyzer/-/codelyzer-2.0.1.tgz#d0f7121f67a8424c92d21d3b31f3640b83def9ed"
codelyzer@~4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/codelyzer/-/codelyzer-4.2.1.tgz#d56eaacefca7e8138aac0a630e484bdb09988544"
dependencies:
app-root-path "^2.0.1"
css-selector-tokenizer "^0.7.0"
@ -2403,7 +2403,7 @@ comma-separated-tokens@^1.0.0, comma-separated-tokens@^1.0.1:
dependencies:
trim "0.0.1"
commander@2.15.x, commander@^2.9.0, commander@~2.15.0:
commander@2.15.x, commander@^2.12.1, commander@^2.9.0, commander@~2.15.0:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
@ -3148,11 +3148,11 @@ didyoumean@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.1.tgz#e92edfdada6537d484d73c0172fd1eba0c4976ff"
diff@^3.0.1, diff@^3.1.0:
diff@^3.1.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c"
diff@^3.3.1, diff@^3.5.0:
diff@^3.2.0, diff@^3.3.1, diff@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
@ -4056,12 +4056,6 @@ find-up@^2.0.0, find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"
findup-sync@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16"
dependencies:
glob "~5.0.0"
firebase-tools@^3.2.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/firebase-tools/-/firebase-tools-3.13.1.tgz#2ca82a5cdd5e887c5fe961cd8019e4a987625f5a"
@ -8784,6 +8778,12 @@ resolve@^1.1.6, resolve@^1.1.7:
dependencies:
path-parse "^1.0.5"
resolve@^1.3.2:
version "1.7.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
dependencies:
path-parse "^1.0.5"
resolve@^1.5.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.6.0.tgz#0fbd21278b27b4004481c395349e7aba60a9ff5c"
@ -10182,27 +10182,48 @@ tslib@^1.7.1:
version "1.8.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.0.tgz#dc604ebad64bcbf696d613da6c954aa0e7ea1eb6"
tslib@^1.9.0:
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
tslint@^4.1.1, tslint@~4.5.0:
version "4.5.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-4.5.1.tgz#05356871bef23a434906734006fc188336ba824b"
tslint@~5.8.0:
version "5.8.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.8.0.tgz#1f49ad5b2e77c76c3af4ddcae552ae4e3612eb13"
dependencies:
babel-code-frame "^6.20.0"
colors "^1.1.2"
diff "^3.0.1"
findup-sync "~0.3.0"
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.1.0"
commander "^2.9.0"
diff "^3.2.0"
glob "^7.1.1"
optimist "~0.6.0"
resolve "^1.1.7"
tsutils "^1.1.0"
update-notifier "^2.0.0"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.7.1"
tsutils "^2.12.1"
tsutils@^1.1.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0"
tslint@~5.9.1:
version "5.9.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.9.1.tgz#1255f87a3ff57eb0b0e1f0e610a8b4748046c9ae"
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.3.0"
commander "^2.12.1"
diff "^3.2.0"
glob "^7.1.1"
js-yaml "^3.7.0"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tsutils "^2.12.1"
tsutils@^2.12.1:
version "2.26.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.26.1.tgz#9e4a0cb9ff173863f34c22a961969081270d1878"
dependencies:
tslib "^1.8.1"
tty-browserify@0.0.0:
version "0.0.0"
@ -10505,7 +10526,7 @@ update-notifier@^1.0.3:
semver-diff "^2.0.0"
xdg-basedir "^2.0.0"
update-notifier@^2.0.0, update-notifier@^2.1.0:
update-notifier@^2.1.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.3.0.tgz#4e8827a6bb915140ab093559d7014e3ebb837451"
dependencies:
@ -10766,11 +10787,11 @@ void-elements@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
vrsource-tslint-rules@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz#f3cf8026e1d3a9b63d263dd591248dc96dc3ec1c"
vrsource-tslint-rules@^5.8.2:
version "5.8.2"
resolved "https://registry.yarnpkg.com/vrsource-tslint-rules/-/vrsource-tslint-rules-5.8.2.tgz#f08a8b0a254f86a9d3f39f5d2493de7c4fac1a58"
dependencies:
tslint "^4.1.1"
tslint "~5.8.0"
walkdir@^0.0.11:
version "0.0.11"