mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
style: introduce @typescript-eslint/recommended
This commit is contained in:
@@ -9,7 +9,7 @@ export default {
|
||||
'reverse': (v: any[]) => [...v].reverse(),
|
||||
'sort': <T>(v: T[], arg: (lhs: T, rhs: T) => number) => v.sort(arg),
|
||||
'size': (v: string | any[]) => v.length,
|
||||
'concat': <T1, T2>(v: T1[], arg: T2[] | T2): Array<T1 | T2> => Array.prototype.concat.call(v, arg),
|
||||
'concat': <T1, T2>(v: T1[], arg: T2[] | T2): (T1 | T2)[] => Array.prototype.concat.call(v, arg),
|
||||
'slice': <T>(v: T[], begin: number, length: number = 1): T[] => {
|
||||
begin = begin < 0 ? v.length + begin : begin
|
||||
return v.slice(begin, begin + length)
|
||||
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
'times': (v: number, arg: number) => v * arg
|
||||
}
|
||||
|
||||
function caseInsensitiveCmp (a, b) {
|
||||
function caseInsensitiveCmp (a: any, b: any) {
|
||||
if (!b) return -1
|
||||
if (!a) return 1
|
||||
a = toLowerCase.call(a)
|
||||
|
||||
@@ -8,7 +8,7 @@ import ITagImplOptions from '../../template/tag/itag-impl-options'
|
||||
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
|
||||
const candidatesRE = new RegExp(rValue.source, 'g')
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
export default {
|
||||
parse: function (tagToken: TagToken) {
|
||||
let match: RegExpExecArray | null = groupRE.exec(tagToken.args) as RegExpExecArray
|
||||
assert(match, `illegal tag: ${tagToken.raw}`)
|
||||
@@ -40,4 +40,4 @@ export default <ITagImplOptions>{
|
||||
|
||||
return evalValue(candidate, ctx)
|
||||
}
|
||||
}
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -17,7 +17,7 @@ const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||
`(?:\\s+(reversed))?` +
|
||||
`(?:\\s+${hash.source})*$`)
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
export default {
|
||||
type: 'block',
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
const match = re.exec(tagToken.args) as RegExpExecArray
|
||||
@@ -79,4 +79,4 @@ export default <ITagImplOptions>{
|
||||
ctx.pop()
|
||||
return html
|
||||
}
|
||||
}
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -10,7 +10,7 @@ import ITagImplOptions from '../../template/tag/itag-impl-options'
|
||||
const staticFileRE = /[^\s,]+/
|
||||
const withRE = new RegExp(`with\\s+(${value.source})`)
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
export default {
|
||||
parse: function (token: TagToken) {
|
||||
let match = staticFileRE.exec(token.args)
|
||||
if (match) this.staticValue = match[0]
|
||||
@@ -51,4 +51,4 @@ export default <ITagImplOptions>{
|
||||
ctx.setRegister('blockMode', originBlockMode)
|
||||
return html
|
||||
}
|
||||
}
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -2,7 +2,7 @@ import TagToken from '../../parser/tag-token'
|
||||
import Token from '../../parser/token'
|
||||
import ITagImplOptions from '../../template/tag/itag-impl-options'
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
this.tokens = []
|
||||
|
||||
@@ -20,4 +20,4 @@ export default <ITagImplOptions>{
|
||||
render: function () {
|
||||
return this.tokens.map((token: Token) => token.raw).join('')
|
||||
}
|
||||
}
|
||||
} as ITagImplOptions
|
||||
|
||||
Reference in New Issue
Block a user