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
+1 -1
View File
@@ -2,7 +2,7 @@ import { isNil, isString, toValue } from '../util/underscore'
import { EmptyDrop } from '../drop/empty-drop'
export class BlankDrop extends EmptyDrop {
equals (value: any) {
public equals (value: any) {
if (value === false) return true
if (isNil(toValue(value))) return true
if (isString(value)) return /^\s*$/.test(value)
+2 -2
View File
@@ -1,9 +1,9 @@
export abstract class Drop {
valueOf (): any {
public valueOf (): any {
return undefined
}
liquidMethodMissing (key: string): Promise<string | undefined> | string | undefined {
public liquidMethodMissing (key: string): Promise<string | undefined> | string | undefined {
return undefined
}
}
+6 -6
View File
@@ -3,24 +3,24 @@ import { IComparable } from './icomparable'
import { isObject, isString, isArray } from '../util/underscore'
export class EmptyDrop extends Drop implements IComparable {
equals (value: any) {
public equals (value: any) {
if (isString(value) || isArray(value)) return value.length === 0
if (isObject(value)) return Object.keys(value).length === 0
return false
}
gt () {
public gt () {
return false
}
geq () {
public geq () {
return false
}
lt () {
public lt () {
return false
}
leq () {
public leq () {
return false
}
valueOf () {
public valueOf () {
return ''
}
}
+10 -10
View File
@@ -2,33 +2,33 @@ import { Drop } from './drop'
export class ForloopDrop extends Drop {
protected i: number = 0
length: number
constructor (length: number) {
public length: number
public constructor (length: number) {
super()
this.length = length
}
next () {
public next () {
this.i++
}
index0 () {
public index0 () {
return this.i
}
index () {
public index () {
return this.i + 1
}
first () {
public first () {
return this.i === 0
}
last () {
public last () {
return this.i === this.length - 1
}
rindex () {
public rindex () {
return this.length - this.i
}
rindex0 () {
public rindex0 () {
return this.length - this.i - 1
}
valueOf () {
public valueOf () {
return JSON.stringify(this)
}
}
+5 -5
View File
@@ -1,11 +1,11 @@
import { isFunction } from '../util/underscore'
export interface IComparable {
equals: (rhs: any) => boolean
gt: (rhs: any) => boolean
geq: (rhs: any) => boolean
lt: (rhs: any) => boolean
leq: (rhs: any) => boolean
equals: (rhs: any) => boolean;
gt: (rhs: any) => boolean;
geq: (rhs: any) => boolean;
lt: (rhs: any) => boolean;
leq: (rhs: any) => boolean;
}
export function isComparable (arg: any): arg is IComparable {
+6 -6
View File
@@ -4,22 +4,22 @@ import { isNil, toValue } from '../util/underscore'
import { BlankDrop } from '../drop/blank-drop'
export class NullDrop extends Drop implements IComparable {
equals (value: any) {
public equals (value: any) {
return isNil(toValue(value)) || value instanceof BlankDrop
}
gt () {
public gt () {
return false
}
geq () {
public geq () {
return false
}
lt () {
public lt () {
return false
}
leq () {
public leq () {
return false
}
valueOf () {
public valueOf () {
return null
}
}
+6 -6
View File
@@ -2,24 +2,24 @@ import { ForloopDrop } from './forloop-drop'
export class TablerowloopDrop extends ForloopDrop {
private cols: number
constructor (length: number, cols: number) {
public constructor (length: number, cols: number) {
super(length)
this.length = length
this.cols = cols
}
row () {
public row () {
return Math.floor(this.i / this.cols) + 1
}
col0 () {
public col0 () {
return (this.i % this.cols)
}
col () {
public col () {
return this.col0() + 1
}
col_first () { // eslint-disable-line
public col_first () { // eslint-disable-line
return this.col0() === 0
}
col_last () { // eslint-disable-line
public col_last () { // eslint-disable-line
return this.col() === this.cols
}
}