Skip to content

Chore(lint): add codelyzer #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nativescript-angular/common/detached-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function log(message: string) {
selector: "DetachedContainer",
template: `<Placeholder #loader></Placeholder>`
})
export class DetachedLoader {
export class DetachedLoader { // tslint:disable-line:component-class-suffix
constructor(
private resolver: ComponentFactoryResolver,
private changeDetector: ChangeDetectorRef,
Expand All @@ -31,7 +31,7 @@ export class DetachedLoader {
const componentRef = this.containerRef.createComponent(
factory, this.containerRef.length, this.containerRef.parentInjector);

// Component is created, buit may not be checked if we are loading
// Component is created, buit may not be checked if we are loading
// inside component with OnPush CD strategy. Mark us for check to be sure CD will reach us.
// We are inside a promise here so no need for setTimeout - CD should trigger
// after the promise.
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isBlank, isNumber} from "../lang-facade";
import { isBlank, isNumber } from "../lang-facade";

export function convertToInt(value): number {
let normalizedValue;
Expand Down
12 changes: 6 additions & 6 deletions nativescript-angular/directives/action-bar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, Component, ElementRef, Optional } from "@angular/core";
import { Directive, Component, ElementRef, Optional, OnDestroy } from "@angular/core";
import { ActionItem, ActionBar, NavigationButton } from "ui/action-bar";
import { isBlank } from "../lang-facade";
import { Page } from "ui/page";
Expand Down Expand Up @@ -63,7 +63,7 @@ export class ActionBarComponent {
selector: "ActionBarExtension",
template: ""
})
export class ActionBarScope {
export class ActionBarScope { // tslint:disable-line:component-class-suffix
constructor(private page: Page) {
}

Expand All @@ -88,9 +88,9 @@ export class ActionBarScope {
}

@Directive({
selector: "ActionItem"
selector: "ActionItem" // tslint:disable-line:directive-selector
})
export class ActionItemDirective {
export class ActionItemDirective implements OnDestroy {
constructor(public element: ElementRef, @Optional() private ownerScope: ActionBarScope) {
if (this.ownerScope) {
this.ownerScope.onActionInit(this);
Expand All @@ -105,9 +105,9 @@ export class ActionItemDirective {
}

@Directive({
selector: "NavigationButton"
selector: "NavigationButton" // tslint:disable-line:directive-selector
})
export class NavigationButtonDirective {
export class NavigationButtonDirective implements OnDestroy {
constructor(public element: ElementRef, @Optional() private ownerScope: ActionBarScope) {
if (this.ownerScope) {
this.ownerScope.onNavButtonInit(this);
Expand Down
4 changes: 2 additions & 2 deletions nativescript-angular/directives/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export class ModalDialogService {


@Directive({
selector: "[modal-dialog-host]"
selector: "[modal-dialog-host]" // tslint:disable-line:directive-selector
})
export class ModalDialogHost {
export class ModalDialogHost { // tslint:disable-line:directive-class-suffix
constructor() {
throw new Error("ModalDialogHost is deprecated. Call ModalDialogService.showModal() " +
"by passing ViewContainerRef in the options instead.");
Expand Down
6 changes: 5 additions & 1 deletion nativescript-angular/directives/list-view-comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export interface SetupItemViewArgs {
<DetachedContainer>
<Placeholder #loader></Placeholder>
</DetachedContainer>`,
inputs: ["items"],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
Expand All @@ -72,6 +71,11 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {

@ContentChild(TemplateRef) itemTemplate: TemplateRef<ListItemContext>;

@Input()
get items() {
return this._items;
}

set items(value: any) {
this._items = value;
let needDiffer = true;
Expand Down
6 changes: 3 additions & 3 deletions nativescript-angular/directives/platform-filters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, Inject} from "@angular/core";
import {Device, platformNames} from "platform";
import {DEVICE} from "../platform-providers";
import { Component, Inject } from "@angular/core";
import { Device, platformNames } from "platform";
import { DEVICE } from "../platform-providers";

@Component({
selector: "android",
Expand Down
25 changes: 17 additions & 8 deletions nativescript-angular/directives/tab-view.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ElementRef, Directive, Input, TemplateRef, ViewContainerRef } from "@angular/core";
import { ElementRef, Directive, Input, TemplateRef, ViewContainerRef, OnInit, AfterViewInit } from "@angular/core";
import { TabView, TabViewItem } from "ui/tab-view";
import * as utils from "../common/utils";
import { rendererLog } from "../trace";
import { isBlank } from "../lang-facade";

@Directive({
selector: "TabView",
inputs: ["selectedIndex"]
selector: "TabView", // tslint:disable-line:directive-selector
})
export class TabViewDirective {
export class TabViewDirective implements AfterViewInit {
public tabView: TabView;
private _selectedIndex: number;
private viewInitialized: boolean;

@Input()
get selectedIndex(): number {
return this._selectedIndex;
}
Expand All @@ -38,10 +38,9 @@ export class TabViewDirective {
}

@Directive({
selector: "[tabItem]",
inputs: ["title", "iconSource"]
selector: "[tabItem]" // tslint:disable-line:directive-selector
})
export class TabViewItemDirective {
export class TabViewItemDirective implements OnInit {
private item: TabViewItem;
private _title: string;
private _iconSource: string;
Expand All @@ -53,7 +52,12 @@ export class TabViewItemDirective {
) {
}

@Input("tabItem") config: any;
@Input("tabItem") config: any; // tslint:disable-line:no-input-rename

@Input()
get title() {
return this._title;
}

set title(value: string) {
if (this._title !== value) {
Expand All @@ -63,6 +67,11 @@ export class TabViewItemDirective {
}
}

@Input()
get iconSource() {
return this._iconSource;
}

set iconSource(value: string) {
if (this._iconSource !== value) {
this._iconSource = value;
Expand Down
4 changes: 2 additions & 2 deletions nativescript-angular/file-system/ns-file-system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from "@angular/core";
import {knownFolders, Folder} from "file-system";
import { Injectable } from "@angular/core";
import { knownFolders, Folder } from "file-system";

// Allows greater flexibility with `file-system` and Angular
// Also provides a way for `file-system` to be mocked for testing
Expand Down
6 changes: 3 additions & 3 deletions nativescript-angular/http/ns-http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Injectable} from "@angular/core";
import { Injectable } from "@angular/core";
import {
Http,
ConnectionBackend,
Expand All @@ -7,9 +7,9 @@ import {
ResponseType,
Response
} from "@angular/http";
import {Observable} from "rxjs/Observable";
import { Observable } from "rxjs/Observable";
import "rxjs/add/observable/fromPromise";
import {NSFileSystem} from "../file-system/ns-file-system";
import { NSFileSystem } from "../file-system/ns-file-system";

export class NSXSRFStrategy {
public configureRequest(_req: any) {
Expand Down
17 changes: 9 additions & 8 deletions nativescript-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"url": "https://github.com/NativeScript/nativescript-angular.git"
},
"scripts": {
"tslint": "tslint --project tsconfig.json --config tslint.json",
"postinstall": "node postinstall.js",
"ngc": "ngc -p tsconfig.json",
"tsc": "tsc -p tsconfig.json",
"prepublish": "npm run tsc && npm run ngc"
"tslint": "tslint --project tsconfig.json --config tslint.json",
"postinstall": "node postinstall.js",
"ngc": "ngc -p tsconfig.json",
"tsc": "tsc -p tsconfig.json",
"prepublish": "npm run tsc && npm run ngc"
},
"dependencies": {
"nativescript-intl": "~0.0.4",
Expand All @@ -38,11 +38,12 @@
"url": "0.10.3"
},
"devDependencies": {
"@angular/compiler-cli": "~2.2.1",
"codelyzer": "^2.0.0-beta.1",
"tns-core-modules": ">=2.4.0 || >=2.4.0-2016",
"zone.js": "^0.6.21",
"typescript": "^2.0.2",
"tslint": "~4.0.1",
"@angular/compiler-cli": "~2.2.1"
"typescript": "^2.0.2",
"zone.js": "^0.6.21"
},
"nativescript": {}
}
2 changes: 1 addition & 1 deletion nativescript-angular/private_import_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {__core_private__ as r} from "@angular/core";
import { __core_private__ as r } from "@angular/core";

export type RenderDebugInfo = typeof r._RenderDebugInfo;
export let RenderDebugInfo: typeof r.RenderDebugInfo = r.RenderDebugInfo;
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/private_import_platform-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {__platform_browser_private__ as _} from "@angular/platform-browser";
import { __platform_browser_private__ as _ } from "@angular/platform-browser";

export type DomAdapter = typeof _._DomAdapter;
export let DomAdapter: typeof _.DomAdapter = _.DomAdapter;
Expand Down
16 changes: 8 additions & 8 deletions nativescript-angular/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
} from "@angular/core";
import { AnimationPlayer } from "@angular/core";
import { AnimationStyles, AnimationKeyframe } from "./private_import_core";
import {APP_ROOT_VIEW, DEVICE} from "./platform-providers";
import {isBlank} from "./lang-facade";
import {View} from "ui/core/view";
import { APP_ROOT_VIEW, DEVICE } from "./platform-providers";
import { isBlank } from "./lang-facade";
import { View } from "ui/core/view";
import * as application from "application";
import {topmost} from "ui/frame";
import {Page} from "ui/page";
import {ViewUtil, NgView} from "./view-util";
import {rendererLog as traceLog} from "./trace";
import {escapeRegexSymbols} from "utils/utils";
import { topmost } from "ui/frame";
import { Page } from "ui/page";
import { ViewUtil, NgView } from "./view-util";
import { rendererLog as traceLog } from "./trace";
import { escapeRegexSymbols } from "utils/utils";
import { Device } from "platform";

import * as nsAnimationDriver from "./animation-driver";
Expand Down
4 changes: 2 additions & 2 deletions nativescript-angular/resource-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {path, knownFolders, File} from "file-system";
import {ResourceLoader} from "@angular/compiler";
import { path, knownFolders, File } from "file-system";
import { ResourceLoader } from "@angular/compiler";

export class FileSystemResourceLoader extends ResourceLoader {
resolve(url: string, baseUrl: string): string {
Expand Down
8 changes: 4 additions & 4 deletions nativescript-angular/router/ns-platform-location.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {NSLocationStrategy} from "./ns-location-strategy";
import {PlatformLocation, LocationChangeListener} from "@angular/common";
import {Injectable} from "@angular/core";
import {routerLog} from "../trace";
import { NSLocationStrategy } from "./ns-location-strategy";
import { PlatformLocation, LocationChangeListener } from "@angular/common";
import { Injectable } from "@angular/core";
import { routerLog } from "../trace";


@Injectable()
Expand Down
10 changes: 5 additions & 5 deletions nativescript-angular/router/ns-router-link-active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
ElementRef, Input, OnChanges, OnDestroy,
QueryList, Renderer
} from "@angular/core";
import {Subscription} from "rxjs/Subscription";
import { Subscription } from "rxjs/Subscription";

import {NavigationEnd, Router, UrlTree} from "@angular/router";
import {containsTree} from "../router-url-tree";
import { NavigationEnd, Router, UrlTree } from "@angular/router";
import { containsTree } from "../router-url-tree";

import {NSRouterLink} from "./ns-router-link";
import { NSRouterLink } from "./ns-router-link";


/**
Expand Down Expand Up @@ -54,7 +54,7 @@ import {NSRouterLink} from "./ns-router-link";
* @stable
*/
@Directive({ selector: "[nsRouterLinkActive]" })
export class NSRouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
export class NSRouterLinkActive implements OnChanges, OnDestroy, AfterContentInit { // tslint:disable-line:max-line-length directive-class-suffix
@ContentChildren(NSRouterLink) links: QueryList<NSRouterLink>;

private classes: string[] = [];
Expand Down
20 changes: 10 additions & 10 deletions nativescript-angular/router/ns-router-link.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Directive, HostListener, Input, Optional, OnChanges} from "@angular/core";
import {NavigationExtras} from "@angular/router";
import {ActivatedRoute, Router, UrlTree} from "@angular/router";
import {routerLog} from "../trace";
import {PageRoute} from "./page-router-outlet";
import {RouterExtensions} from "./router-extensions";
import {NavigationOptions} from "./ns-location-strategy";
import {NavigationTransition} from "ui/frame";
import {isString} from "utils/types";
import { Directive, HostListener, Input, Optional, OnChanges } from "@angular/core";
import { NavigationExtras } from "@angular/router";
import { ActivatedRoute, Router, UrlTree } from "@angular/router";
import { routerLog } from "../trace";
import { PageRoute } from "./page-router-outlet";
import { RouterExtensions } from "./router-extensions";
import { NavigationOptions } from "./ns-location-strategy";
import { NavigationTransition } from "ui/frame";
import { isString } from "utils/types";

/**
* The nsRouterLink directive lets you link to specific parts of your app.
Expand All @@ -33,7 +33,7 @@ import {isString} from "utils/types";
* And if the segment begins with `../`, the router will go up one level.
*/
@Directive({ selector: "[nsRouterLink]" })
export class NSRouterLink implements OnChanges {
export class NSRouterLink implements OnChanges { // tslint:disable-line:directive-class-suffix
private commands: any[] = [];
@Input() target: string;
@Input() queryParams: { [k: string]: any };
Expand Down
4 changes: 2 additions & 2 deletions nativescript-angular/router/page-router-outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class RefCache {
}
}

@Directive({ selector: "page-router-outlet" })
export class PageRouterOutlet {
@Directive({ selector: "page-router-outlet" }) // tslint:disable-line:directive-selector
export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
private viewUtil: ViewUtil;
private refCache: RefCache = new RefCache();
private isInitialPage: boolean = true;
Expand Down
8 changes: 4 additions & 4 deletions nativescript-angular/router/router-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Injectable} from "@angular/core";
import {Router, UrlTree, NavigationExtras} from "@angular/router";
import {NSLocationStrategy, NavigationOptions} from "./ns-location-strategy";
import {Frame} from "ui/frame";
import { Injectable } from "@angular/core";
import { Router, UrlTree, NavigationExtras } from "@angular/router";
import { NSLocationStrategy, NavigationOptions } from "./ns-location-strategy";
import { Frame } from "ui/frame";

export type ExtendedNavigationExtras = NavigationExtras & NavigationOptions;

Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/trace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {write, categories, messageType} from "trace";
import { write, categories, messageType } from "trace";

export const rendererTraceCategory = "ns-renderer";
export const routerTraceCategory = "ns-router";
Expand Down
21 changes: 20 additions & 1 deletion nativescript-angular/tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"rules": {
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules":{
"directive-selector": [true, "attribute", "ns", "camelCase"],
"component-selector": [true, "element", "", "camelCase"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"pipe-naming": [true, "camelCase", "ns"],
"component-class-suffix": true,
"directive-class-suffix": true,
"import-destructuring-spacing": true,
"templates-use-public": true,
"no-access-missing-member": true,
"invoke-injectable": true,
"member-access": false,
"no-any": false,
"no-inferrable-types": false,
Expand Down
Loading