Skip to content

Some issues about VOnExpression node range when line-breaking style is CRLF. #59

Closed
@kamilic

Description

@kamilic

Hello.
I am using 'eslint-plugin-vue' to do some checking job for my project, but I happened some problems.

Here is the repository for reproducing this problem.
https://github.com/kamilic/reproduce-of-location-problem
In LF, everything runs well, but in CRLF, it seems to go wrong.
(--fix also)

I did some research by reading some source code.
After some code reading, I found that it's not an issues from 'eslint-plugin-vue'.
The rule vue/space-infix-ops is simply a wrapper of eslint rule space-infix-ops.

Eslint implements space-infix-ops rule depending on ast node range.
https://github.com/eslint/eslint/blob/master/lib/rules/space-infix-ops.js#L55

Estree node range is produced by vue-eslint-parser.

<template>
    <div @click="a = b"></div>
</template>

image

image

I tried to count location manually.
Range of a should be [29, 30].
Range of = should be [31, 32].
Range of b should be [33, 34].

Then, I did some step by step debugging.
Range still correct before location fixing.
https://github.com/mysticatea/vue-eslint-parser/blob/master/src/script/index.ts#L101
It seem something bad happened in fixLocation method.

Hope it is helpful for fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions