Skip to content

Commit b45b0c7

Browse files
authored
Merge pull request #23 from readdle/feature/tslint-support
Add tslint and fix all warnings
2 parents 663f142 + ad596c8 commit b45b0c7

File tree

12 files changed

+1219
-28
lines changed

12 files changed

+1219
-28
lines changed

decorators/directive/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ export function Directive<IComponentClass>({selector}: {
4141
Reflect.defineMetadata(Metakeys.type, DeclarationType.directive, target);
4242

4343
return target;
44-
}
44+
};
4545
}

decorators/ng-module/index.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import importHandler from "./metadata-handlers/import";
22
import daclarationHandler from "./metadata-handlers/declaration";
33
import providerHandler from "./metadata-handlers/provider";
4-
import counter from '../../helpers/counter';
4+
import counter from "../../helpers/counter";
55

66
export function NgModule({id, imports, declarations, providers, directRegister}: any) {
77
return function (target: any) {
8-
var ng1ModuleIds: Array<string> = [];
9-
var ng1RouterConfig;
8+
let ng1ModuleIds: Array<string> = [];
9+
let ng1RouterConfig;
1010

11-
if (imports && imports.length) {
12-
var {ng1ModuleIds, ng1RouterConfig} = importHandler(imports);
11+
const hasImports = imports && imports.length;
12+
13+
if (hasImports) {
14+
const handledImports = importHandler(imports);
15+
ng1ModuleIds = handledImports.ng1ModuleIds;
16+
ng1RouterConfig = handledImports.ng1RouterConfig;
1317
}
1418

1519
target.ng1ShiftModuleName = `${target.name}-${counter("moduleName")}`;
@@ -35,5 +39,5 @@ export function NgModule({id, imports, declarations, providers, directRegister}:
3539
if (directRegister) {
3640
directRegister(ng1Module);
3741
}
38-
}
42+
};
3943
}

decorators/ng-module/metadata-handlers/import.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ export default function importHandler(imports: Array<ng1Module>) {
3030
return {
3131
ng1ModuleIds,
3232
ng1RouterConfig
33-
}
33+
};
3434
}

helpers/array.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function findFirst<T>(array: Array<T>, expression: (value: T) => boolean): T {
22
if (!angular.isFunction(expression)) {
3-
let first = array[0];
3+
const first = array[0];
44
if (!first) {
55
return null;
66
}

helpers/counter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
let store = {} as any;
1+
const entityCounters: Record<string, number> = {};
22

33
export default function counter(entity: string) {
4-
const registeredEntity = entity in store;
4+
const registeredEntity = entity in entityCounters;
55

66
if (!registeredEntity) {
7-
store[entity] = 0;
7+
entityCounters[entity] = 0;
88
}
99

10-
return store[entity]++;
10+
return entityCounters[entity]++;
1111
}

helpers/kebab-case-to-camel-case.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export default function kebabCaseToCamelCase(str: string) {
22
if (str.indexOf("-") !== -1) {
3-
const newArr = str.split("-");
3+
const newArr = str.toLowerCase().split("-");
44

5-
for (var i = 1 ; i < newArr.length ; i++) {
5+
// We are starting from 1 because the first letter in camelCase word is in lowercase
6+
for (let i = 1; i < newArr.length; i++) {
67
newArr[i] = newArr[i].charAt(0).toUpperCase() + newArr[i].substr(1);
78
}
89

index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function Inject(dependencyName: string): ParameterDecorator {
8383
};
8484
}
8585

86-
export function Component<IComponentClass>(config?: {selector?: string, template?: string}): ClassDecorator {
86+
export function Component(config?: {selector?: string, template?: string}): ClassDecorator {
8787
return function (target: any) {
8888
if (config) {
8989
if (config.template) {
@@ -118,7 +118,7 @@ export function Component<IComponentClass>(config?: {selector?: string, template
118118
Reflect.defineMetadata(Metakeys.type, DeclarationType.component, target);
119119

120120
return target;
121-
}
121+
};
122122
}
123123

124124
export class EventEmitter {

0 commit comments

Comments
 (0)