Skip to content

Commit 3b7351d

Browse files
committed
chore: fix linting
1 parent e977669 commit 3b7351d

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

src/template/filter/filter.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import assert from 'src/util/assert'
2-
import * as lexical from 'src/parser/lexical'
31
import { evalValue } from 'src/render/syntax'
42
import Scope from 'src/scope/scope'
53
import { FilterImpl } from './filter-impl'
64

7-
const valueRE = new RegExp(`${lexical.value.source}`, 'g')
8-
95
export default class Filter {
106
name: string
117
impl: FilterImpl

src/template/value.ts

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { evalExp } from 'src/render/syntax'
2-
import * as lexical from 'src/parser/lexical'
32
import Filter from './filter/filter'
43
import Scope from 'src/scope/scope'
54

6-
75
enum ParseState {
86
INIT = 0,
97
FILTER_NAME = 1,
@@ -18,7 +16,6 @@ export default class {
1816
* @param str value string, like: "i have a dream | truncate: 3
1917
*/
2018
constructor (str: string, strictFilters: boolean) {
21-
const N = str.length
2219
let buffer = ''
2320
let quoted = ''
2421
let state = ParseState.INIT
@@ -27,23 +24,20 @@ export default class {
2724
let filterName = ''
2825
let filterArgs: string[] = []
2926

30-
for(let i = 0; i < str.length; i++) {
27+
for (let i = 0; i < str.length; i++) {
3128
if (quoted) {
32-
if (str[i] == quoted) {
29+
if (str[i] === quoted) {
3330
quoted = ''
3431
sealed = true
3532
}
3633
buffer += str[i]
37-
}
38-
else if (/\s/.test(str[i])) {
34+
} else if (/\s/.test(str[i])) {
3935
if (!buffer) continue
4036
else sealed = true
41-
}
42-
else if (str[i] === '|') {
37+
} else if (str[i] === '|') {
4338
if (state === ParseState.INIT) {
4439
this.initial = buffer
45-
}
46-
else {
40+
} else {
4741
if (state === ParseState.FILTER_NAME) filterName = buffer
4842
else filterArgs.push(buffer)
4943
this.filters.push(new Filter(filterName, filterArgs, strictFilters))
@@ -53,19 +47,16 @@ export default class {
5347
state = ParseState.FILTER_NAME
5448
buffer = ''
5549
sealed = false
56-
}
57-
else if (state === ParseState.FILTER_NAME && str[i] === ':') {
50+
} else if (state === ParseState.FILTER_NAME && str[i] === ':') {
5851
filterName = buffer
5952
state = ParseState.FILTER_ARG
6053
buffer = ''
6154
sealed = false
62-
}
63-
else if (state === ParseState.FILTER_ARG && str[i] === ',') {
55+
} else if (state === ParseState.FILTER_ARG && str[i] === ',') {
6456
filterArgs.push(buffer)
6557
buffer = ''
6658
sealed = false
67-
}
68-
else if (sealed) continue
59+
} else if (sealed) continue
6960
else {
7061
if ((str[i] === '"' || str[i] === "'") && !quoted) quoted = str[i]
7162
buffer += str[i]

test/unit/template/filter/filter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('filter', function () {
3535

3636
it('should render filters with argument', function () {
3737
Filter.register('add', (a, b) => a + b)
38-
expect(new Filter('add', ["2"], false).render(3, scope)).to.equal(5)
38+
expect(new Filter('add', ['2'], false).render(3, scope)).to.equal(5)
3939
})
4040

4141
it('should render filters with multiple arguments', function () {

0 commit comments

Comments
 (0)