From 2b01979fb26011d359dab5a54c4829c5a22c1033 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 11 Mar 2017 10:40:20 +0900 Subject: [PATCH] Follow lint --- src/general.ts | 2 +- src/plugins/amazon.ts | 9 +++++---- src/plugins/wikipedia.ts | 5 +++-- src/summary.ts | 2 +- src/utils/clip.ts | 2 +- src/utils/null-or-empty.ts | 2 +- tslint.json | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/general.ts b/src/general.ts index 2f3f27f..67be1cf 100644 --- a/src/general.ts +++ b/src/general.ts @@ -73,7 +73,7 @@ export default async (url: URL.Url): Promise => { let icon = $('link[rel="shortcut icon"]').attr('href') || $('link[rel="icon"]').attr('href'); - + if (icon == null) { const favicon = '/favicon.ico'; diff --git a/src/plugins/amazon.ts b/src/plugins/amazon.ts index 165de0e..32d232d 100644 --- a/src/plugins/amazon.ts +++ b/src/plugins/amazon.ts @@ -1,10 +1,11 @@ import * as URL from 'url'; - import * as client from 'cheerio-httpcli'; +import summary from '../summary'; + client.set('referer', false); client.set('timeout', 10000); -export function test(url: URL.Url) { +export function test(url: URL.Url): boolean { return url.hostname === 'www.amazon.com' || url.hostname === 'www.amazon.co.jp' || url.hostname === 'www.amazon.ca' || @@ -18,10 +19,10 @@ export function test(url: URL.Url) { url.hostname === 'www.amazon.nl' || url.hostname === 'www.amazon.cn' || url.hostname === 'www.amazon.in' || - url.hostname === 'www.amazon.au' + url.hostname === 'www.amazon.au'; }; -export async function summarize(url: URL.Url) { +export async function summarize(url: URL.Url): Promise { const res = await client.fetch(url.href); const $ = res.$; diff --git a/src/plugins/wikipedia.ts b/src/plugins/wikipedia.ts index bec98ca..9d6ce13 100644 --- a/src/plugins/wikipedia.ts +++ b/src/plugins/wikipedia.ts @@ -1,15 +1,16 @@ import * as URL from 'url'; import * as request from 'request'; import * as debug from 'debug'; +import summary from '../summary'; import clip from './../utils/clip'; const log = debug('summaly:plugins:wikipedia'); -export function test(url: URL.Url) { +export function test(url: URL.Url): boolean { return /\.wikipedia\.org$/.test(url.hostname); }; -export function summarize(url: URL.Url) { +export function summarize(url: URL.Url): Promise { return new Promise((res, rej) => { const lang = url.host.split('.')[0]; const title = url.pathname.split('/')[2]; diff --git a/src/summary.ts b/src/summary.ts index 25d3c56..b40b616 100644 --- a/src/summary.ts +++ b/src/summary.ts @@ -23,6 +23,6 @@ type Summary = { * The title of that web page */ title: string; -} +}; export default Summary; diff --git a/src/utils/clip.ts b/src/utils/clip.ts index b127190..92e658c 100644 --- a/src/utils/clip.ts +++ b/src/utils/clip.ts @@ -1,6 +1,6 @@ import nullOrEmpty from './null-or-empty'; -export default function(s: string, max: number) { +export default function(s: string, max: number): string { if (nullOrEmpty(s)) { return s; } diff --git a/src/utils/null-or-empty.ts b/src/utils/null-or-empty.ts index c72da8d..84133d6 100644 --- a/src/utils/null-or-empty.ts +++ b/src/utils/null-or-empty.ts @@ -1,4 +1,4 @@ -export default function(val: string) { +export default function(val: string): boolean { if (val === undefined) { return true; } else if (val === null) { diff --git a/tslint.json b/tslint.json index 2089dbe..31f049a 100644 --- a/tslint.json +++ b/tslint.json @@ -61,7 +61,7 @@ "radix": true, "semicolon": true, "switch-default": false, - "triple-equals": true, + "triple-equals": false, "typedef": [true, "call-signature", "property-declaration"