mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
style: make eslint check .ts files
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"types": "dist/liquid.d.ts",
|
"types": "dist/liquid.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint '**/*.ts' .",
|
||||||
"check": "npm test && npm run lint",
|
"check": "npm test && npm run lint",
|
||||||
"unit": "mocha \"test/unit/**/*.ts\"",
|
"unit": "mocha \"test/unit/**/*.ts\"",
|
||||||
"integration": "mocha \"test/integration/**/*.ts\"",
|
"integration": "mocha \"test/integration/**/*.ts\"",
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ const nodeEsm = {
|
|||||||
input
|
input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const browserEsm = {
|
const browserEsm = {
|
||||||
output: [{
|
output: [{
|
||||||
file: 'dist/liquid.browser.esm.js',
|
file: 'dist/liquid.browser.esm.js',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class Expression {
|
|||||||
private postfix: Token[]
|
private postfix: Token[]
|
||||||
private lenient: boolean
|
private lenient: boolean
|
||||||
|
|
||||||
public constructor (str: string, lenient: boolean = false) {
|
public constructor (str: string, lenient = false) {
|
||||||
const tokenizer = new Tokenizer(str)
|
const tokenizer = new Tokenizer(str)
|
||||||
this.postfix = [...toPostfix(tokenizer.readExpression())]
|
this.postfix = [...toPostfix(tokenizer.readExpression())]
|
||||||
this.lenient = lenient
|
this.lenient = lenient
|
||||||
@@ -32,7 +32,7 @@ export class Expression {
|
|||||||
const result = evalOperatorToken(token, l, r, ctx)
|
const result = evalOperatorToken(token, l, r, ctx)
|
||||||
this.operands.push(result)
|
this.operands.push(result)
|
||||||
} else {
|
} else {
|
||||||
this.operands.push(evalToken(token, ctx, this.lenient && this.postfix.length == 1))
|
this.operands.push(evalToken(token, ctx, this.lenient && this.postfix.length === 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.operands[0]
|
return this.operands[0]
|
||||||
@@ -42,7 +42,7 @@ export class Expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function evalToken (token: Token | undefined, ctx: Context, lenient: boolean = false): any {
|
export function evalToken (token: Token | undefined, ctx: Context, lenient = false): any {
|
||||||
assert(ctx, () => 'unable to evaluate: context not defined')
|
assert(ctx, () => 'unable to evaluate: context not defined')
|
||||||
if (TypeGuards.isPropertyAccessToken(token)) {
|
if (TypeGuards.isPropertyAccessToken(token)) {
|
||||||
const variable = token.getVariableAsText()
|
const variable = token.getVariableAsText()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Context } from '../context/context'
|
|||||||
import { isFunction } from '../util/underscore'
|
import { isFunction } from '../util/underscore'
|
||||||
import { isTruthy } from '../render/boolean'
|
import { isTruthy } from '../render/boolean'
|
||||||
|
|
||||||
|
|
||||||
export const operatorImpls: {[key: string]: (lhs: any, rhs: any, ctx: Context) => boolean} = {
|
export const operatorImpls: {[key: string]: (lhs: any, rhs: any, ctx: Context) => boolean} = {
|
||||||
'==': (l: any, r: any) => {
|
'==': (l: any, r: any) => {
|
||||||
if (isComparable(l)) return l.equals(r)
|
if (isComparable(l)) return l.equals(r)
|
||||||
|
|||||||
Reference in New Issue
Block a user