style(tslint): tslint updates

This commit is contained in:
Adam Bradley
2016-04-06 21:28:52 -05:00
parent d8e670ca7c
commit 6f3b9bef82
41 changed files with 133 additions and 137 deletions

View File

@ -885,8 +885,7 @@ gulp.task("tslint", function() {
var tslint = require("gulp-tslint");
gulp.src([
'ionic/**/*.ts',
'!ionic/components/*/test/**/*',
'!ionic/util/test/*'
'!ionic/**/test/**/*',
]).pipe(tslint())
.pipe(tslint.report('verbose'));
});

View File

@ -38,7 +38,7 @@ export class Badge {
attrName = elementAttrs[i].name;
// Ignore attributes item-left, item-right
if (attrName.indexOf('item') == -1) {
if (attrName.indexOf('item') === -1) {
this._setClass(attrName);
}
}

View File

@ -168,7 +168,7 @@ export class Content extends Ion {
return () => {
if (!this.scrollElement) { return; }
this.scrollElement.removeEventListener(type, handler);
}
};
}
/**

View File

@ -150,7 +150,7 @@ export class Icon {
css += this._name;
}
if (this.mode == 'ios' && !this.isActive) {
if (this.mode === 'ios' && !this.isActive) {
css += '-outline';
}

View File

@ -1,4 +1,4 @@
import {Component, Input} from 'angular2/core'
import {Component, Input} from 'angular2/core';
import {NgIf} from 'angular2/common';
import {Config} from '../../config/config';

View File

@ -172,7 +172,7 @@ export class InfiniteScroll {
if (this._thrPc) {
reloadY += (reloadY * this._thrPc);
} else {
reloadY += this._thrPx
reloadY += this._thrPx;
}
let distanceFromInfinite = ((d.scrollHeight - infiniteHeight) - d.scrollTop) - reloadY;

View File

@ -398,7 +398,7 @@ export class InputBase {
* @private
*/
clearTextInput() {
console.debug("Should clear input");
console.debug('Should clear input');
}
/**
@ -578,7 +578,6 @@ export class InputBase {
const SCROLL_ASSIST_SPEED = 0.3;
function getScrollAssistDuration(distanceToScroll) {
//return 3000;
distanceToScroll = Math.abs(distanceToScroll);
let duration = distanceToScroll / SCROLL_ASSIST_SPEED;
return Math.min(400, Math.max(150, duration));

View File

@ -65,7 +65,7 @@ class MenuRevealType extends MenuType {
constructor(menu) {
super();
let openedX = (menu.width() * (menu.side == 'right' ? -1 : 1)) + 'px';
let openedX = (menu.width() * (menu.side === 'right' ? -1 : 1)) + 'px';
this.ani
.easing('ease')
@ -95,10 +95,11 @@ class MenuPushType extends MenuType {
let contentOpenedX, menuClosedX, menuOpenedX;
if (menu.side == 'right') {
if (menu.side === 'right') {
contentOpenedX = -menu.width() + 'px';
menuOpenedX = (menu._platform.width() - menu.width()) + 'px';
menuClosedX = menu._platform.width() + 'px';
} else {
contentOpenedX = menu.width() + 'px';
menuOpenedX = '0px';
@ -132,7 +133,7 @@ class MenuOverlayType extends MenuType {
.duration(250);
let closedX, openedX;
if (menu.side == 'right') {
if (menu.side === 'right') {
// right side
closedX = menu._platform.width() + 'px';
openedX = (menu._platform.width() - menu.width() - 8) + 'px';

View File

@ -708,7 +708,7 @@ export class NavController extends Ion {
startIndex = this._views.length - 1;
} else if (startIndex < 0 || startIndex >= this._views.length) {
return Promise.reject("remove index out of range");
return Promise.reject('remove index out of range');
}
if (isBlank(opts)) {

View File

@ -78,7 +78,7 @@ export class NavPush {
if (this.navPush instanceof Array) {
if (this.navPush.length > 2) {
throw 'Too many [navPush] arguments, expects [View, { params }]'
throw 'Too many [navPush] arguments, expects [View, { params }]';
}
destination = this.navPush[0];
params = this.navPush[1] || this.navParams;
@ -88,7 +88,7 @@ export class NavPush {
params = this.navParams;
}
if (typeof destination === "string") {
if (typeof destination === 'string') {
destination = this.registry.get(destination);
}

View File

@ -94,7 +94,7 @@ export class ViewController {
constructor(public componentType?: Type, data?: any) {
// passed in data could be NavParams, but all we care about is its data object
this.data = (data instanceof NavParams ? data.data : isPresent(data) ? data : {});
this.data = (data instanceof NavParams ? data.data : (isPresent(data) ? data : {}));
}
subscribe(generatorOrNext?: any): any {

View File

@ -186,7 +186,7 @@ export class RadioGroup {
remove(button: RadioButton) {
let index = this._btns.indexOf(button);
if (index > -1) {
if (button.value == this.value) {
if (button.value === this.value) {
this.value = null;
}
this._btns.splice(index, 1);

View File

@ -1,4 +1,4 @@
import {Component, Input} from 'angular2/core'
import {Component, Input} from 'angular2/core';
import {NgIf} from 'angular2/common';
import {Config} from '../../config/config';

View File

@ -1,4 +1,4 @@
import {Directive, ElementRef, EventEmitter, Host, Input, Output, NgZone} from 'angular2/core'
import {Directive, ElementRef, EventEmitter, Host, Input, Output, NgZone} from 'angular2/core';
import {NgIf, NgClass} from 'angular2/common';
import {Content} from '../content/content';

View File

@ -83,7 +83,7 @@ export class Scroll extends Ion {
return () => {
this.scrollElement.removeEventListener('scroll', handler);
}
};
}
}

View File

@ -67,7 +67,7 @@ export class SearchbarInput {
directives: [FORM_DIRECTIVES, NgIf, NgClass, Icon, Button, SearchbarInput]
})
export class Searchbar extends Ion {
private _tmr: number;
private _tmr: any;
/**
* @private
@ -191,7 +191,7 @@ export class Searchbar extends Ion {
if (this.ngModel) this.value = this.ngModel;
this.onChange(this.value);
this.shouldLeftAlign = this.value && this.value.trim() != '';
this.shouldLeftAlign = this.value && this.value.trim() !== '';
// Using querySelector instead of searchbarInput because at this point it doesn't exist
this.inputElement = this._elementRef.nativeElement.querySelector('.searchbar-input');
@ -222,8 +222,8 @@ export class Searchbar extends Ion {
if (this.mode !== 'ios') return;
if (this.shouldLeftAlign) {
this.inputElement.removeAttribute("style");
this.searchIconElement.removeAttribute("style");
this.inputElement.removeAttribute('style');
this.searchIconElement.removeAttribute('style');
} else {
this.addElementLeft();
}
@ -245,11 +245,11 @@ export class Searchbar extends Ion {
tempSpan.remove();
// Set the input padding left
let inputLeft = "calc(50% - " + (textWidth / 2) + "px)";
let inputLeft = 'calc(50% - ' + (textWidth / 2) + 'px)';
this.inputElement.style.paddingLeft = inputLeft;
// Set the icon margin left
let iconLeft = "calc(50% - " + ((textWidth / 2) + 30) + "px)";
let iconLeft = 'calc(50% - ' + ((textWidth / 2) + 30) + 'px)';
this.searchIconElement.style.marginLeft = iconLeft;
}
@ -288,7 +288,7 @@ export class Searchbar extends Ion {
inputBlurred() {
// blurInput determines if it should blur
// if we are clearing the input we still want to stay focused in the input
if (this.blurInput == false) {
if (this.blurInput === false) {
this.searchbarInput._elementRef.nativeElement.focus();
this.blurInput = true;
return;
@ -296,7 +296,7 @@ export class Searchbar extends Ion {
this.blur.emit(this);
this.isFocused = false;
this.shouldLeftAlign = this.value && this.value.trim() != '';
this.shouldLeftAlign = this.value && this.value.trim() !== '';
this.setElementLeft();
}

View File

@ -233,7 +233,7 @@ export class Select {
label: input.text,
value: input.value,
checked: input.checked
}
};
});
// create the alert instance from our built up alertOptions

View File

@ -1,4 +1,4 @@
import {Directive, Attribute, NgZone} from 'angular2/core'
import {Directive, Attribute, NgZone} from 'angular2/core';
import {Platform} from '../../platform/platform';
@ -42,12 +42,12 @@ export class DisplayWhen {
orientation(): boolean {
for (let i = 0; i < this.conditions.length; i++) {
if (this.conditions[i] == 'portrait') {
if (this.conditions[i] === 'portrait') {
this.isMatch = this.platform.isPortrait();
return true;
}
if (this.conditions[i] == 'landscape') {
if (this.conditions[i] === 'landscape') {
this.isMatch = this.platform.isLandscape();
return true;
}

View File

@ -7,7 +7,7 @@ import {Gesture} from '../../gestures/gesture';
import {DragGesture} from '../../gestures/drag-gesture';
import {dom} from '../../util';
import {CSS} from '../../util/dom';
import {debounce, isTrueProperty, defaults} from '../../util/util'
import {debounce, isTrueProperty, defaults} from '../../util/util';
import {Swiper} from './swiper-widget';
import {Scroll} from '../scroll/scroll';
@ -151,7 +151,7 @@ export class Slides extends Ion {
zoomable: HTMLElement,
zoomableWidth: number,
zoomableHeight: number
}
};
/**
* @input {boolean} Whether the slide should show the pager or not
@ -356,12 +356,12 @@ export class Slides extends Ion {
this.zoomGesture.on('pinch', (e) => {
this.scale = Math.max(1, Math.min(last_scale * e.scale, 10));
console.debug('Scaling', this.scale);
this.zoomElement.style[CSS.transform] = 'scale(' + this.scale + ')'
this.zoomElement.style[CSS.transform] = 'scale(' + this.scale + ')';
zoomRect = this.zoomElement.getBoundingClientRect();
});
this.zoomGesture.on('pinchend', (e) => {
this.zoomGesture.on('pinchend', () => {
// last_scale = Math.max(1, Math.min(last_scale * e.scale, 10));
if (this.scale > this.maxScale) {
let za = new Animation(this.zoomElement)
@ -438,7 +438,7 @@ export class Slides extends Ion {
za.add(zi);
if (this.scale > 1) {
// Zoom out
// zoom out
// zw.fromTo('translateX', posX + 'px', '0px');
// zw.fromTo('translateY', posY + 'px', '0px');
@ -452,7 +452,7 @@ export class Slides extends Ion {
this.scale = 1;
} else {
// Zoom in
// zoom in
// zw.fromTo('translateX', posX + 'px', tx + 'px');
// zw.fromTo('translateY', posY + 'px', ty + 'px');
@ -502,11 +502,10 @@ export class Slides extends Ion {
zoomable: target,
zoomableWidth: target.offsetWidth,
zoomableHeight: target.offsetHeight
}
};
console.debug('Target', this.touch.target);
// TODO: android prevent default
}
/**
@ -521,9 +520,9 @@ export class Slides extends Ion {
let zoomableScaledWidth = this.touch.zoomableWidth * this.scale;
let zoomableScaledHeight = this.touch.zoomableHeight * this.scale;
let x1 = Math.min((this.viewportWidth / 2) - zoomableScaledWidth/2, 0)
let x1 = Math.min((this.viewportWidth / 2) - zoomableScaledWidth / 2, 0);
let x2 = -x1;
let y1 = Math.min((this.viewportHeight / 2) - zoomableScaledHeight/2, 0)
let y1 = Math.min((this.viewportHeight / 2) - zoomableScaledHeight / 2, 0);
let y2 = -y1;
console.debug('BOUNDS', x1, x2, y1, y2);
@ -534,7 +533,7 @@ export class Slides extends Ion {
console.debug('PAN', e);
// Move image
// move image
this.touch.x = this.touch.deltaX + this.touch.lastX;
this.touch.y = this.touch.deltaY + this.touch.lastY;
@ -546,9 +545,9 @@ export class Slides extends Ion {
}
if (this.touch.x > this.viewportWidth) {
// Too far on the left side, let the event bubble up (to enable slider on edges, for example)
// too far on the left side, let the event bubble up (to enable slider on edges, for example)
} else if (-this.touch.x > this.viewportWidth) {
// Too far on the right side, let the event bubble up (to enable slider on edges, for example)
// too far on the right side, let the event bubble up (to enable slider on edges, for example)
} else {
console.debug('TRANSFORM', this.touch.x, this.touch.y, this.touch.target);
// this.touch.target.style[CSS.transform] = 'translateX(' + this.touch.x + 'px) translateY(' + this.touch.y + 'px)';

View File

@ -1,12 +1,11 @@
export declare class Swiper {
constructor(container: HTMLElement, params: any);
slides: Array<HTMLElement>;
activeIndex: number;
isEnd: boolean;
isBeginning: boolean;
update(): any;
slideNext(): any;
slidePrev(): any;
}

View File

@ -185,7 +185,7 @@ export class Spinner {
}
_loadEle(spinner: any, index: number, total: number) {
let duration = this._dur || spinner.dur
let duration = this._dur || spinner.dur;
let data = spinner.fn(duration, index, total);
data.style.animationDuration = duration + 'ms';
return data;
@ -206,7 +206,7 @@ const SPINNERS = {
transform: 'rotate(' + (30 * index + (index < 6 ? 180 : -180)) + 'deg)',
animationDelay: -(dur - ((dur / total) * index)) + 'ms'
}
}
};
}
},
@ -221,7 +221,7 @@ const SPINNERS = {
transform: 'rotate(' + (30 * index + (index < 6 ? 180 : -180)) + 'deg)',
animationDelay: -(dur - ((dur / total) * index)) + 'ms'
}
}
};
}
},
@ -236,7 +236,7 @@ const SPINNERS = {
left: 9 * Math.cos(2 * Math.PI * index / total),
animationDelay: -(dur - ((dur / total) * index)) + 'ms'
}
}
};
}
},
@ -251,7 +251,7 @@ const SPINNERS = {
left: 9 * Math.cos(2 * Math.PI * index / total),
animationDelay: -(dur - ((dur / total) * index)) + 'ms'
}
}
};
}
},
@ -262,7 +262,7 @@ const SPINNERS = {
return {
r: 26,
style: {}
}
};
}
},
@ -276,7 +276,7 @@ const SPINNERS = {
left: (9 - (9 * index)),
animationDelay: -(110 * index) + 'ms'
}
}
};
}
}

View File

@ -45,7 +45,7 @@ export class TabButton extends Ion {
this._layout = this.tab.parent.tabbarLayout || this._layout;
this.hasTitle = !!this.tab.tabTitle;
this.hasIcon = !!this.tab.tabIcon && this._layout != 'icon-hide';
this.hasIcon = !!this.tab.tabIcon && this._layout !== 'icon-hide';
this.hasTitleOnly = (this.hasTitle && !this.hasIcon);
this.hasIconOnly = (this.hasIcon && !this.hasTitle);
this.hasBadge = !!this.tab.tabBadge;

View File

@ -132,7 +132,7 @@ export class Tabs extends Ion {
/**
* @private
*/
parent: any
parent: any;
constructor(
@Optional() viewCtrl: ViewController,
@ -171,7 +171,7 @@ export class Tabs extends Ion {
this._setConfig('tabbarIcons', 'top');
if (this.tabbarIcons) {
console.warn("DEPRECATION WARNING: 'tabbarIcons' is no longer supported and will be removed in next major release. Use 'tabbarLayout' instead. Available values: 'icon-top', 'icon-left', 'icon-right', 'icon-bottom', 'icon-hide', 'title-hide'.");
console.warn('DEPRECATION WARNING: "tabbarIcons" is no longer supported and will be removed in next major release. Use "tabbarLayout" instead. Available values: "icon-top", "icon-left", "icon-right", "icon-bottom", "icon-hide", "title-hide".');
}
if (this._useHighlight) {
@ -342,7 +342,7 @@ export class Tabs extends Ion {
// Otherwise, if the page we're on is not our real root, reset it to our
// default root type
if (tab.root != active.componentType) {
if (tab.root !== active.componentType) {
return tab.setRoot(tab.root);
}

View File

@ -27,10 +27,10 @@ export class TapClick {
) {
let self = this;
if (config.get('activator') == 'ripple') {
if (config.get('activator') === 'ripple') {
self.activator = new RippleActivator(app, config, zone);
} else if (config.get('activator') == 'highlight') {
} else if (config.get('activator') === 'highlight') {
self.activator = new Activator(app, config, zone);
}

View File

@ -238,8 +238,8 @@ export function populateNodeData(startCellIndex: number, endCellIndex: number, v
// apply the cell's data to this node
availableNode.view.setLocal('\$implicit', cell.data || records[cell.record]);
availableNode.view.setLocal('index', cellIndex);
availableNode.view.setLocal('even', (cellIndex % 2 == 0));
availableNode.view.setLocal('odd', (cellIndex % 2 == 1));
availableNode.view.setLocal('even', (cellIndex % 2 === 0));
availableNode.view.setLocal('odd', (cellIndex % 2 === 1));
availableNode.hasChanges = true;
availableNode.lastTransform = null;
madeChanges = true;

View File

@ -1,31 +1,31 @@
export * from './config/bootstrap'
export * from './config/config'
export * from './config/directives'
export * from './config/bootstrap';
export * from './config/config';
export * from './config/directives';
export * from './decorators/app'
export * from './decorators/page'
export * from './decorators/app';
export * from './decorators/page';
export * from './components'
export * from './components';
export * from './platform/platform'
export * from './platform/storage'
export * from './platform/platform';
export * from './platform/storage';
export * from './util/click-block'
export * from './util/events'
export * from './util/keyboard'
export * from './util/form'
export * from './util/click-block';
export * from './util/events';
export * from './util/keyboard';
export * from './util/form';
export * from './animations/animation'
export * from './transitions/transition'
export * from './animations/animation';
export * from './transitions/transition';
export * from './translation/translate'
export * from './translation/translate_pipe'
export * from './translation/translate';
export * from './translation/translate_pipe';
// these modules don't export anything
import './config/modes'
import './platform/registry'
import './animations/builtins'
import './transitions/transition-ios'
import './transitions/transition-md'
import './transitions/transition-wp'
import './config/modes';
import './platform/registry';
import './animations/builtins';
import './transitions/transition-ios';
import './transitions/transition-md';
import './transitions/transition-wp';

View File

@ -109,7 +109,7 @@ export class SqlStorage extends StorageEngine {
} catch (err) {
reject({ err: err });
}
})
});
}
/**

View File

@ -4,7 +4,7 @@
*
* For most cases, we recommend the SqlStorage system as it will store
* data in a file in the app's sandbox. LocalStorage should ONLY be used
* for temporary data as it may be "cleaned up" by the operation system
* for temporary data as it may be 'cleaned up' by the operation system
* during low disk space situations.
*/
/**
@ -68,18 +68,18 @@ export class StorageEngine {
constructor(options = {}) { }
get(key: string): Promise<any> {
throw Error("get() not implemented for this storage engine");
throw Error('get() not implemented for this storage engine');
}
set(key: string, value: any): Promise<any> {
throw Error("set() not implemented for this storage engine");
throw Error('set() not implemented for this storage engine');
}
remove(key: string): Promise<any> {
throw Error("remove() not implemented for this storage engine");
throw Error('remove() not implemented for this storage engine');
}
query(query: string, params?: any): Promise<any> {
throw Error("query() not implemented for this storage engine");
throw Error('query() not implemented for this storage engine');
}
clear(): Promise<any> {
throw Error("clear() not implemented for this storage engine");
throw Error('clear() not implemented for this storage engine');
}
}

View File

@ -1,4 +1,3 @@
import * as domUtil from './util/dom'
export const dom = domUtil
export * from './util/util'
import * as domUtil from './util/dom';
export const dom = domUtil;
export * from './util/util';