diff --git a/src/builtin/filters/array.ts b/src/builtin/filters/array.ts index a56da41df..885e2345a 100644 --- a/src/builtin/filters/array.ts +++ b/src/builtin/filters/array.ts @@ -23,7 +23,7 @@ function concat (v: T1[], arg: T2[] | T2): (T1 | T2)[] { return Array.prototype.concat.call(v, arg) } -function slice (v: T[], begin: number, length: number = 1): T[] { +function slice (v: T[], begin: number, length = 1): T[] { begin = begin < 0 ? v.length + begin : begin return v.slice(begin, begin + length) } diff --git a/src/builtin/filters/math.ts b/src/builtin/filters/math.ts index 4dc69f84c..3e2b0781a 100644 --- a/src/builtin/filters/math.ts +++ b/src/builtin/filters/math.ts @@ -9,7 +9,7 @@ export default { 'floor': (v: number) => Math.floor(v), 'minus': (v: number, arg: number) => v - arg, 'modulo': (v: number, arg: number) => v % arg, - 'round': (v: number, arg: number = 0) => { + 'round': (v: number, arg = 0) => { const amp = Math.pow(10, arg) return Math.round(v * amp) / amp }, diff --git a/src/builtin/filters/string.ts b/src/builtin/filters/string.ts index c09208979..6d82fec7c 100644 --- a/src/builtin/filters/string.ts +++ b/src/builtin/filters/string.ts @@ -37,13 +37,13 @@ function replaceFirst (v: string, arg1: string, arg2: string) { return stringify(v).replace(arg1, arg2) } -function truncate (v: string, l: number = 50, o: string = '...') { +function truncate (v: string, l = 50, o = '...') { v = stringify(v) if (v.length <= l) return v return v.substr(0, l - o.length) + o } -function truncateWords (v: string, l: number = 15, o: string = '...') { +function truncateWords (v: string, l = 15, o = '...') { const arr = v.split(/\s+/) let ret = arr.slice(0, l).join(' ') if (arr.length >= l) ret += o diff --git a/src/builtin/tags/raw.ts b/src/builtin/tags/raw.ts index dd43fd0fe..406edcf05 100644 --- a/src/builtin/tags/raw.ts +++ b/src/builtin/tags/raw.ts @@ -1,4 +1,4 @@ -import { TagToken, Token, ITagImplOptions, Context, Emitter, Hash } from '../../types' +import { TagToken, Token, ITagImplOptions, Context } from '../../types' export default { parse: function (tagToken: TagToken, remainTokens: Token[]) { diff --git a/src/context/context.ts b/src/context/context.ts index 5f770e6d5..dddbb996e 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -11,7 +11,7 @@ export class Context { public environments: Scope public sync: boolean public opts: NormalizedFullOptions - public constructor (ctx: object = {}, opts?: NormalizedFullOptions, sync: boolean = false) { + public constructor (ctx: object = {}, opts?: NormalizedFullOptions, sync = false) { this.sync = sync this.opts = applyDefault(opts) this.environments = ctx diff --git a/src/drop/forloop-drop.ts b/src/drop/forloop-drop.ts index f902a5663..c076a0e5b 100644 --- a/src/drop/forloop-drop.ts +++ b/src/drop/forloop-drop.ts @@ -1,7 +1,7 @@ import { Drop } from './drop' export class ForloopDrop extends Drop { - protected i: number = 0 + protected i = 0 public length: number public constructor (length: number) { super() diff --git a/src/liquid.ts b/src/liquid.ts index 4b881d7ba..d3fe96c3f 100644 --- a/src/liquid.ts +++ b/src/liquid.ts @@ -144,4 +144,4 @@ export class Liquid { } return this.setCache(filepath, tpl) } -} \ No newline at end of file +} diff --git a/src/parser/parse-stream.ts b/src/parser/parse-stream.ts index ad77fd865..5c4f8e4fd 100644 --- a/src/parser/parse-stream.ts +++ b/src/parser/parse-stream.ts @@ -7,7 +7,7 @@ type ParseToken = ((token: Token, remainTokens: Token[]) => ITemplate) export class ParseStream { private tokens: Token[] private handlers: {[key: string]: (arg: any) => void} = {} - private stopRequested: boolean = false + private stopRequested = false private parseToken: ParseToken public constructor (tokens: Token[], parseToken: ParseToken) { diff --git a/src/parser/token.ts b/src/parser/token.ts index 1da596824..162f83426 100644 --- a/src/parser/token.ts +++ b/src/parser/token.ts @@ -1,7 +1,7 @@ export class Token { - public trimLeft: boolean = false - public trimRight: boolean = false - public type: string = 'notset' + public trimLeft = false + public trimRight = false + public type = 'notset' public line: number public col: number public raw: string diff --git a/src/util/underscore.ts b/src/util/underscore.ts index 76b2cc34e..90335df42 100644 --- a/src/util/underscore.ts +++ b/src/util/underscore.ts @@ -92,7 +92,7 @@ export function isObject (value: any): value is object { return value !== null && (type === 'object' || type === 'function') } -export function range (start: number, stop: number, step: number = 1) { +export function range (start: number, stop: number, step = 1) { const arr: number[] = [] for (let i = start; i < stop; i += step) { arr.push(i) @@ -100,7 +100,7 @@ export function range (start: number, stop: number, step: number = 1) { return arr } -export function padStart (str: any, length: number, ch: string = ' ') { +export function padStart (str: any, length: number, ch = ' ') { str = String(str) let n = length - str.length while (n-- > 0) str = ch + str diff --git a/test/e2e/drop.ts b/test/e2e/drop.ts index c4a3a1cfa..3edd0db06 100644 --- a/test/e2e/drop.ts +++ b/test/e2e/drop.ts @@ -5,7 +5,7 @@ import * as chaiAsPromised from 'chai-as-promised' use(chaiAsPromised) class SettingsDrop extends Drop { - private foo: string = 'FOO' + private foo = 'FOO' public bar () { return 'BAR' } diff --git a/test/integration/drop/drop.ts b/test/integration/drop/drop.ts index bd81ba21b..656ed709c 100644 --- a/test/integration/drop/drop.ts +++ b/test/integration/drop/drop.ts @@ -6,7 +6,7 @@ describe('drop/drop', function () { before(() => (liquid = new Liquid())) class CustomDrop extends Drop { - private name: string = 'NAME' + private name = 'NAME' public getName () { return 'GET NAME' }