diff --git a/rollup.config.js b/rollup.config.js index 5148bcffa..6dba30c16 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,11 +1,11 @@ import shim from 'rollup-plugin-shim' import alias from 'rollup-plugin-alias' import babel from 'rollup-plugin-babel' -import {uglify} from 'rollup-plugin-uglify' +import { uglify } from 'rollup-plugin-uglify' import pkg from './package.json' import nodeResolve from 'rollup-plugin-node-resolve' -const fake = {fs: `export default {}`, path: `export default {}`} +const fake = { fs: `export default {}`, path: `export default {}` } const version = process.env.VERSION || pkg.version const sourcemap = true const banner = `/* @@ -20,7 +20,7 @@ const input = 'src/index.js' const babelConf = { babelrc: false, - 'presets': [['env', {'modules': false}]], + 'presets': [['env', { 'modules': false }]], 'plugins': ['external-helpers'] } diff --git a/src/filter.js b/src/filter.js index 72d576b24..c6b45f078 100644 --- a/src/filter.js +++ b/src/filter.js @@ -1,7 +1,7 @@ import * as lexical from './lexical.js' -import {evalValue} from './syntax.js' +import { evalValue } from './syntax.js' import assert from './util/assert.js' -import {assign, create} from './util/underscore.js' +import { assign, create } from './util/underscore.js' const valueRE = new RegExp(`${lexical.value.source}`, 'g') diff --git a/src/filters.js b/src/filters.js index 29c7fb7d0..a5fadafca 100644 --- a/src/filters.js +++ b/src/filters.js @@ -1,6 +1,6 @@ import strftime from './util/strftime.js' import * as _ from './util/underscore.js' -import {isTruthy} from './syntax.js' +import { isTruthy } from './syntax.js' const escapeMap = { '&': '&', diff --git a/src/index.js b/src/index.js index 2125e60a4..f253c4f8a 100644 --- a/src/index.js +++ b/src/index.js @@ -8,8 +8,8 @@ import Render from './render.js' import Tag from './tag.js' import Filter from './filter.js' import Parser from './parser' -import {isTruthy, isFalsy, evalExp, evalValue} from './syntax.js' -import {ParseError, TokenizationError, RenderBreakError, AssertionError} from './util/error.js' +import { isTruthy, isFalsy, evalExp, evalValue } from './syntax.js' +import { ParseError, TokenizationError, RenderBreakError, AssertionError } from './util/error.js' import tags from './tags/index.js' import filters from './filters.js' diff --git a/src/parser.js b/src/parser.js index ea8dc8df3..4fa32cbd6 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,6 +1,6 @@ import * as lexical from './lexical.js' -import {create} from './util/underscore.js' -import {ParseError} from './util/error.js' +import { create } from './util/underscore.js' +import { ParseError } from './util/error.js' import assert from './util/assert.js' export default function (Tag, Filter) { diff --git a/src/render.js b/src/render.js index e741a558b..06d1cbf2e 100644 --- a/src/render.js +++ b/src/render.js @@ -1,6 +1,6 @@ -import {evalExp} from './syntax.js' -import {RenderBreakError, RenderError} from './util/error.js' -import {stringify, create} from './util/underscore.js' +import { evalExp } from './syntax.js' +import { RenderBreakError, RenderError } from './util/error.js' +import { stringify, create } from './util/underscore.js' import assert from './util/assert.js' const render = { diff --git a/src/tag.js b/src/tag.js index 5970a3676..c0d52fe41 100644 --- a/src/tag.js +++ b/src/tag.js @@ -1,6 +1,6 @@ -import {hashCapture} from './lexical.js' -import {create} from './util/underscore.js' -import {evalValue} from './syntax.js' +import { hashCapture } from './lexical.js' +import { create } from './util/underscore.js' +import { evalValue } from './syntax.js' import assert from './util/assert.js' function hash (markup, scope) { diff --git a/src/tags/assign.js b/src/tags/assign.js index e9997846b..cfd5a9c3a 100644 --- a/src/tags/assign.js +++ b/src/tags/assign.js @@ -1,10 +1,10 @@ import assert from '../util/assert.js' -import {identifier} from '../lexical.js' -import {create} from '../util/underscore.js' +import { identifier } from '../lexical.js' +import { create } from '../util/underscore.js' export default function (liquid, Liquid) { const re = new RegExp(`(${identifier.source})\\s*=([^]*)`) - const {AssignScope} = Liquid.Types + const { AssignScope } = Liquid.Types liquid.registerTag('assign', { parse: function (token) { diff --git a/src/tags/capture.js b/src/tags/capture.js index 1f2667e0b..b2e83f9c2 100644 --- a/src/tags/capture.js +++ b/src/tags/capture.js @@ -1,10 +1,10 @@ import assert from '../util/assert.js' -import {create} from '../util/underscore.js' -import {identifier} from '../lexical.js' +import { create } from '../util/underscore.js' +import { identifier } from '../lexical.js' export default function (liquid, Liquid) { const re = new RegExp(`(${identifier.source})`) - const {CaptureScope} = Liquid.Types + const { CaptureScope } = Liquid.Types liquid.registerTag('capture', { parse: function (tagToken, remainTokens) { diff --git a/src/tags/cycle.js b/src/tags/cycle.js index 67e9b9fc4..344ddd203 100644 --- a/src/tags/cycle.js +++ b/src/tags/cycle.js @@ -1,5 +1,5 @@ import assert from '../util/assert.js' -import {value as rValue} from '../lexical.js' +import { value as rValue } from '../lexical.js' export default function (liquid, Liquid) { const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`) diff --git a/src/tags/decrement.js b/src/tags/decrement.js index 4bcfaba47..71a3edcf6 100644 --- a/src/tags/decrement.js +++ b/src/tags/decrement.js @@ -1,9 +1,9 @@ -import {create} from '../util/underscore.js' +import { create } from '../util/underscore.js' import assert from '../util/assert.js' -import {identifier} from '../lexical.js' +import { identifier } from '../lexical.js' export default function (liquid, Liquid) { - const {CaptureScope, AssignScope, DecrementScope} = Liquid.Types + const { CaptureScope, AssignScope, DecrementScope } = Liquid.Types liquid.registerTag('decrement', { parse: function (token) { diff --git a/src/tags/for.js b/src/tags/for.js index e6ce2aaef..bcaa79d60 100644 --- a/src/tags/for.js +++ b/src/tags/for.js @@ -1,7 +1,7 @@ -import {mapSeries} from '../util/promise.js' -import {isString, isObject, isArray} from '../util/underscore.js' +import { mapSeries } from '../util/promise.js' +import { isString, isObject, isArray } from '../util/underscore.js' import assert from '../util/assert.js' -import {identifier, value, hash} from '../lexical.js' +import { identifier, value, hash } from '../lexical.js' export default function (liquid, Liquid) { const RenderBreakError = Liquid.Types.RenderBreakError @@ -11,7 +11,7 @@ export default function (liquid, Liquid) { `(?:\\s+(reversed))?` + `(?:\\s+${hash.source})*$`) - liquid.registerTag('for', {parse, render}) + liquid.registerTag('for', { parse, render }) function parse (tagToken, remainTokens) { const match = re.exec(tagToken.args) diff --git a/src/tags/include.js b/src/tags/include.js index 0cecf179d..0c456f3c6 100644 --- a/src/tags/include.js +++ b/src/tags/include.js @@ -1,5 +1,5 @@ import assert from '../util/assert.js' -import {value, quotedLine} from '../lexical.js' +import { value, quotedLine } from '../lexical.js' const staticFileRE = /[^\s,]+/ diff --git a/src/tags/increment.js b/src/tags/increment.js index 85cd9c3bb..526b99653 100644 --- a/src/tags/increment.js +++ b/src/tags/increment.js @@ -1,9 +1,9 @@ import assert from '../util/assert.js' -import {create} from '../util/underscore.js' -import {identifier} from '../lexical.js' +import { create } from '../util/underscore.js' +import { identifier } from '../lexical.js' export default function (liquid, Liquid) { - const {CaptureScope, AssignScope, IncrementScope} = Liquid.Types + const { CaptureScope, AssignScope, IncrementScope } = Liquid.Types liquid.registerTag('increment', { parse: function (token) { diff --git a/src/tags/layout.js b/src/tags/layout.js index bc375ed1f..c157ea332 100644 --- a/src/tags/layout.js +++ b/src/tags/layout.js @@ -1,5 +1,5 @@ import assert from '../util/assert.js' -import {value as rValue} from '../lexical.js' +import { value as rValue } from '../lexical.js' /* * blockMode: diff --git a/src/tags/tablerow.js b/src/tags/tablerow.js index 60f3dfedc..1f3d1adbf 100644 --- a/src/tags/tablerow.js +++ b/src/tags/tablerow.js @@ -1,6 +1,6 @@ -import {mapSeries} from '../util/promise.js' +import { mapSeries } from '../util/promise.js' import assert from '../util/assert.js' -import {identifier, value, hash} from '../lexical.js' +import { identifier, value, hash } from '../lexical.js' export default function (liquid, Liquid) { const re = new RegExp(`^(${identifier.source})\\s+in\\s+` + diff --git a/src/template-browser.js b/src/template-browser.js index 7002dba53..771943473 100644 --- a/src/template-browser.js +++ b/src/template-browser.js @@ -1,4 +1,4 @@ -import {last, isArray} from './util/underscore' +import { last, isArray } from './util/underscore' function domResolve (root, path) { const base = document.createElement('base') diff --git a/src/template.js b/src/template.js index 81da8c68c..bacb4f43e 100644 --- a/src/template.js +++ b/src/template.js @@ -1,6 +1,6 @@ import * as _ from './util/underscore.js' import path from 'path' -import {anySeries} from './util/promise.js' +import { anySeries } from './util/promise.js' import fs from 'fs' const statFileAsync = _.promisify(fs.stat) diff --git a/src/tokenizer.js b/src/tokenizer.js index f31cb9fdd..5e3d84b88 100644 --- a/src/tokenizer.js +++ b/src/tokenizer.js @@ -1,10 +1,10 @@ import * as lexical from './lexical.js' -import {TokenizationError} from './util/error.js' +import { TokenizationError } from './util/error.js' import * as _ from './util/underscore.js' import assert from './util/assert.js' import whiteSpaceCtrl from './whitespace-ctrl.js' -export {default as whiteSpaceCtrl} from './whitespace-ctrl.js' +export { default as whiteSpaceCtrl } from './whitespace-ctrl.js' export function parse (input, file, options) { assert(_.isString(input), 'illegal input') diff --git a/src/util/assert.js b/src/util/assert.js index 33a0bfb09..45df079e5 100644 --- a/src/util/assert.js +++ b/src/util/assert.js @@ -1,4 +1,4 @@ -import {AssertionError} from './error.js' +import { AssertionError } from './error.js' export default function (predicate, message) { if (!predicate) { diff --git a/src/util/error.js b/src/util/error.js index a036011a5..01b0cb747 100644 --- a/src/util/error.js +++ b/src/util/error.js @@ -22,7 +22,7 @@ function initLiquidError (err, token) { } export function TokenizationError (message, token) { - initLiquidError.call(this, {message: message}, token) + initLiquidError.call(this, { message: message }, token) } TokenizationError.prototype = _.create(Error.prototype) TokenizationError.prototype.constructor = TokenizationError diff --git a/src/whitespace-ctrl.js b/src/whitespace-ctrl.js index c8f367765..949f6543d 100644 --- a/src/whitespace-ctrl.js +++ b/src/whitespace-ctrl.js @@ -1,4 +1,4 @@ -import {assign} from './util/underscore.js' +import { assign } from './util/underscore.js' export default function whiteSpaceCtrl (tokens, options) { options = assign({ greedy: true }, options) diff --git a/test/e2e/parse-and-render.js b/test/e2e/parse-and-render.js index 069c530b0..ad9c89573 100644 --- a/test/e2e/parse-and-render.js +++ b/test/e2e/parse-and-render.js @@ -13,7 +13,7 @@ describe('.parseAndRender()', function () { }) }) it('should value object', function () { - var ctx = { obj: {foo: 'bar'} } + var ctx = { obj: { foo: 'bar' } } return expect(engine.parseAndRender('{{obj}}', ctx)).to.eventually.equal('{"foo":"bar"}') }) it('should value array', function () { @@ -39,7 +39,7 @@ describe('.parseAndRender()', function () { }).to.not.throw() }) it('should render template multiple times', function () { - var ctx = {obj: {foo: 'bar'}} + var ctx = { obj: { foo: 'bar' } } var template = engine.parse('{{obj}}') return engine.render(template, ctx) .then(result => expect(result).to.equal('{"foo":"bar"}')) @@ -47,7 +47,7 @@ describe('.parseAndRender()', function () { .then((result) => expect(result).to.equal('{"foo":"bar"}')) }) it('should render filters', function () { - var ctx = {names: ['alice', 'bob']} + var ctx = { names: ['alice', 'bob'] } var template = engine.parse('
{{names | join: ","}}
') return expect(engine.render(template, ctx)).to.eventually.equal('alice,bob
') }) diff --git a/test/e2e/render-file.js b/test/e2e/render-file.js index b9903500d..0843fdcfd 100644 --- a/test/e2e/render-file.js +++ b/test/e2e/render-file.js @@ -29,7 +29,7 @@ describe('#renderFile()', function () { .to.eventually.equal('foo') }) it('should find files without extname', function () { - var engine = Liquid({root: '/root'}) + var engine = Liquid({ root: '/root' }) return expect(engine.renderFile('/root/files/bar', {})) .to.eventually.equal('bar') }) @@ -57,11 +57,11 @@ describe('#renderFile()', function () { .to.eventually.equal('FOO') }) it('should render file with context', function () { - return expect(engine.renderFile('/root/files/name.html', {name: 'harttle'})) + return expect(engine.renderFile('/root/files/name.html', { name: 'harttle' })) .to.eventually.equal('My name is harttle.') }) it('should use default extname', function () { - return expect(engine.renderFile('files/name', {name: 'harttle'})).to.eventually.equal('My name is harttle.') + return expect(engine.renderFile('files/name', { name: 'harttle' })).to.eventually.equal('My name is harttle.') }) it('should throw with lookup list when file not exist', function () { engine = Liquid({ diff --git a/test/e2e/xhr.js b/test/e2e/xhr.js index 6c5ebd647..37754f081 100644 --- a/test/e2e/xhr.js +++ b/test/e2e/xhr.js @@ -15,7 +15,7 @@ describe('xhr', () => { server = sinon.createFakeServer() server.autoRespond = true server.respondWith('GET', 'https://example.com/views/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) var dom = new JSDOM('', { url: 'https://example.com/foo/bar.html', contentType: 'text/html', @@ -35,29 +35,29 @@ describe('xhr', () => { }) describe('#renderFile()', () => { it('should support without extname', () => { - return expect(engine.renderFile('hello', {name: 'alice1'})) + return expect(engine.renderFile('hello', { name: 'alice1' })) .to.eventually.equal('hello alice1') }) it('should support with extname', () => { - return expect(engine.renderFile('hello.html', {name: 'alice2'})) + return expect(engine.renderFile('hello.html', { name: 'alice2' })) .to.eventually.equal('hello alice2') }) it('should support with absolute path', () => { server.respondWith('GET', 'https://example.com/foo.html', - [200, {'Content-Type': 'text/plain'}, 'foo']) + [200, { 'Content-Type': 'text/plain' }, 'foo']) return expect(engine.renderFile('/foo.html')) .to.eventually.equal('foo') }) it('should support with url', () => { - return expect(engine.renderFile('https://example.com/views/hello.html', {name: 'alice4'})) + return expect(engine.renderFile('https://example.com/views/hello.html', { name: 'alice4' })) .to.eventually.equal('hello alice4') }) it('should support include', () => { server.respondWith('GET', 'https://example.com/views/hello.html', - [200, {'Content-Type': 'text/plain'}, "hello {% include 'name.html' %}"]) + [200, { 'Content-Type': 'text/plain' }, "hello {% include 'name.html' %}"]) server.respondWith('GET', 'https://example.com/views/name.html', - [200, {'Content-Type': 'text/plain'}, '{{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, '{{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) it('should throw 404', () => { @@ -82,8 +82,8 @@ describe('xhr', () => { extname: '.html' }) server.respondWith('GET', 'https://example.com/foo/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) it('should support empty root', () => { @@ -92,8 +92,8 @@ describe('xhr', () => { extname: '.html' }) server.respondWith('https://example.com/foo/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) it('should support with relative path', () => { @@ -102,8 +102,8 @@ describe('xhr', () => { extname: '.html' }) server.respondWith('GET', 'https://example.com/foo/views/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) it('should support with absolute path', () => { @@ -112,8 +112,8 @@ describe('xhr', () => { extname: '.html' }) server.respondWith('GET', 'https://example.com/views/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) it('should support with url', () => { @@ -122,20 +122,20 @@ describe('xhr', () => { extname: '.html' }) server.respondWith('GET', 'https://foo.com/bar/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) - return expect(engine.renderFile('hello.html', {name: 'alice5'})) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) + return expect(engine.renderFile('hello.html', { name: 'alice5' })) .to.eventually.equal('hello alice5') }) }) describe('cache options', () => { it('should be disabled by default', () => { server.respondWith('GET', 'https://example.com/views/foo.html', - [200, {'Content-Type': 'text/plain'}, 'foo1']) + [200, { 'Content-Type': 'text/plain' }, 'foo1']) return engine.renderFile('foo.html') .then((html) => { expect(html).to.equal('foo1') server.respondWith('GET', 'https://example.com/views/foo.html', - [200, {'Content-Type': 'text/plain'}, 'foo2']) + [200, { 'Content-Type': 'text/plain' }, 'foo2']) return engine.renderFile('foo.html') }) .then(html => expect(html).to.equal('foo2')) @@ -147,12 +147,12 @@ describe('xhr', () => { cache: true }) server.respondWith('GET', 'https://example.com/views/foo.html', - [200, {'Content-Type': 'text/plain'}, 'foo1']) + [200, { 'Content-Type': 'text/plain' }, 'foo1']) return engine.renderFile('foo.html') .then((html) => { expect(html).to.equal('foo1') server.respondWith('GET', 'https://example.com/views/foo.html', - [200, {'Content-Type': 'text/plain'}, 'foo2']) + [200, { 'Content-Type': 'text/plain' }, 'foo2']) return engine.renderFile('foo.html') }) .then(html => expect(html).to.equal('foo1')) diff --git a/test/unit/filter.js b/test/unit/filter.js index 3a5110282..ebba521b5 100644 --- a/test/unit/filter.js +++ b/test/unit/filter.js @@ -2,7 +2,7 @@ import chai from 'chai' import sinon from 'sinon' import sinonChai from 'sinon-chai' import Filter from '../../src/filter.js' -import {factory as scopeFactory} from '../../src/scope.js' +import { factory as scopeFactory } from '../../src/scope.js' chai.use(sinonChai) const expect = chai.expect diff --git a/test/unit/index.js b/test/unit/index.js index cb8844ee7..7c9efe674 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -31,7 +31,7 @@ describe('Liquid', function () { }) }) describe('#express()', function () { - const liquid = new Liquid({root: '/root'}) + const liquid = new Liquid({ root: '/root' }) const render = liquid.express() before(function () { mock({ @@ -42,14 +42,14 @@ describe('Liquid', function () { mock.restore() }) it('should render single template', function (done) { - render.call({root: '.'}, 'foo', null, (err, result) => { + render.call({ root: '.' }, 'foo', null, (err, result) => { if (err) return done(err) expect(result).to.equal('foo') done() }) }) it('should render single template with Array-typed root', function (done) { - render.call({root: ['.']}, 'foo', null, (err, result) => { + render.call({ root: ['.'] }, 'foo', null, (err, result) => { if (err) return done(err) expect(result).to.equal('foo') done() diff --git a/test/unit/options/trimming.js b/test/unit/options/trimming.js index 2d8c148f1..c567280fc 100644 --- a/test/unit/options/trimming.js +++ b/test/unit/options/trimming.js @@ -6,7 +6,7 @@ const expect = chai.expect chai.use(chaiAsPromised) describe('trimming', function () { - const ctx = {name: 'harttle'} + const ctx = { name: 'harttle' } describe('tag trimming', function () { it('should respect trim_tag_left', function () { @@ -50,7 +50,7 @@ describe('trimming', function () { .to.eventually.equal('aharttle') }) it('should respect to greedy:false by default', function () { - const engine = Liquid({greedy: false}) + const engine = Liquid({ greedy: false }) return expect(engine.parseAndRender(src, ctx)) .to.eventually.equal('\n a \nharttle ') }) diff --git a/test/unit/render.js b/test/unit/render.js index af5a712c6..5b50b5094 100644 --- a/test/unit/render.js +++ b/test/unit/render.js @@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised' import sinonChai from 'sinon-chai' import sinon from 'sinon' import Tag from '../../src/tag.js' -import {factory as scopeFactory} from '../../src/scope.js' +import { factory as scopeFactory } from '../../src/scope.js' import Filter from '../../src/filter' import Render from '../../src/render.js' import parser from '../../src/parser.js' @@ -31,7 +31,7 @@ describe('render', function () { it('should render html', function () { const scope = scopeFactory({}) - return expect(render.renderTemplates([{type: 'html', value: ''}], scope)).to.eventually.equal('
') + return expect(render.renderTemplates([{ type: 'html', value: '
' }], scope)).to.eventually.equal('
') }) }) @@ -59,7 +59,7 @@ describe('render', function () { return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"num":2,"circular":{"bar":"bar"}}') }) it('should skip function property', function () { - const scope = scopeFactory({obj: {foo: 'foo', bar: x => x}}) + const scope = scopeFactory({ obj: { foo: 'foo', bar: x => x } }) const tpl = Template.parseValue('obj') return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"foo":"foo"}') }) @@ -92,7 +92,7 @@ describe('render', function () { filter.register('time', time) const tpl = Template.parseValue('foo.bar | date: "b" | time:2') const scope = scopeFactory({ - foo: {bar: 'bar'} + foo: { bar: 'bar' } }) render.evalValue(tpl, scope) expect(date).to.have.been.calledWith('bar', 'b') diff --git a/test/unit/scope.js b/test/unit/scope.js index dc9d2798e..b41b269f2 100644 --- a/test/unit/scope.js +++ b/test/unit/scope.js @@ -1,5 +1,5 @@ import chai from 'chai' -import {factory as scopeFactory} from '../../src/scope.js' +import { factory as scopeFactory } from '../../src/scope.js' const expect = chai.expect @@ -97,18 +97,18 @@ describe('scope', function () { }) it('should respect to to_liquid', function () { - const scope = scopeFactory({foo: { - to_liquid: () => ({bar: 'BAR'}), + const scope = scopeFactory({ foo: { + to_liquid: () => ({ bar: 'BAR' }), bar: 'bar' - }}) + } }) expect(scope.get('foo.bar')).to.equal('BAR') }) it('should respect to toLiquid', function () { - const scope = scopeFactory({foo: { - toLiquid: () => ({bar: 'BAR'}), + const scope = scopeFactory({ foo: { + toLiquid: () => ({ bar: 'BAR' }), bar: 'bar' - }}) + } }) expect(scope.get('foo.bar')).to.equal('BAR') }) @@ -152,12 +152,12 @@ describe('scope', function () { expect(scope.get('a.b.c.d')).to.equal('COO') }) it('should keep other properties of parent', function () { - scope.push({obj: {foo: 'FOO'}}) + scope.push({ obj: { foo: 'FOO' } }) scope.set('obj.bar', 'BAR') expect(scope.get('obj.foo')).to.equal('FOO') }) it('should abort if property cannot be set', function () { - scope.push({obj: {foo: 'FOO'}}) + scope.push({ obj: { foo: 'FOO' } }) scope.set('obj.foo.bar', 'BAR') expect(scope.get('obj.foo')).to.equal('FOO') }) @@ -220,8 +220,8 @@ describe('scope', function () { expect(scope.get('bar')).to.equal('bar') }) it('should hide deep properties by push', function () { - scope.set('bar', {bar: 'bar'}) - scope.push({bar: {foo: 'foo'}}) + scope.set('bar', { bar: 'bar' }) + scope.push({ bar: { foo: 'foo' } }) expect(scope.get('bar.foo')).to.equal('foo') expect(scope.get('bar.bar')).to.equal(undefined) }) diff --git a/test/unit/tag.js b/test/unit/tag.js index aa26899f1..91fba7e05 100644 --- a/test/unit/tag.js +++ b/test/unit/tag.js @@ -1,6 +1,6 @@ import chai from 'chai' import Tag from '../../src/tag.js' -import {factory as scopeFactory} from '../../src/scope.js' +import { factory as scopeFactory } from '../../src/scope.js' import sinon from 'sinon' import sinonChai from 'sinon-chai' diff --git a/test/unit/tags/assign.js b/test/unit/tags/assign.js index 2b4db5ce5..a8d070bda 100644 --- a/test/unit/tags/assign.js +++ b/test/unit/tags/assign.js @@ -23,7 +23,7 @@ describe('tags/assign', function () { .to.eventually.equal('10086') }) it('should shading rather than overwriting', function () { - const ctx = {foo: 'foo'} + const ctx = { foo: 'foo' } const src = '{% assign foo="FOO" %}{{foo}}' return liquid.parseAndRender(src, ctx) .then(x => { diff --git a/test/unit/tags/capture.js b/test/unit/tags/capture.js index 256fa2e83..a5c8d3c32 100644 --- a/test/unit/tags/capture.js +++ b/test/unit/tags/capture.js @@ -15,7 +15,7 @@ describe('tags/capture', function () { it('should shading rather than overwriting', function () { const src = '{% capture var %}10{% endcapture %}{{var}}' - const ctx = {'var': 20} + const ctx = { 'var': 20 } return liquid.parseAndRender(src, ctx) .then(x => { expect(x).to.equal('10') diff --git a/test/unit/tags/decrement.js b/test/unit/tags/decrement.js index 1925df827..eb1abff7e 100644 --- a/test/unit/tags/decrement.js +++ b/test/unit/tags/decrement.js @@ -20,7 +20,7 @@ describe('tags/decrement', function () { it('should decrement defined variable', function () { const src = '{% decrement var %}{% decrement var %}{% decrement var %}' - const ctx = {'var': 10} + const ctx = { 'var': 10 } return liquid.parseAndRender(src, ctx) .then(x => { expect(x).to.equal('987') diff --git a/test/unit/tags/for.js b/test/unit/tags/for.js index d117156f9..a5f3c3db9 100644 --- a/test/unit/tags/for.js +++ b/test/unit/tags/for.js @@ -17,7 +17,7 @@ describe('tags/for', function () { strObj: new String(''), emptyObj: {}, nullProtoObj: Object.create(null), - obj: {foo: 'bar', coo: 'haa'}, + obj: { foo: 'bar', coo: 'haa' }, alpha: ['a', 'b', 'c'], emptyArray: [] } @@ -37,12 +37,12 @@ describe('tags/for', function () { describe('scope', function () { it('should read super scope', function () { const src = '{%for a in (1..2)%}{{num}}{%endfor%}' - return expect(liquid.parseAndRender(src, {num: 1})) + return expect(liquid.parseAndRender(src, { num: 1 })) .to.eventually.equal('11') }) it('should write super scope', function () { const src = '{%for a in (1..2)%}{{num}}{%assign num = 2%}{%endfor%}' - return expect(liquid.parseAndRender(src, {num: 1})) + return expect(liquid.parseAndRender(src, { num: 1 })) .to.eventually.equal('12') }) }) diff --git a/test/unit/tags/include.js b/test/unit/tags/include.js index 8bf30f918..2abbdb3be 100644 --- a/test/unit/tags/include.js +++ b/test/unit/tags/include.js @@ -29,7 +29,7 @@ describe('tags/include', function () { '/current.html': 'bar{% include "bar/{{name}}" %}bar', '/bar/foo.html': 'foo' }) - return expect(liquid.renderFile('/current.html', {name: 'foo.html'})).to + return expect(liquid.renderFile('/current.html', { name: 'foo.html' })).to .eventually.equal('barfoobar') }) @@ -114,7 +114,7 @@ describe('tags/include', function () { '/parent.html': 'X{% include child.html color:"red" %}Y', '/child.html': 'child with {{color}}' }) - const staticLiquid = new Liquid({dynamicPartials: false, root: '/'}) + const staticLiquid = new Liquid({ dynamicPartials: false, root: '/' }) return expect(staticLiquid.renderFile('parent.html')).to .eventually.equal('Xchild with redY') }) @@ -124,7 +124,7 @@ describe('tags/include', function () { '/parent.html': 'X{% include bar/./../foo/child.html %}Y', '/foo/child.html': 'child' }) - const staticLiquid = new Liquid({dynamicPartials: false, root: '/'}) + const staticLiquid = new Liquid({ dynamicPartials: false, root: '/' }) return expect(staticLiquid.renderFile('parent.html')).to .eventually.equal('XchildY') }) @@ -134,7 +134,7 @@ describe('tags/include', function () { '/parent.html': 'X{% include foo/child.html %}Y', '/foo/child.html': 'child' }) - const staticLiquid = new Liquid({dynamicPartials: false, root: '/'}) + const staticLiquid = new Liquid({ dynamicPartials: false, root: '/' }) return expect(staticLiquid.renderFile('parent.html')).to .eventually.equal('XchildY') }) @@ -144,7 +144,7 @@ describe('tags/include', function () { '/parent.html': 'X{% include child.html, color:"red" %}Y', '/child.html': 'child with {{color}}' }) - const staticLiquid = new Liquid({dynamicPartials: false, root: '/'}) + const staticLiquid = new Liquid({ dynamicPartials: false, root: '/' }) return expect(staticLiquid.renderFile('parent.html')).to .eventually.equal('Xchild with redY') }) diff --git a/test/unit/tags/increment.js b/test/unit/tags/increment.js index 6aa661315..156c62f7c 100644 --- a/test/unit/tags/increment.js +++ b/test/unit/tags/increment.js @@ -15,7 +15,7 @@ describe('tags/increment', function () { it('should increment defined variable', function () { const src = '{% increment one %}{% increment one %}{% increment one %}' - const ctx = {one: 7} + const ctx = { one: 7 } return liquid.parseAndRender(src, ctx) .then(x => { expect(x).to.equal('789') diff --git a/test/unit/template-browser.js b/test/unit/template-browser.js index 08e34a270..436f8e102 100644 --- a/test/unit/template-browser.js +++ b/test/unit/template-browser.js @@ -1,4 +1,4 @@ -import {resolve} from '../../src/template-browser.js' +import { resolve } from '../../src/template-browser.js' import chai from 'chai' const expect = chai.expect diff --git a/test/unit/template.js b/test/unit/template.js index 0d1a8f6f0..d7228c042 100644 --- a/test/unit/template.js +++ b/test/unit/template.js @@ -1,4 +1,4 @@ -import {resolve} from '../../src/template.js' +import { resolve } from '../../src/template.js' import mock from 'mock-fs' import chai from 'chai' import path from 'path' @@ -15,12 +15,12 @@ describe('template', function () { }) describe('#resolve()', function () { it('should resolve based on root', function () { - const filepath = resolve('bar.html', '/foo', {root: []}) + const filepath = resolve('bar.html', '/foo', { root: [] }) const expected = path.resolve('/foo/bar.html') return expect(filepath).to.eventually.equal(expected) }) it('should resolve based on root', function () { - return expect(resolve('foo.html', '/foo', {root: []})) + return expect(resolve('foo.html', '/foo', { root: [] })) .to.rejectedWith(/Failed to lookup foo.html in: \/foo/) }) }) diff --git a/test/unit/util/underscore.js b/test/unit/util/underscore.js index a9203a499..c4165c9b2 100644 --- a/test/unit/util/underscore.js +++ b/test/unit/util/underscore.js @@ -1,7 +1,7 @@ import chai from 'chai' import sinonChai from 'sinon-chai' import sinon from 'sinon' -import {RenderError, RenderBreakError} from '../../../src/util/error.js' +import { RenderError, RenderBreakError } from '../../../src/util/error.js' import * as _ from '../../../src/util/underscore.js' const expect = chai.expect @@ -37,13 +37,13 @@ describe('util/underscore', function () { }) describe('.stringify()', function () { it('should respect to to_liquid() method', function () { - expect(_.stringify({to_liquid: () => 'foo'})).to.equal('foo') + expect(_.stringify({ to_liquid: () => 'foo' })).to.equal('foo') }) it('should respect to toLiquid() method', function () { - expect(_.stringify({toLiquid: () => 'foo'})).to.equal('foo') + expect(_.stringify({ toLiquid: () => 'foo' })).to.equal('foo') }) it('should recursively call toLiquid()', function () { - expect(_.stringify({toLiquid: () => ({toLiquid: () => 'foo'})})).to.equal('foo') + expect(_.stringify({ toLiquid: () => ({ toLiquid: () => 'foo' }) })).to.equal('foo') }) it('should return "null" for null', function () { expect(_.stringify(null)).to.equal('null') diff --git a/test/unit/xhr.js b/test/unit/xhr.js index e41971f08..8e637c2f2 100644 --- a/test/unit/xhr.js +++ b/test/unit/xhr.js @@ -1,4 +1,4 @@ -import {read} from '../../src/template-browser.js' +import { read } from '../../src/template-browser.js' import sinon from 'sinon' import chai from 'chai' @@ -16,7 +16,7 @@ describe('template-browser', () => { server = sinon.createFakeServer() server.autoRespond = true server.respondWith('GET', 'https://example.com/views/hello.html', - [200, {'Content-Type': 'text/plain'}, 'hello {{name}}']) + [200, { 'Content-Type': 'text/plain' }, 'hello {{name}}']) global.XMLHttpRequest = sinon.useFakeXMLHttpRequest() }) afterEach(() => {