chore: fix linting

This commit is contained in:
harttle
2019-02-23 03:50:45 +08:00
parent 56c7992b76
commit 3cf01603e8
35 changed files with 107 additions and 110 deletions
+1
View File
@@ -17,6 +17,7 @@
"no-var": 2, "no-var": 2,
"prefer-const": 2, "prefer-const": 2,
"no-unused-vars": "off", "no-unused-vars": "off",
"import/export": "off",
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }] "@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
} }
} }
+2 -2
View File
@@ -6,7 +6,7 @@
"types": "dist/liquid.d.ts", "types": "dist/liquid.d.ts",
"browser": "dist/liquid.js", "browser": "dist/liquid.js",
"scripts": { "scripts": {
"lint": "eslint . --ext .ts --ext .js", "lint": "eslint . --ext .ts",
"unit": "mocha 'test/unit/**/*.ts'", "unit": "mocha 'test/unit/**/*.ts'",
"e2e": "npm run build && mocha 'test/e2e/**/*.ts'", "e2e": "npm run build && mocha 'test/e2e/**/*.ts'",
"test": "npm run unit && npm run e2e", "test": "npm run unit && npm run e2e",
@@ -62,7 +62,7 @@
"eslint": "^5.12.1", "eslint": "^5.12.1",
"eslint-config-standard": "^12.0.0", "eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.15.0", "eslint-plugin-import": "^2.15.0",
"eslint-plugin-mocha": "^5.2.1", "eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-node": "^8.0.1", "eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1", "eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0", "eslint-plugin-standard": "^4.0.0",
+1 -1
View File
@@ -1,4 +1,4 @@
import FilterImpl from "src/template/filter/filter-impl"; import { FilterImpl } from 'src/template/filter/filter-impl'
export default { export default {
'append': (v: string, arg: string) => v + arg, 'append': (v: string, arg: string) => v + arg,
+3 -3
View File
@@ -1,9 +1,9 @@
import assert from 'src/util/assert' import assert from 'src/util/assert'
import { identifier } from 'src/parser/lexical' import { identifier } from 'src/parser/lexical'
import { AssignScope } from 'src/scope/scopes' import { AssignScope } from 'src/scope/scopes'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`) const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
+5 -5
View File
@@ -1,10 +1,10 @@
import BlockMode from 'src/scope/block-mode' import BlockMode from 'src/scope/block-mode'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import ITemplate from 'src/template/itemplate' import ITemplate from 'src/template/itemplate'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ParseStream from 'src/parser/parse-stream'; import ParseStream from 'src/parser/parse-stream'
export default { export default {
parse: function (token: TagToken, remainTokens: Token[]) { parse: function (token: TagToken, remainTokens: Token[]) {
+1 -1
View File
@@ -4,7 +4,7 @@ import { CaptureScope } from 'src/scope/scopes'
import TagToken from 'src/parser/tag-token' import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token' import Token from 'src/parser/token'
import Scope from 'src/scope/scope' import Scope from 'src/scope/scope'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
const re = new RegExp(`(${identifier.source})`) const re = new RegExp(`(${identifier.source})`)
+6 -6
View File
@@ -1,10 +1,10 @@
import { evalExp } from 'src/render/syntax' import { evalExp } from 'src/render/syntax'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITemplate from 'src/template/itemplate'; import ITemplate from 'src/template/itemplate'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ParseStream from 'src/parser/parse-stream'; import ParseStream from 'src/parser/parse-stream'
export default { export default {
parse: function (tagToken: TagToken, remainTokens: Token[]) { parse: function (tagToken: TagToken, remainTokens: Token[]) {
+3 -3
View File
@@ -1,6 +1,6 @@
import TagToken from "src/parser/tag-token"; import TagToken from 'src/parser/tag-token'
import Token from "src/parser/token"; import Token from 'src/parser/token'
import ITagImplOptions from "src/template/tag/itag-impl-options"; import ITagImplOptions from 'src/template/tag/itag-impl-options'
export default { export default {
parse: function (tagToken: TagToken, remainTokens: Token[]) { parse: function (tagToken: TagToken, remainTokens: Token[]) {
+3 -3
View File
@@ -1,9 +1,9 @@
import assert from 'src/util/assert' import assert from 'src/util/assert'
import { value as rValue } from 'src/parser/lexical' import { value as rValue } from 'src/parser/lexical'
import { evalValue } from 'src/render/syntax' import { evalValue } from 'src/render/syntax'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`) const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
const candidatesRE = new RegExp(rValue.source, 'g') const candidatesRE = new RegExp(rValue.source, 'g')
+1 -1
View File
@@ -3,7 +3,7 @@ import { identifier } from 'src/parser/lexical'
import { CaptureScope, AssignScope, DecrementScope } from 'src/scope/scopes' import { CaptureScope, AssignScope, DecrementScope } from 'src/scope/scopes'
import TagToken from 'src/parser/tag-token' import TagToken from 'src/parser/tag-token'
import Scope from 'src/scope/scope' import Scope from 'src/scope/scope'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
export default { export default {
parse: function (token: TagToken) { parse: function (token: TagToken) {
+7 -7
View File
@@ -3,13 +3,13 @@ import { isString, isObject, isArray } from 'src/util/underscore'
import { evalExp } from 'src/render/syntax' import { evalExp } from 'src/render/syntax'
import assert from 'src/util/assert' import assert from 'src/util/assert'
import { identifier, value, hash } from 'src/parser/lexical' import { identifier, value, hash } from 'src/parser/lexical'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import Hash from 'src/template/tag/hash'; import Hash from 'src/template/tag/hash'
import ITemplate from 'src/template/itemplate'; import ITemplate from 'src/template/itemplate'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ParseStream from 'src/parser/parse-stream'; import ParseStream from 'src/parser/parse-stream'
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` + const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
`(${value.source})` + `(${value.source})` +
+6 -6
View File
@@ -1,10 +1,10 @@
import { evalExp, isTruthy } from 'src/render/syntax' import { evalExp, isTruthy } from 'src/render/syntax'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITemplate from 'src/template/itemplate'; import ITemplate from 'src/template/itemplate'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ParseStream from 'src/parser/parse-stream'; import ParseStream from 'src/parser/parse-stream'
export default { export default {
parse: function (tagToken: TagToken, remainTokens: Token[]) { parse: function (tagToken: TagToken, remainTokens: Token[]) {
+4 -4
View File
@@ -2,10 +2,10 @@ import assert from 'src/util/assert'
import { value, quotedLine } from 'src/parser/lexical' import { value, quotedLine } from 'src/parser/lexical'
import { evalValue } from 'src/render/syntax' import { evalValue } from 'src/render/syntax'
import BlockMode from 'src/scope/block-mode' import BlockMode from 'src/scope/block-mode'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import Hash from 'src/template/tag/hash'; import Hash from 'src/template/tag/hash'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
const staticFileRE = /[^\s,]+/ const staticFileRE = /[^\s,]+/
const withRE = new RegExp(`with\\s+(${value.source})`) const withRE = new RegExp(`with\\s+(${value.source})`)
+1 -1
View File
@@ -1,7 +1,7 @@
import assert from 'src/util/assert' import assert from 'src/util/assert'
import { identifier } from 'src/parser/lexical' import { identifier } from 'src/parser/lexical'
import { CaptureScope, AssignScope, IncrementScope } from 'src/scope/scopes' import { CaptureScope, AssignScope, IncrementScope } from 'src/scope/scopes'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
export default { export default {
parse: function (token) { parse: function (token) {
+5 -5
View File
@@ -2,11 +2,11 @@ import assert from 'src/util/assert'
import { value as rValue } from 'src/parser/lexical' import { value as rValue } from 'src/parser/lexical'
import { evalValue } from 'src/render/syntax' import { evalValue } from 'src/render/syntax'
import BlockMode from 'src/scope/block-mode' import BlockMode from 'src/scope/block-mode'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import Hash from 'src/template/tag/hash'; import Hash from 'src/template/tag/hash'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
const staticFileRE = /\S+/ const staticFileRE = /\S+/
+3 -3
View File
@@ -1,6 +1,6 @@
import TagToken from "src/parser/tag-token"; import TagToken from 'src/parser/tag-token'
import Token from "src/parser/token"; import Token from 'src/parser/token'
import ITagImplOptions from "src/template/tag/itag-impl-options"; import ITagImplOptions from 'src/template/tag/itag-impl-options'
export default <ITagImplOptions>{ export default <ITagImplOptions>{
parse: function (tagToken: TagToken, remainTokens: Token[]) { parse: function (tagToken: TagToken, remainTokens: Token[]) {
+7 -7
View File
@@ -2,13 +2,13 @@ import { mapSeries } from 'src/util/promise'
import assert from 'src/util/assert' import assert from 'src/util/assert'
import { evalExp } from 'src/render/syntax' import { evalExp } from 'src/render/syntax'
import { identifier, value, hash } from 'src/parser/lexical' import { identifier, value, hash } from 'src/parser/lexical'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import ITemplate from 'src/template/itemplate'; import ITemplate from 'src/template/itemplate'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import Hash from 'src/template/tag/hash'; import Hash from 'src/template/tag/hash'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ParseStream from 'src/parser/parse-stream'; import ParseStream from 'src/parser/parse-stream'
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` + const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
`(${value.source})` + `(${value.source})` +
+5 -6
View File
@@ -1,10 +1,9 @@
import { evalExp, isFalsy } from 'src/render/syntax' import { evalExp, isFalsy } from 'src/render/syntax'
import TagToken from 'src/parser/tag-token'; import TagToken from 'src/parser/tag-token'
import Token from 'src/parser/token'; import Token from 'src/parser/token'
import ITemplate from 'src/template/itemplate'; import Scope from 'src/scope/scope'
import Scope from 'src/scope/scope'; import ITagImplOptions from 'src/template/tag/itag-impl-options'
import ITagImplOptions from 'src/template/tag/itag-impl-options'; import ParseStream from 'src/parser/parse-stream'
import ParseStream from 'src/parser/parse-stream';
export default { export default {
parse: function (tagToken: TagToken, remainTokens: Token[]) { parse: function (tagToken: TagToken, remainTokens: Token[]) {
+1 -1
View File
@@ -14,7 +14,7 @@ import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax'
import builtinTags from './builtin/tags' import builtinTags from './builtin/tags'
import builtinFilters from './builtin/filters' import builtinFilters from './builtin/filters'
import { LiquidOptions, NormalizedFullOptions, applyDefault, normalize } from './liquid-options' import { LiquidOptions, NormalizedFullOptions, applyDefault, normalize } from './liquid-options'
import FilterImpl from './template/filter/filter-impl'; import { FilterImpl } from './template/filter/filter-impl'
export default class Liquid { export default class Liquid {
public options: NormalizedFullOptions public options: NormalizedFullOptions
+1 -1
View File
@@ -6,7 +6,7 @@ export const quoteBalanced = new RegExp(`(?:${quoted.source}|[^'"])*`)
// basic types // basic types
export const integer = /-?\d+/ export const integer = /-?\d+/
export const number = /-?\d+\.?\d*|\.?\d+/ export const number = /[+-]?(?:\d+\.?\d*|\.?\d+)/
export const bool = /true|false/ export const bool = /true|false/
// property access // property access
+2 -2
View File
@@ -1,6 +1,6 @@
import Token from 'src/parser/token' import Token from 'src/parser/token'
import ITemplate from 'src/template/itemplate' import ITemplate from 'src/template/itemplate'
import TagToken from './tag-token'; import TagToken from './tag-token'
type ParseToken = ((token: Token, remainTokens: Array<Token>) => ITemplate) type ParseToken = ((token: Token, remainTokens: Array<Token>) => ITemplate)
@@ -18,7 +18,7 @@ export default class ParseStream {
this.handlers[name] = cb this.handlers[name] = cb
return this return this
} }
trigger <T extends Token | ITemplate>(event: string, arg?: T) { trigger <T extends Token | ITemplate> (event: string, arg?: T) {
const h = this.handlers[event] const h = this.handlers[event]
if (typeof h === 'function') { if (typeof h === 'function') {
h(arg) h(arg)
+3 -3
View File
@@ -1,7 +1,7 @@
import { RenderBreakError, RenderError } from 'src/util/error' import { RenderError } from 'src/util/error'
import assert from 'src/util/assert' import assert from 'src/util/assert'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
import ITemplate from 'src/template/itemplate'; import ITemplate from 'src/template/itemplate'
export default class Render { export default class Render {
async renderTemplates (templates: ITemplate[], scope: Scope) { async renderTemplates (templates: ITemplate[], scope: Scope) {
+2 -2
View File
@@ -1,4 +1,4 @@
export default interface IContext { export default interface IContext {
[key: string]: any; [key: string]: any;
liquid_method_missing?: (key: string) => any; liquid_method_missing?: (key: string) => any; // eslint-disable-line
} }
+1 -1
View File
@@ -4,7 +4,7 @@ import * as lexical from '../parser/lexical'
import assert from '../util/assert' import assert from '../util/assert'
import { NormalizedFullOptions, applyDefault } from '../liquid-options' import { NormalizedFullOptions, applyDefault } from '../liquid-options'
import BlockMode from './block-mode' import BlockMode from './block-mode'
import IContext from './icontext'; import IContext from './icontext'
export default class Scope { export default class Scope {
opts: NormalizedFullOptions opts: NormalizedFullOptions
+1 -3
View File
@@ -1,3 +1 @@
type FilterImpl = (value: any, ...args: any[]) => any export type FilterImpl = (value: any, ...args: any[]) => any
export default FilterImpl
+1 -1
View File
@@ -2,7 +2,7 @@ import assert from 'src/util/assert'
import * as lexical from 'src/parser/lexical' import * as lexical from 'src/parser/lexical'
import { evalValue } from 'src/render/syntax' import { evalValue } from 'src/render/syntax'
import Scope from 'src/scope/scope' import Scope from 'src/scope/scope'
import FilterImpl from './filter-impl' import { FilterImpl } from './filter-impl'
const valueRE = new RegExp(`${lexical.value.source}`, 'g') const valueRE = new RegExp(`${lexical.value.source}`, 'g')
+1 -1
View File
@@ -1,6 +1,6 @@
import { hashCapture } from 'src/parser/lexical' import { hashCapture } from 'src/parser/lexical'
import { evalValue } from 'src/render/syntax' import { evalValue } from 'src/render/syntax'
import Scope from 'src/scope/scope'; import Scope from 'src/scope/scope'
/** /**
* Key-Value Pairs Representing Tag Arguments * Key-Value Pairs Representing Tag Arguments
+1 -2
View File
@@ -1,5 +1,4 @@
import * as _ from './underscore' import * as _ from './underscore'
import { __extends } from 'tslib'
import Token from 'src/parser/token' import Token from 'src/parser/token'
import ITemplate from 'src/template/itemplate' import ITemplate from 'src/template/itemplate'
@@ -11,7 +10,7 @@ abstract class LiquidError extends Error {
this.originalError = err this.originalError = err
this.token = token this.token = token
} }
protected update() { protected update () {
const err = this.originalError const err = this.originalError
const context = mkContext(this.token) const context = mkContext(this.token)
this.message = mkMessage(err.message, this.token) this.message = mkMessage(err.message, this.token)
+2 -2
View File
@@ -5,8 +5,8 @@
* The iteratee is invoked with three arguments: (value, index, iterable). * The iteratee is invoked with three arguments: (value, index, iterable).
*/ */
export function mapSeries<T1, T2> ( export function mapSeries<T1, T2> (
iterable: T1[], iterable: T1[],
iteratee: (item: T1, idx: number, iterable: T1[]) => Promise<T2> | T2 iteratee: (item: T1, idx: number, iterable: T1[]) => Promise<T2> | T2
): Promise<T2[]> { ): Promise<T2[]> {
let ret = Promise.resolve(0) let ret = Promise.resolve(0)
const result: T2[] = [] const result: T2[] = []
+1 -1
View File
@@ -179,6 +179,6 @@ export default function (d: Date, format: string) {
// Add the format code // Add the format code
const ch = results[0].charAt(1) const ch = results[0].charAt(1)
const func = formatCodes[ch] const func = formatCodes[ch]
output += func ? func.call(null, d) : '%' + ch output += func ? func(d) : '%' + ch
} }
} }
+2 -2
View File
@@ -77,10 +77,10 @@ export function isError (value: any): boolean {
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @return {Object} Returns object. * @return {Object} Returns object.
*/ */
export function forOwn <T>( export function forOwn <T> (
object: {[key: string]: T} | undefined, object: {[key: string]: T} | undefined,
iteratee: ((val: T, key: string, obj: {[key: string]: T}) => boolean | void) iteratee: ((val: T, key: string, obj: {[key: string]: T}) => boolean | void)
) { ) {
object = object || {} object = object || {}
for (const k in object) { for (const k in object) {
if (object.hasOwnProperty(k)) { if (object.hasOwnProperty(k)) {
+1 -1
View File
@@ -1,7 +1,7 @@
import Liquid from 'src/liquid' import Liquid from 'src/liquid'
import { expect, use } from 'chai' import { expect, use } from 'chai'
import * as chaiAsPromised from 'chai-as-promised' import * as chaiAsPromised from 'chai-as-promised'
import IContext from 'src/scope/icontext'; import IContext from 'src/scope/icontext'
use(chaiAsPromised) use(chaiAsPromised)
+2 -2
View File
@@ -4,11 +4,11 @@ import { expect } from 'chai'
describe('LiquidOptions', function () { describe('LiquidOptions', function () {
describe('#normalize ()', function () { describe('#normalize ()', function () {
it('should normalize string typed root array', function () { it('should normalize string typed root array', function () {
const options = normalize({root: 'foo'}) const options = normalize({ root: 'foo' })
expect(options.root).to.eql(['foo']) expect(options.root).to.eql(['foo'])
}) })
it('should normalize null typed root as empty array', function () { it('should normalize null typed root as empty array', function () {
const options = normalize({root: null} as any) const options = normalize({ root: null } as any)
expect(options.root).to.eql([]) expect(options.root).to.eql([])
}) })
}) })
+1 -1
View File
@@ -1,6 +1,6 @@
import * as chai from 'chai' import * as chai from 'chai'
import Scope from 'src/scope/scope' import Scope from 'src/scope/scope'
import IContext from 'src/scope/icontext'; import IContext from 'src/scope/icontext'
const expect = chai.expect const expect = chai.expect