Skip to content

Commit 4081ded

Browse files
committed
chore(lint): add codelyzer
1 parent 00513c6 commit 4081ded

28 files changed

+181
-126
lines changed

nativescript-angular/common/detached-loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function log(message: string) {
1919
selector: "DetachedContainer",
2020
template: `<Placeholder #loader></Placeholder>`
2121
})
22-
export class DetachedLoader {
22+
export class DetachedLoader { // tslint:disable-line:component-class-suffix
2323
constructor(
2424
private resolver: ComponentFactoryResolver,
2525
private changeDetector: ChangeDetectorRef,
@@ -31,7 +31,7 @@ export class DetachedLoader {
3131
const componentRef = this.containerRef.createComponent(
3232
factory, this.containerRef.length, this.containerRef.parentInjector);
3333

34-
// Component is created, buit may not be checked if we are loading
34+
// Component is created, buit may not be checked if we are loading
3535
// inside component with OnPush CD strategy. Mark us for check to be sure CD will reach us.
3636
// We are inside a promise here so no need for setTimeout - CD should trigger
3737
// after the promise.

nativescript-angular/common/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isBlank, isNumber} from "../lang-facade";
1+
import { isBlank, isNumber } from "../lang-facade";
22

33
export function convertToInt(value): number {
44
let normalizedValue;

nativescript-angular/directives/action-bar.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, Component, ElementRef, Optional } from "@angular/core";
1+
import { Directive, Component, ElementRef, Optional, OnDestroy } from "@angular/core";
22
import { ActionItem, ActionBar, NavigationButton } from "ui/action-bar";
33
import { isBlank } from "../lang-facade";
44
import { Page } from "ui/page";
@@ -63,7 +63,7 @@ export class ActionBarComponent {
6363
selector: "ActionBarExtension",
6464
template: ""
6565
})
66-
export class ActionBarScope {
66+
export class ActionBarScope { // tslint:disable-line:component-class-suffix
6767
constructor(private page: Page) {
6868
}
6969

@@ -88,9 +88,9 @@ export class ActionBarScope {
8888
}
8989

9090
@Directive({
91-
selector: "ActionItem"
91+
selector: "ActionItem" // tslint:disable-line:directive-selector
9292
})
93-
export class ActionItemDirective {
93+
export class ActionItemDirective implements OnDestroy {
9494
constructor(public element: ElementRef, @Optional() private ownerScope: ActionBarScope) {
9595
if (this.ownerScope) {
9696
this.ownerScope.onActionInit(this);
@@ -105,9 +105,9 @@ export class ActionItemDirective {
105105
}
106106

107107
@Directive({
108-
selector: "NavigationButton"
108+
selector: "NavigationButton" // tslint:disable-line:directive-selector
109109
})
110-
export class NavigationButtonDirective {
110+
export class NavigationButtonDirective implements OnDestroy {
111111
constructor(public element: ElementRef, @Optional() private ownerScope: ActionBarScope) {
112112
if (this.ownerScope) {
113113
this.ownerScope.onNavButtonInit(this);

nativescript-angular/directives/dialogs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export class ModalDialogService {
9191

9292

9393
@Directive({
94-
selector: "[modal-dialog-host]"
94+
selector: "[modal-dialog-host]" // tslint:disable-line:directive-selector
9595
})
96-
export class ModalDialogHost {
96+
export class ModalDialogHost { // tslint:disable-line:directive-class-suffix
9797
constructor() {
9898
throw new Error("ModalDialogHost is deprecated. Call ModalDialogService.showModal() " +
9999
"by passing ViewContainerRef in the options instead.");

nativescript-angular/directives/list-view-comp.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export interface SetupItemViewArgs {
5353
<DetachedContainer>
5454
<Placeholder #loader></Placeholder>
5555
</DetachedContainer>`,
56-
inputs: ["items"],
5756
changeDetection: ChangeDetectionStrategy.OnPush
5857
})
5958
export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
@@ -72,6 +71,11 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
7271

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

74+
@Input()
75+
get items() {
76+
return this._items;
77+
}
78+
7579
set items(value: any) {
7680
this._items = value;
7781
let needDiffer = true;

nativescript-angular/directives/platform-filters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {Component, Inject} from "@angular/core";
2-
import {Device, platformNames} from "platform";
3-
import {DEVICE} from "../platform-providers";
1+
import { Component, Inject } from "@angular/core";
2+
import { Device, platformNames } from "platform";
3+
import { DEVICE } from "../platform-providers";
44

55
@Component({
66
selector: "android",

nativescript-angular/directives/tab-view.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { ElementRef, Directive, Input, TemplateRef, ViewContainerRef } from "@angular/core";
1+
import { ElementRef, Directive, Input, TemplateRef, ViewContainerRef, OnInit, AfterViewInit } from "@angular/core";
22
import { TabView, TabViewItem } from "ui/tab-view";
33
import * as utils from "../common/utils";
44
import { rendererLog } from "../trace";
55
import { isBlank } from "../lang-facade";
66

77
@Directive({
8-
selector: "TabView",
9-
inputs: ["selectedIndex"]
8+
selector: "TabView", // tslint:disable-line:directive-selector
109
})
11-
export class TabViewDirective {
10+
export class TabViewDirective implements AfterViewInit {
1211
public tabView: TabView;
1312
private _selectedIndex: number;
1413
private viewInitialized: boolean;
1514

15+
@Input()
1616
get selectedIndex(): number {
1717
return this._selectedIndex;
1818
}
@@ -38,10 +38,9 @@ export class TabViewDirective {
3838
}
3939

4040
@Directive({
41-
selector: "[tabItem]",
42-
inputs: ["title", "iconSource"]
41+
selector: "[tabItem]" // tslint:disable-line:directive-selector
4342
})
44-
export class TabViewItemDirective {
43+
export class TabViewItemDirective implements OnInit {
4544
private item: TabViewItem;
4645
private _title: string;
4746
private _iconSource: string;
@@ -53,7 +52,12 @@ export class TabViewItemDirective {
5352
) {
5453
}
5554

56-
@Input("tabItem") config: any;
55+
@Input("tabItem") config: any; // tslint:disable-line:no-input-rename
56+
57+
@Input()
58+
get title() {
59+
return this._title;
60+
}
5761

5862
set title(value: string) {
5963
if (this._title !== value) {
@@ -63,6 +67,11 @@ export class TabViewItemDirective {
6367
}
6468
}
6569

70+
@Input()
71+
get iconSource() {
72+
return this._iconSource;
73+
}
74+
6675
set iconSource(value: string) {
6776
if (this._iconSource !== value) {
6877
this._iconSource = value;

nativescript-angular/file-system/ns-file-system.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Injectable} from "@angular/core";
2-
import {knownFolders, Folder} from "file-system";
1+
import { Injectable } from "@angular/core";
2+
import { knownFolders, Folder } from "file-system";
33

44
// Allows greater flexibility with `file-system` and Angular
55
// Also provides a way for `file-system` to be mocked for testing

nativescript-angular/http/ns-http.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from "@angular/core";
1+
import { Injectable } from "@angular/core";
22
import {
33
Http,
44
ConnectionBackend,
@@ -7,9 +7,9 @@ import {
77
ResponseType,
88
Response
99
} from "@angular/http";
10-
import {Observable} from "rxjs/Observable";
10+
import { Observable } from "rxjs/Observable";
1111
import "rxjs/add/observable/fromPromise";
12-
import {NSFileSystem} from "../file-system/ns-file-system";
12+
import { NSFileSystem } from "../file-system/ns-file-system";
1313

1414
export class NSXSRFStrategy {
1515
public configureRequest(_req: any) {

nativescript-angular/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"url": "https://github.com/NativeScript/nativescript-angular.git"
1515
},
1616
"scripts": {
17-
"tslint": "tslint --project tsconfig.json --config tslint.json",
18-
"postinstall": "node postinstall.js",
19-
"ngc": "ngc -p tsconfig.json",
20-
"tsc": "tsc -p tsconfig.json",
21-
"prepublish": "npm run tsc && npm run ngc"
17+
"tslint": "tslint --project tsconfig.json --config tslint.json",
18+
"postinstall": "node postinstall.js",
19+
"ngc": "ngc -p tsconfig.json",
20+
"tsc": "tsc -p tsconfig.json",
21+
"prepublish": "npm run tsc && npm run ngc"
2222
},
2323
"dependencies": {
2424
"nativescript-intl": "~0.0.4",
@@ -38,11 +38,12 @@
3838
"url": "0.10.3"
3939
},
4040
"devDependencies": {
41+
"@angular/compiler-cli": "~2.2.1",
42+
"codelyzer": "^2.0.0-beta.1",
4143
"tns-core-modules": ">=2.4.0 || >=2.4.0-2016",
42-
"zone.js": "^0.6.21",
43-
"typescript": "^2.0.2",
4444
"tslint": "~4.0.1",
45-
"@angular/compiler-cli": "~2.2.1"
45+
"typescript": "^2.0.2",
46+
"zone.js": "^0.6.21"
4647
},
4748
"nativescript": {}
4849
}

nativescript-angular/private_import_core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {__core_private__ as r} from "@angular/core";
9+
import { __core_private__ as r } from "@angular/core";
1010

1111
export type RenderDebugInfo = typeof r._RenderDebugInfo;
1212
export let RenderDebugInfo: typeof r.RenderDebugInfo = r.RenderDebugInfo;

nativescript-angular/private_import_platform-browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

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

1111
export type DomAdapter = typeof _._DomAdapter;
1212
export let DomAdapter: typeof _.DomAdapter = _.DomAdapter;

nativescript-angular/renderer.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import {
44
} from "@angular/core";
55
import { AnimationPlayer } from "@angular/core";
66
import { AnimationStyles, AnimationKeyframe } from "./private_import_core";
7-
import {APP_ROOT_VIEW, DEVICE} from "./platform-providers";
8-
import {isBlank} from "./lang-facade";
9-
import {View} from "ui/core/view";
7+
import { APP_ROOT_VIEW, DEVICE } from "./platform-providers";
8+
import { isBlank } from "./lang-facade";
9+
import { View } from "ui/core/view";
1010
import * as application from "application";
11-
import {topmost} from "ui/frame";
12-
import {Page} from "ui/page";
13-
import {ViewUtil, NgView} from "./view-util";
14-
import {rendererLog as traceLog} from "./trace";
15-
import {escapeRegexSymbols} from "utils/utils";
11+
import { topmost } from "ui/frame";
12+
import { Page } from "ui/page";
13+
import { ViewUtil, NgView } from "./view-util";
14+
import { rendererLog as traceLog } from "./trace";
15+
import { escapeRegexSymbols } from "utils/utils";
1616
import { Device } from "platform";
1717

1818
import * as nsAnimationDriver from "./animation-driver";

nativescript-angular/resource-loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {path, knownFolders, File} from "file-system";
2-
import {ResourceLoader} from "@angular/compiler";
1+
import { path, knownFolders, File } from "file-system";
2+
import { ResourceLoader } from "@angular/compiler";
33

44
export class FileSystemResourceLoader extends ResourceLoader {
55
resolve(url: string, baseUrl: string): string {

nativescript-angular/router/ns-platform-location.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {NSLocationStrategy} from "./ns-location-strategy";
2-
import {PlatformLocation, LocationChangeListener} from "@angular/common";
3-
import {Injectable} from "@angular/core";
4-
import {routerLog} from "../trace";
1+
import { NSLocationStrategy } from "./ns-location-strategy";
2+
import { PlatformLocation, LocationChangeListener } from "@angular/common";
3+
import { Injectable } from "@angular/core";
4+
import { routerLog } from "../trace";
55

66

77
@Injectable()

nativescript-angular/router/ns-router-link-active.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import {
33
ElementRef, Input, OnChanges, OnDestroy,
44
QueryList, Renderer
55
} from "@angular/core";
6-
import {Subscription} from "rxjs/Subscription";
6+
import { Subscription } from "rxjs/Subscription";
77

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

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

1313

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

6060
private classes: string[] = [];

nativescript-angular/router/ns-router-link.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {Directive, HostListener, Input, Optional, OnChanges} from "@angular/core";
2-
import {NavigationExtras} from "@angular/router";
3-
import {ActivatedRoute, Router, UrlTree} from "@angular/router";
4-
import {routerLog} from "../trace";
5-
import {PageRoute} from "./page-router-outlet";
6-
import {RouterExtensions} from "./router-extensions";
7-
import {NavigationOptions} from "./ns-location-strategy";
8-
import {NavigationTransition} from "ui/frame";
9-
import {isString} from "utils/types";
1+
import { Directive, HostListener, Input, Optional, OnChanges } from "@angular/core";
2+
import { NavigationExtras } from "@angular/router";
3+
import { ActivatedRoute, Router, UrlTree } from "@angular/router";
4+
import { routerLog } from "../trace";
5+
import { PageRoute } from "./page-router-outlet";
6+
import { RouterExtensions } from "./router-extensions";
7+
import { NavigationOptions } from "./ns-location-strategy";
8+
import { NavigationTransition } from "ui/frame";
9+
import { isString } from "utils/types";
1010

1111
/**
1212
* The nsRouterLink directive lets you link to specific parts of your app.
@@ -33,7 +33,7 @@ import {isString} from "utils/types";
3333
* And if the segment begins with `../`, the router will go up one level.
3434
*/
3535
@Directive({ selector: "[nsRouterLink]" })
36-
export class NSRouterLink implements OnChanges {
36+
export class NSRouterLink implements OnChanges { // tslint:disable-line:directive-class-suffix
3737
private commands: any[] = [];
3838
@Input() target: string;
3939
@Input() queryParams: { [k: string]: any };

nativescript-angular/router/page-router-outlet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class RefCache {
5656
}
5757
}
5858

59-
@Directive({ selector: "page-router-outlet" })
60-
export class PageRouterOutlet {
59+
@Directive({ selector: "page-router-outlet" }) // tslint:disable-line:directive-selector
60+
export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
6161
private viewUtil: ViewUtil;
6262
private refCache: RefCache = new RefCache();
6363
private isInitialPage: boolean = true;

nativescript-angular/router/router-extensions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Injectable} from "@angular/core";
2-
import {Router, UrlTree, NavigationExtras} from "@angular/router";
3-
import {NSLocationStrategy, NavigationOptions} from "./ns-location-strategy";
4-
import {Frame} from "ui/frame";
1+
import { Injectable } from "@angular/core";
2+
import { Router, UrlTree, NavigationExtras } from "@angular/router";
3+
import { NSLocationStrategy, NavigationOptions } from "./ns-location-strategy";
4+
import { Frame } from "ui/frame";
55

66
export type ExtendedNavigationExtras = NavigationExtras & NavigationOptions;
77

nativescript-angular/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {write, categories, messageType} from "trace";
1+
import { write, categories, messageType } from "trace";
22

33
export const rendererTraceCategory = "ns-renderer";
44
export const routerTraceCategory = "ns-router";

nativescript-angular/tslint.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
{
2-
"rules": {
2+
"rulesDirectory": [
3+
"node_modules/codelyzer"
4+
],
5+
"rules":{
6+
"directive-selector": [true, "attribute", "ns", "camelCase"],
7+
"component-selector": [true, "element", "", "camelCase"],
8+
"use-input-property-decorator": true,
9+
"use-output-property-decorator": true,
10+
"use-host-property-decorator": true,
11+
"no-input-rename": true,
12+
"no-output-rename": true,
13+
"use-life-cycle-interface": true,
14+
"use-pipe-transform-interface": true,
15+
"pipe-naming": [true, "camelCase", "ns"],
16+
"component-class-suffix": true,
17+
"directive-class-suffix": true,
18+
"import-destructuring-spacing": true,
19+
"templates-use-public": true,
20+
"no-access-missing-member": true,
21+
"invoke-injectable": true,
322
"member-access": false,
423
"no-any": false,
524
"no-inferrable-types": false,

0 commit comments

Comments
 (0)