Skip to content

Commit

Permalink
added linting and linted all filed
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeKay committed Oct 29, 2015
1 parent d6b3f2e commit c739374
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 49 deletions.
2 changes: 1 addition & 1 deletion common/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import * as angular from 'angular';

export const commonAppName = 'common';
export const commonAppName:string = 'common';

angular.module(commonAppName, []);
4 changes: 2 additions & 2 deletions common/src/tests/blankTest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Blank test for karma', () => {
it('Should be true', () => {
expect(true).toBe(true);
})
});
});
});
18 changes: 12 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var sourcemaps = require('gulp-sourcemaps');
var path = require('path');
var watch = require('gulp-watch');
var karma = require('karma').Server;
var tslint = require('gulp-tslint');

module.exports = function (config) {
var tsProject = ts.createProject({
Expand All @@ -28,11 +29,9 @@ module.exports = function (config) {
});

// compile TypeScript
gulp.task('ts', ['clean'], function () {
var tsResult = gulp.src([
'common/src/**/*.ts',
path.join(config.path, 'src/**/*.ts')
])
gulp.task('ts', ['lint', 'clean'], function () {
var tsResult = gulp
.src(path.join(config.path, 'src/**/*.ts'))
.pipe(sourcemaps.init()) // with Sourcemaps
.pipe(ts(tsProject));

Expand Down Expand Up @@ -94,14 +93,21 @@ module.exports = function (config) {
}, done).start();
});

gulp.task('lint', function() {
return gulp
.src(path.join(config.path, 'src/**/*.ts'))
.pipe(tslint())
.pipe(tslint.report('verbose'));
});

// watch for file changes
gulp.task('watch', ['test'], function () {
var watchPath = [
path.join(config.path, 'src/**/*.ts'),
path.join(config.path, 'test/**/*.ts')
];
if (config.appName !== 'common') {
watchPath = watchPath.concat(path.join(__dirname, 'common/build/**/*.js'));
watchPath = watchPath.concat(path.join(__dirname, 'common/build/compiled/*.js'));
}

return watch(watchPath, function() {
Expand Down
15 changes: 6 additions & 9 deletions home/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@ import * as angular from 'angular';
import registerDirectives from './directives/appDirectives';
import registerServices from './services/appServices';

// App name
export const homeAppName = 'homeApp';
// app name
export const homeAppName:string = 'homeApp';

// Register module, directives, services, etc.
// register module, directives, services, etc.
angular.module(homeAppName, []);
registerDirectives(homeAppName);
registerServices(homeAppName);

// Bootstrap Angular
// bootstrap Angular
let appAngularConfig:angular.IAngularBootstrapConfig = {
strictDi: true,
debugInfoEnabled: true
debugInfoEnabled: true,
strictDi: true
};

angular.bootstrap(
document.getElementById('coHomeApp'),
['homeApp'],
appAngularConfig
);



6 changes: 4 additions & 2 deletions home/src/directives/appDirectives.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Import directives
// import directives
import coHome from './coHome/coHome';
import coHeader from './coHome/coHeader/coHeader';

// Register directives
// register directives
export default function registerDirectives(homeAppName:string):void {
'use strict';

angular.module(homeAppName)
.directive('coHome', coHome)
.directive('coHeader', coHeader);
Expand Down
8 changes: 5 additions & 3 deletions home/src/directives/coHome/coHeader/coHeader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { html } from './coHeaderTemplate.html';

export default function coHeader():angular.IDirective {
'use strict';

return {
scope: {},
replace: true,
scope: {},
template: html
}
}
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const html =
export const html:string =
`
<div>
<p>This directive works.</p>
Expand Down
21 changes: 11 additions & 10 deletions home/src/directives/coHome/coHome.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import * as angular from 'angular';
import { html } from './coHomeTemplate.html';
import HomeService from '../../services/HomeService/HomeService';
import {IHomeService} from "../../services/HomeService/IHomeService";
import {IHomeService} from '../../services/HomeService/IHomeService';

coHome.$inject = ['HomeService'];

function coHome(HomeService:IHomeService):angular.IDirective {
'use strict';

return {
scope: {
testing: '='
},
replace: true,
template: html,
link: ($scope:any) => {
link: ($scope:any):void => {
$scope.$watch(
() => {
return $scope.testing;
Expand All @@ -21,8 +17,13 @@ function coHome(HomeService:IHomeService):angular.IDirective {
$scope.firstLetter = HomeService.returnFirstLetter($scope.testing);
}
);
}
}
},
replace: true,
scope: {
testing: '='
},
template: html
};
}


Expand Down
4 changes: 2 additions & 2 deletions home/src/directives/coHome/coHomeTemplate.html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const html =
export const html:string =
`
<div>
<p>This directive works. 2</p>
Expand All @@ -7,4 +7,4 @@ export const html =
<h1>Another directive</h1>
<div data-co-header></div>
</div>
`;
`;
5 changes: 1 addition & 4 deletions home/src/services/HomeService/HomeService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { IHomeService } from './IHomeService';

export default class HomeService implements IHomeService {
constructor() {}

returnFirstLetter(input:string):string {
public returnFirstLetter(input:string):string {
if (input && input.length > 0) {
return input[0];
}

return '';
}
}

2 changes: 1 addition & 1 deletion home/src/services/HomeService/IHomeService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface IHomeService {
returnFirstLetter(input:string): string;
}
}
6 changes: 4 additions & 2 deletions home/src/services/appServices.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Import directives
// import directives
import HomeService from './HomeService/HomeService';

// Register directives
// register directives
export default function registerServices(homeAppName:string):void {
'use strict';

angular.module(homeAppName)
.service('HomeService', HomeService);
}
8 changes: 4 additions & 4 deletions home/src/tests/directives/coHome/coHome.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {IHomeService} from "../../../services/HomeService/IHomeService";
import HomeService from "../../../services/HomeService/HomeService";
import {IHomeService} from '../../../services/HomeService/IHomeService';
import HomeService from '../../../services/HomeService/HomeService';

describe('coHome', () => {
let $compile:ng.ICompileService,
Expand All @@ -22,8 +22,8 @@ describe('coHome', () => {

it('should test a directive', () => {
$rootScope.someInput = 'this is working';
var template = angular.element('<div data-co-home data-testing="someInput"></div>');
var element = $compile(template)($rootScope);
let template:angular.IAugmentedJQuery = angular.element('<div data-co-home data-testing="someInput"></div>');
let element:angular.IAugmentedJQuery = $compile(template)($rootScope);

$rootScope.$digest();
expect(element.html()).toContain('this is working');
Expand Down
4 changes: 2 additions & 2 deletions home/src/tests/services/HomeService/HomeService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import HomeService from '../../../services/HomeService/HomeService';
import {IHomeService} from "../../../services/HomeService/IHomeService";
import {IHomeService} from '../../../services/HomeService/IHomeService';

describe('HomeService', () => {
let homeService:IHomeService;
Expand All @@ -12,4 +12,4 @@ describe('HomeService', () => {
expect(homeService.returnFirstLetter('this is a test')).toBe('t');
expect(homeService.returnFirstLetter('why not')).toBe('w');
});
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"express": "^4.13.3",
"gulp": "^3.9.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-tslint": "^3.4.0",
"gulp-typescript": "^2.9.2",
"gulp-watch": "^4.3.5",
"jasmine": "^2.3.2",
Expand Down
123 changes: 123 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space",
"check-lowercase"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"interface-name": true,
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
"max-line-length": [
true,
140
],
"member-access": true,
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-constructor-vars": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-shadowed-variable": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": true,
"no-require-imports": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"no-trailing-comma": true,
"no-trailing-whitespace": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single",
"avoid-escape"
],
"radix": true,
"semicolon": true,
"sort-object-literal-keys": true,
"switch-default": true,
"triple-equals": [
true,
"allow-null-check"
],
"typedef": [
true,
"call-signature",
"parameter",
"property-declaration",
"variable-declaration",
"member-variable-declaration"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"use-strict": [
true,
"check-module",
"check-function"
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator"
]
}
}

0 comments on commit c739374

Please sign in to comment.