style: introduce @typescript-eslint/recommended

This commit is contained in:
harttle
2019-07-06 14:33:34 +08:00
parent e6f5f1cd85
commit 88c89fe3b3
48 changed files with 260 additions and 235 deletions
+6 -6
View File
@@ -5,11 +5,11 @@ import * as chaiAsPromised from 'chai-as-promised'
use(chaiAsPromised)
class SettingsDrop extends Liquid.Types.Drop {
foo: string = 'FOO'
bar () {
private foo: string = 'FOO'
public bar () {
return 'BAR'
}
liquidMethodMissing (key: string) {
public liquidMethodMissing (key: string) {
return key.toUpperCase()
}
}
@@ -29,10 +29,10 @@ describe('drop', function () {
describe('BlandDrop', function () {
it('should test blank strings', async function () {
const src = `
{% unless settings.fp_heading == blank %}
<h1>{{ settings.fp_heading }}</h1>
{% unless settings.fpHeading == blank %}
<h1>{{ settings.fpHeading }}</h1>
{% endunless %}`
var ctx = { settings: { fp_heading: '' } }
var ctx = { settings: { fpHeading: '' } }
const html = await engine.parseAndRender(src, ctx)
return expect(html).to.match(/^\s+$/)
})
+2 -2
View File
@@ -136,7 +136,7 @@ describe('xhr', () => {
[200, { 'Content-Type': 'text/plain' }, 'foo2'])
return engine.renderFile('foo.html')
})
.then((html:string) => expect(html).to.equal('foo2'))
.then((html: string) => expect(html).to.equal('foo2'))
})
it('should respect cache=true option', () => {
engine = new Liquid({
@@ -153,7 +153,7 @@ describe('xhr', () => {
[200, { 'Content-Type': 'text/plain' }, 'foo2'])
return engine.renderFile('foo.html')
})
.then((html:string) => expect(html).to.equal('foo1'))
.then((html: string) => expect(html).to.equal('foo1'))
})
})
})
+2 -2
View File
@@ -85,7 +85,7 @@ describe('tags/include', function () {
})
it('should support include: with as Liquid Drop', async function () {
class ColorDrop extends Liquid.Types.Drop {
valueOf (): string {
public valueOf (): string {
return 'red!'
}
}
@@ -98,7 +98,7 @@ describe('tags/include', function () {
})
it('should support include: with passed as Liquid Drop', async function () {
class ColorDrop extends Liquid.Types.Drop {
valueOf (): string {
public valueOf (): string {
return 'red!'
}
}
+6 -6
View File
@@ -6,22 +6,22 @@ describe('drop/drop', function () {
before(() => (liquid = new Liquid()))
class CustomDrop extends Liquid.Types.Drop {
name: string = 'NAME'
getName () {
private name: string = 'NAME'
public getName () {
return 'GET NAME'
}
}
class CustomDropWithMethodMissing extends CustomDrop {
liquidMethodMissing (key: string) {
public liquidMethodMissing (key: string) {
return key.toUpperCase()
}
}
class PromiseDrop extends Liquid.Types.Drop {
name = Promise.resolve('NAME')
async getName () {
private name = Promise.resolve('NAME')
public async getName () {
return 'GET NAME'
}
async liquidMethodMissing (key: string) {
public async liquidMethodMissing (key: string) {
return key.toUpperCase()
}
}
+7 -4
View File
@@ -2,17 +2,20 @@ import { isString, forOwn } from '../../src/util/underscore'
import fs from '../../src/fs/node'
import { resolve } from 'path'
type fileDescriptor = { mode: string, content: string }
interface FileDescriptor {
mode: string;
content: string;
}
let files: { [path: string]: fileDescriptor } = {}
let files: { [path: string]: FileDescriptor } = {}
const readFile = fs.readFile
const exists = fs.exists
export function mock (options: { [path: string]: (string | fileDescriptor) }) {
export function mock (options: { [path: string]: (string | FileDescriptor) }) {
forOwn(options, (val, key) => {
files[resolve(key)] = isString(val)
? { mode: '33188', content: val }
: val as fileDescriptor
: val as FileDescriptor
})
fs.readFile = async function (path) {
const file = files[path]
+4 -4
View File
@@ -1,12 +1,12 @@
import * as chai from 'chai'
import { isRange } from '../../../src/parser/lexical'
const expect = chai.expect
const lexical = require('../../../src/parser/lexical')
describe('lexical', function () {
it('should test range literal', function () {
expect(lexical.isRange('(12..32)')).to.equal(true)
expect(lexical.isRange('(12..foo)')).to.equal(true)
expect(lexical.isRange('(foo.bar..foo)')).to.equal(true)
expect(isRange('(12..32)')).to.equal(true)
expect(isRange('(12..foo)')).to.equal(true)
expect(isRange('(foo.bar..foo)')).to.equal(true)
})
})