chore(): tslint checks

This commit is contained in:
Manu Mtz.-Almeida
2018-09-06 21:49:28 +02:00
parent abc9afcc35
commit 4876df928d
19 changed files with 61 additions and 26 deletions

View File

@ -27,7 +27,7 @@
"ionicons": "4.4.3" "ionicons": "4.4.3"
}, },
"devDependencies": { "devDependencies": {
"@stencil/core": "0.13.0-3", "@stencil/core": "0.13.0-4",
"@stencil/dev-server": "latest", "@stencil/dev-server": "latest",
"@stencil/sass": "0.1.0", "@stencil/sass": "0.1.0",
"@stencil/utils": "latest", "@stencil/utils": "latest",
@ -44,7 +44,7 @@
"stylelint": "^9.4.0", "stylelint": "^9.4.0",
"stylelint-order": "^0.8.1", "stylelint-order": "^0.8.1",
"tslint": "^5.10.0", "tslint": "^5.10.0",
"tslint-ionic-rules": "0.0.18", "tslint-ionic-rules": "0.0.19",
"tslint-react": "^3.6.0", "tslint-react": "^3.6.0",
"typescript": "^2.9.2", "typescript": "^2.9.2",
"yargs": "^12.0.1" "yargs": "^12.0.1"

View File

@ -4011,7 +4011,7 @@ export namespace Components {
* The text to display on the ok button. Default: `OK`. * The text to display on the ok button. Default: `OK`.
*/ */
'okText': string; 'okText': string;
'open': (ev?: UIEvent | undefined) => Promise<HTMLIonPopoverElement | HTMLIonActionSheetElement | HTMLIonAlertElement>; 'open': (ev?: UIEvent | undefined) => Promise<HTMLIonActionSheetElement | HTMLIonAlertElement | HTMLIonPopoverElement>;
/** /**
* The text to display when the select is empty. * The text to display when the select is empty.
*/ */

View File

@ -46,11 +46,11 @@ export class BackButton {
*/ */
@Prop() text?: string; @Prop() text?: string;
private onClick(ev: Event) { async onClick(ev: Event) {
const nav = this.el.closest('ion-nav'); const nav = this.el.closest('ion-nav');
ev.preventDefault(); ev.preventDefault();
if (nav && nav.canGoBack()) { if (nav && await nav.canGoBack()) {
return nav.pop({ skipIfBusy: true }); return nav.pop({ skipIfBusy: true });
} }
return openURL(this.win, this.defaultHref, ev, 'back'); return openURL(this.win, this.defaultHref, ev, 'back');

View File

@ -11,11 +11,11 @@ export function renderDatetime(template: string, value: DatetimeData | undefined
const token = '{' + index + '}'; const token = '{' + index + '}';
const text = renderTextFormat(format.f, (value as any)[format.k], value, locale); const text = renderTextFormat(format.f, (value as any)[format.k], value, locale);
if (!hasText && text && (value as any)[format.k] != null) { if (!hasText && text !== undefined && (value as any)[format.k] != null) {
hasText = true; hasText = true;
} }
tokens.push(token, text); tokens.push(token, text || '');
template = template.replace(format.f, token); template = template.replace(format.f, token);
} }
@ -32,7 +32,7 @@ export function renderDatetime(template: string, value: DatetimeData | undefined
return template; return template;
} }
export function renderTextFormat(format: string, value: any, date: DatetimeData | undefined, locale: LocaleData): string { export function renderTextFormat(format: string, value: any, date: DatetimeData | undefined, locale: LocaleData): string | undefined {
if ((format === FORMAT_DDDD || format === FORMAT_DDD)) { if ((format === FORMAT_DDDD || format === FORMAT_DDD)) {
try { try {
value = (new Date(date!.year!, date!.month! - 1, date!.day)).getDay(); value = (new Date(date!.year!, date!.month! - 1, date!.day)).getDay();
@ -47,7 +47,7 @@ export function renderTextFormat(format: string, value: any, date: DatetimeData
// ignore // ignore
} }
return ''; return undefined;
} }
if (format === FORMAT_A) { if (format === FORMAT_A) {

View File

@ -234,9 +234,9 @@ export class ItemSliding {
this.setOpenAmount(restingPoint, true); this.setOpenAmount(restingPoint, true);
if (this.state & SlidingState.SwipeEnd && this.rightOptions) { if ((this.state & SlidingState.SwipeEnd) !== 0 && this.rightOptions) {
this.rightOptions.fireSwipeEvent(); this.rightOptions.fireSwipeEvent();
} else if (this.state & SlidingState.SwipeStart && this.leftOptions) { } else if ((this.state & SlidingState.SwipeStart) !== 0 && this.leftOptions) {
this.leftOptions.fireSwipeEvent(); this.leftOptions.fireSwipeEvent();
} }
} }

View File

@ -0,0 +1,34 @@
import { newE2EPage } from '@stencil/core/testing';
describe('menu', () => {
it('should open menu', async () => {
// create a new e2e test page
const page = await newE2EPage({
html: `
<ion-app>
<ion-menu>
<ion-content>Content</ion-content>
</ion-menu>
<div main></div>
</ion-app>
`
});
const menu = await page.find('ion-menu');
expect(menu).toHaveClasses([
'menu-type-overlay',
'menu-side-start',
]);
await menu.callMethod('open', false);
await page.waitForChanges();
expect(menu).toHaveClasses([
'menu-type-overlay',
'menu-enabled',
'menu-side-start',
]);
});
});

View File

@ -22,7 +22,7 @@ export class NavPush {
push() { push() {
const nav = this.el.closest('ion-nav'); const nav = this.el.closest('ion-nav');
const toPush = this.component; const toPush = this.component;
if (nav && toPush) { if (nav && toPush !== undefined) {
return nav.push(toPush, this.componentProps, { skipIfBusy: true }); return nav.push(toPush, this.componentProps, { skipIfBusy: true });
} }
return Promise.resolve(false); return Promise.resolve(false);

View File

@ -23,7 +23,7 @@ export class NavSetRoot {
push() { push() {
const nav = this.el.closest('ion-nav'); const nav = this.el.closest('ion-nav');
const toPush = this.component; const toPush = this.component;
if (nav && toPush) { if (nav && toPush !== undefined) {
return nav.setRoot(toPush, this.componentProps, { skipIfBusy: true }); return nav.setRoot(toPush, this.componentProps, { skipIfBusy: true });
} }
return Promise.resolve(false); return Promise.resolve(false);

View File

@ -436,7 +436,7 @@ export class Nav implements NavOutlet {
} }
private canGoBackSync(view = this.getActiveSync()): boolean { private canGoBackSync(view = this.getActiveSync()): boolean {
return !!(view && this.getPrevious(view)); return !!(view && this.getPreviousSync(view));
} }
private getPreviousSync(view = this.getActiveSync()): ViewController | undefined { private getPreviousSync(view = this.getActiveSync()): ViewController | undefined {

View File

@ -105,7 +105,7 @@ export class RouterOutlet implements NavOutlet {
let resolve!: () => void; let resolve!: () => void;
this.waitPromise = new Promise(r => resolve = r); this.waitPromise = new Promise(r => resolve = r);
if (p) { if (p !== undefined) {
await p; await p;
} }
return resolve; return resolve;

View File

@ -219,7 +219,7 @@ export class Router {
let resolve!: () => void; let resolve!: () => void;
this.waitPromise = new Promise(r => resolve = r); this.waitPromise = new Promise(r => resolve = r);
if (p) { if (p !== undefined) {
await p; await p;
} }
return resolve; return resolve;

View File

@ -471,7 +471,7 @@ export class Select {
let addPlaceholderClass = false; let addPlaceholderClass = false;
let selectText = this.selectedText || this.text; let selectText = this.selectedText || this.text;
if (selectText === undefined && this.placeholder) { if (selectText === undefined && this.placeholder !== undefined) {
selectText = this.placeholder; selectText = this.placeholder;
addPlaceholderClass = true; addPlaceholderClass = true;
} }

View File

@ -131,7 +131,7 @@ export class Tab {
} }
private prepareLazyLoaded(): Promise<HTMLElement | void> { private prepareLazyLoaded(): Promise<HTMLElement | void> {
if (!this.loaded && this.component) { if (!this.loaded && this.component != null) {
this.loaded = true; this.loaded = true;
return attachComponent(this.delegate, this.el, this.component, ['ion-page']); return attachComponent(this.delegate, this.el, this.component, ['ion-page']);
} }

View File

@ -272,7 +272,7 @@ export class VirtualScroll {
} }
} }
private updateCellHeight(cell: Cell, node: HTMLStencilElement) { private updateCellHeight(cell: Cell, node: any) {
const update = () => { const update = () => {
if ((node as any)['$ionCell'] === cell) { if ((node as any)['$ionCell'] === cell) {
const style = this.win.getComputedStyle(node); const style = this.win.getComputedStyle(node);

View File

@ -37,7 +37,7 @@ export type PredefinedColors = 'primary' | 'secondary' | 'tertiary' | 'success'
export type Color = PredefinedColors | string; export type Color = PredefinedColors | string;
export type Mode = 'ios' | 'md'; export type Mode = 'ios' | 'md';
export type ComponentTags = keyof StencilIntrinsicElements; export type ComponentTags = keyof StencilIntrinsicElements;
export type ComponentRef = Function | HTMLElement | string; export type ComponentRef = Function | HTMLElement | string | null;
export type ComponentProps<T = null> = T extends ComponentTags ? StencilIntrinsicElements[T] : {[key: string]: any}; export type ComponentProps<T = null> = T extends ComponentTags ? StencilIntrinsicElements[T] : {[key: string]: any};
export type CssClassMap = { [className: string]: boolean }; export type CssClassMap = { [className: string]: boolean };
export type BackButtonEvent = CustomEvent<{ export type BackButtonEvent = CustomEvent<{

View File

@ -1,6 +1,6 @@
import { BackButtonEvent } from '../interface'; import { BackButtonEvent } from '../interface';
type Handler = () => Promise<any> | void; type Handler = () => Promise<any> | void | null;
interface HandlerRegister { interface HandlerRegister {
priority: number; priority: number;
@ -35,7 +35,7 @@ export function startHardwareBackButton(win: Window) {
} }
}); });
const result = handler!(); const result = handler!();
if (result) { if (result != null) {
// tslint:disable-next-line:no-floating-promises // tslint:disable-next-line:no-floating-promises
result.then(() => busy = false); result.then(() => busy = false);
} }

View File

@ -75,7 +75,7 @@ function jsSetFocus(
}); });
} }
function hasPointerMoved(threshold: number, startCoord: PointerCoordinates, endCoord: PointerCoordinates) { function hasPointerMoved(threshold: number, startCoord: PointerCoordinates | undefined, endCoord: PointerCoordinates | undefined) {
if (startCoord && endCoord) { if (startCoord && endCoord) {
const deltaX = (startCoord.x - endCoord.x); const deltaX = (startCoord.x - endCoord.x);
const deltaY = (startCoord.y - endCoord.y); const deltaY = (startCoord.y - endCoord.y);

View File

@ -1,7 +1,7 @@
import { Color, CssClassMap, Mode, RouterDirection } from '../interface'; import { Color, CssClassMap, Mode, RouterDirection } from '../interface';
export function hostContext(selector: string, el: HTMLElement): boolean { export function hostContext(selector: string, el: HTMLElement): boolean {
return !!el.closest(selector); return el.closest(selector) !== null;
} }
/** /**
@ -38,8 +38,8 @@ export function getClassMap(classes: string | string[] | undefined): CssClassMap
return map; return map;
} }
export async function openURL(win: Window, url: string | undefined, ev: Event | undefined | null, direction?: RouterDirection): Promise<boolean> { export async function openURL(win: Window, url: string | undefined | null, ev: Event | undefined | null, direction?: RouterDirection): Promise<boolean> {
if (url && url[0] !== '#' && url.indexOf('://') === -1) { if (url != null && url[0] !== '#' && url.indexOf('://') === -1) {
const router = win.document.querySelector('ion-router'); const router = win.document.querySelector('ion-router');
if (router) { if (router) {
if (ev != null) { if (ev != null) {

View File

@ -15,6 +15,7 @@
"no-null-keyword": false, "no-null-keyword": false,
"no-console": false, "no-console": false,
"no-unbound-method": true, "no-unbound-method": true,
"no-floating-promises": true,
"jsx-key": false, "jsx-key": false,
"jsx-self-close": false, "jsx-self-close": false,