Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed error
  • Loading branch information
ota-meshi committed May 26, 2020
commit 97784ef12a5fb5e978e39b1a18a17b85ae3df34a
18 changes: 11 additions & 7 deletions src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ function parseFilter(
// Parse the callee.
if (calleeCode.trim()) {
const spaces = /^\s*/u.exec(calleeCode)![0]
const subCalculator = locationCalculator.getSubCalculatorShift(
spaces.length,
)
const { ast } = parseScriptFragment(
`${spaces}"${calleeCode.trim()}"`,
locationCalculator,
`"${calleeCode.trim()}"`,
subCalculator,
parserOptions,
)
const statement = ast.body[0] as ESLintExpressionStatement
Expand All @@ -455,12 +458,13 @@ function parseFilter(
expression.callee = {
type: "Identifier",
parent: expression,
range: [callee.range[0], callee.range[1] - 2],
range: [
callee.range[0],
subCalculator.getOffsetWithGap(calleeCode.trim().length),
],
loc: {
start: callee.loc.start,
end: locationCalculator.getLocation(
callee.range[1] - callee.range[0] - 1,
),
end: subCalculator.getLocation(calleeCode.trim().length),
},
name: String(callee.value),
}
Expand Down Expand Up @@ -686,7 +690,7 @@ export function parseExpression(
// Parse a filter
const retF = parseFilter(
filterCode,
locationCalculator.getSubCalculatorAfter(prevLoc + 1),
locationCalculator.getSubCalculatorShift(prevLoc + 1),
parserOptions,
)
if (retF) {
Expand Down