Skip to content

a bug about parseFilter #37

Closed
Closed
@marzk

Description

@marzk

try eslint to reproduce the bug.

<template>
  <div>{{ 1 | identity() || 0 }}</div>
</template>

<script>
export default {};
</script>

This is because identity() || 0 is LogicalExpression but not CallExpression.

This is the bug code.

//  `parseFilter` in `./src/script/index.ts`

if (argsCode != null) {
    const { ast } = parseScriptFragment(
        `0${argsCode}`,
        locationCalculator.getSubCalculatorAfter(paren - 1),
        parserOptions,
    )
    const statement = ast.body[0] as ESLintExpressionStatement
    const callExpression = statement.expression as ESLintCallExpression

    ast.tokens!.shift()
    
    // this is LogicalExpression
    for (const argument of callExpression.arguments) {
        argument.parent = expression
        expression.arguments.push(argument)
    }
    
    // ...
}

im not good at parser, and I dont know how to fix this bug. So i only create an issue but not a pr.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions