style(tslint): add tslint

Closes #5756
This commit is contained in:
Adam Bradley
2016-04-06 20:48:09 -05:00
parent 86fc741e63
commit d8e670ca7c
19 changed files with 111 additions and 35 deletions

View File

@ -876,3 +876,17 @@ gulp.task('tooling', function(){
.pipe(gulp.dest('dist'));
})
});
/**
* TS LINT
*/
gulp.task("tslint", function() {
var tslint = require("gulp-tslint");
gulp.src([
'ionic/**/*.ts',
'!ionic/components/*/test/**/*',
'!ionic/util/test/*'
]).pipe(tslint())
.pipe(tslint.report('verbose'));
});

View File

@ -179,7 +179,7 @@ export class Animation {
if (!isNaN(num)) {
fxState.num = num;
}
fxState.unit = (r[0] != r[2] ? r[2] : '');
fxState.unit = (r[0] !== r[2] ? r[2] : '');
} else if (typeof val === 'number') {
fxState.num = val;
@ -216,7 +216,7 @@ export class Animation {
}
return this;
}
}
};
}
get after() {
@ -239,7 +239,7 @@ export class Animation {
}
return this;
}
}
};
}
play(opts: PlayOptions = {}) {

View File

@ -100,5 +100,5 @@ export function App(args: AppMetadata={}) {
});
return cls;
}
};
}

View File

@ -1,4 +1,4 @@
import {Component, ChangeDetectionStrategy, ViewEncapsulation, Type} from 'angular2/core'
import {Component, ChangeDetectionStrategy, ViewEncapsulation, Type} from 'angular2/core';
import {IONIC_DIRECTIVES} from '../config/directives';
const _reflect: any = Reflect;
@ -107,5 +107,5 @@ export function Page(config: PageMetadata) {
annotations.push(new Component(config));
_reflect.defineMetadata('annotations', annotations, cls);
return cls;
}
};
}

View File

@ -36,7 +36,7 @@ export class Gesture {
}
on(type: string, cb: Function) {
if(type == 'pinch' || type == 'rotate') {
if (type === 'pinch' || type === 'rotate') {
this._hammer.get('pinch').set({enable: true});
}
this._hammer.on(type, cb);

View File

@ -1,3 +1,4 @@
/* tslint:disable */
import {assign} from '../util/util';
const win: any = window;

View File

@ -8,7 +8,7 @@ const OPACITY = 'opacity';
const TRANSLATEX = 'translateX';
const OFF_RIGHT = '99.5%';
const OFF_LEFT = '-33%';
const CENTER = '0%'
const CENTER = '0%';
const OFF_OPACITY = 0.8;
const SHOW_BACK_BTN_CSS = 'show-back-button';

View File

@ -4,7 +4,7 @@ import {ViewController} from '../components/nav/view-controller';
const TRANSLATEY = 'translateY';
const OFF_BOTTOM = '40px';
const CENTER = '0px'
const CENTER = '0px';
const SHOW_BACK_BTN_CSS = 'show-back-button';

View File

@ -194,9 +194,9 @@ export function hasFocus(ele) {
export function isTextInput(ele) {
return !!ele &&
(ele.tagName == 'TEXTAREA' ||
(ele.tagName === 'TEXTAREA' ||
ele.contentEditable === 'true' ||
(ele.tagName == 'INPUT' && !(/^(radio|checkbox|range|file|submit|reset|color|image|button)$/i).test(ele.type)));
(ele.tagName === 'INPUT' && !(/^(radio|checkbox|range|file|submit|reset|color|image|button)$/i).test(ele.type)));
}
export function hasFocusedTextInput() {
@ -207,7 +207,7 @@ export function hasFocusedTextInput() {
return false;
}
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i;
export function copyInputAttributes(srcElement, destElement) {
// copy attributes from one element to another
// however, skip over a few of them as they're already

View File

@ -152,7 +152,7 @@ export class Keyboard {
// default is to add the focus-outline when the tab key is used
function keyDown(ev) {
if (!isKeyInputEnabled && ev.keyCode == 9) {
if (!isKeyInputEnabled && ev.keyCode === 9) {
isKeyInputEnabled = true;
enableKeyInput();
}

View File

@ -74,11 +74,11 @@ export class ScrollView {
// fraction based on the easing method
let easedT = (--time) * time * time + 1;
if (fromY != y) {
if (fromY !== y) {
self.setTop((easedT * (y - fromY)) + fromY);
}
if (fromX != x) {
if (fromX !== x) {
self._el.scrollLeft = Math.floor((easedT * (x - fromX)) + fromX);
}

View File

@ -134,7 +134,9 @@ export const isCheckedProperty = function(a: any, b: any): boolean {
}
// not using strict comparison on purpose
/* tslint:disable */
return (a == b);
/* tslint:enable */
};
/**
@ -170,7 +172,7 @@ export const array = {
arr.splice(index, 1);
return true;
}
}
};
/**
* Grab all query strings keys and values.

View File

@ -52,6 +52,7 @@
"gulp-sass": "^2.0.4",
"gulp-shell": "^0.4.0",
"gulp-strip-debug": "^1.1.0",
"gulp-tslint": "^4.3.4",
"gulp-typescript": "2.12.1",
"gulp-util": "^3.0.6",
"gulp-watch": "^4.2.4",
@ -79,6 +80,7 @@
"strip-sourcemap-loader": "0.0.1",
"systemjs": "0.19.6",
"through2": "^0.6.3",
"tslint": "^3.7.1",
"typescript": "1.8.7",
"vinyl": "^0.4.6",
"webpack": "^1.12.2",

57
tslint.json Normal file
View File

@ -0,0 +1,57 @@
{
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-var-keyword": false,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}