From 117673a725eedfd2a4c720e96ff197fe22c11f98 Mon Sep 17 00:00:00 2001 From: harttle Date: Tue, 8 Dec 2020 00:24:07 +0800 Subject: [PATCH] style: make eslint check .ts files --- package.json | 2 +- rollup.config.ts | 1 - src/render/expression.ts | 8 ++++---- src/render/operator.ts | 1 - test/integration/builtin/tags/tablerow.ts | 2 +- test/integration/liquid/strict.ts | 4 ++-- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 1a684a712..3b240f97b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "types": "dist/liquid.d.ts", "scripts": { - "lint": "eslint .", + "lint": "eslint '**/*.ts' .", "check": "npm test && npm run lint", "unit": "mocha \"test/unit/**/*.ts\"", "integration": "mocha \"test/integration/**/*.ts\"", diff --git a/rollup.config.ts b/rollup.config.ts index d3ba2ab5f..a73e82d6f 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -57,7 +57,6 @@ const nodeEsm = { input } - const browserEsm = { output: [{ file: 'dist/liquid.browser.esm.js', diff --git a/src/render/expression.ts b/src/render/expression.ts index c97c28b27..09c7f3da9 100644 --- a/src/render/expression.ts +++ b/src/render/expression.ts @@ -19,7 +19,7 @@ export class Expression { private postfix: Token[] private lenient: boolean - public constructor (str: string, lenient: boolean = false) { + public constructor (str: string, lenient = false) { const tokenizer = new Tokenizer(str) this.postfix = [...toPostfix(tokenizer.readExpression())] this.lenient = lenient @@ -32,7 +32,7 @@ export class Expression { const result = evalOperatorToken(token, l, r, ctx) this.operands.push(result) } 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] @@ -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') if (TypeGuards.isPropertyAccessToken(token)) { const variable = token.getVariableAsText() @@ -53,7 +53,7 @@ export function evalToken (token: Token | undefined, ctx: Context, lenient: bool if (lenient && e instanceof InternalUndefinedVariableError) { return null } else { - throw(new UndefinedVariableError(e, token)) + throw (new UndefinedVariableError(e, token)) } } } diff --git a/src/render/operator.ts b/src/render/operator.ts index 1863cc1ca..258185416 100644 --- a/src/render/operator.ts +++ b/src/render/operator.ts @@ -3,7 +3,6 @@ import { Context } from '../context/context' import { isFunction } from '../util/underscore' import { isTruthy } from '../render/boolean' - export const operatorImpls: {[key: string]: (lhs: any, rhs: any, ctx: Context) => boolean} = { '==': (l: any, r: any) => { if (isComparable(l)) return l.equals(r) diff --git a/test/integration/builtin/tags/tablerow.ts b/test/integration/builtin/tags/tablerow.ts index a14830784..71a6d1bc5 100644 --- a/test/integration/builtin/tags/tablerow.ts +++ b/test/integration/builtin/tags/tablerow.ts @@ -17,7 +17,7 @@ describe('tags/tablerow', function () { it('should support promises', async function () { const src = '{% tablerow i in promiseNumbers %}{{ i }}{% endtablerow %}' const ctx = { - promiseNumbers: Promise.resolve([1,2,3]) + promiseNumbers: Promise.resolve([1, 2, 3]) } const dst = '123' const html = await liquid.parseAndRender(src, ctx) diff --git a/test/integration/liquid/strict.ts b/test/integration/liquid/strict.ts index b8ff24a9e..1fca49f85 100644 --- a/test/integration/liquid/strict.ts +++ b/test/integration/liquid/strict.ts @@ -30,7 +30,7 @@ describe('LiquidOptions#strict*', function () { return expect(engine.parseAndRender(html, ctx, opts)).to .be.rejectedWith(/undefined variable: notdefined/) }) - describe('with strictVariables and lenientIf', function() { + describe('with strictVariables and lenientIf', function () { const strictLenientOpts = { strictVariables: true, lenientIf: true @@ -42,7 +42,7 @@ describe('LiquidOptions#strict*', function () { }) it('should support elsif with undefined variables', async function () { const tpl = engine.parse('{% if notdefined1 %}a{% elsif notdefined2 %}b{% elsif defined3 %}{{defined3}}{% else %}d{% endif %}') - const html = await engine.render(tpl, {'defined3': 'bla'}, strictLenientOpts) + const html = await engine.render(tpl, { 'defined3': 'bla' }, strictLenientOpts) return expect(html).to.equal('bla') }) it('should not throw in `unless` with a single variable', async function () {