Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix has invalid range #76

Closed
aelgn opened this issue Nov 19, 2023 · 3 comments
Closed

Fix has invalid range #76

aelgn opened this issue Nov 19, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@aelgn
Copy link

aelgn commented Nov 19, 2023

It seems like eslint-plugin-vuetify 2.1.0 throws AssertionError [ERR_ASSERTION]: Fix has invalid range for a lot of cases which work in 2.0.5. It seems like the null range returned from some eslint-plugin-vuetify rules makes eslint throw a fit and stop linting.

Might want to check the output range of fixes before returning it to eslint. If a valid range cannot be found, that could be a warning instead - so that eslint does not crash.

Although it seems like a multitude of cases exist, I have boiled it down to a minimal repro:

  • npm create vuetify
  • add eslint-plugin-vuetify 2.1.0 to package.json
  • extend 'plugin:vuetify/base' in eslintrc.js
  • create vue component:
<template>
  <v-menu>
    <template #activator="{ on, attrs }">
      <v-btn icon v-bind="attrs" v-on="on">
        <v-icon>mdi-filter-outline</v-icon>
      </v-btn>
    </template>
  </v-menu>
</template>

<script lang="ts">
</script>
  • npm run lint

=>

AssertionError [ERR_ASSERTION]: Fix has invalid range: {
  "range": [
    null,
    null
  ],
  "text": ""
}
    at assertValidFix (.../vfy3test/node_modules/eslint/lib/linter/report-translator.js:126:9)
    at mergeFixes (.../vfy3test/node_modules/eslint/lib/linter/report-translator.js:149:9)
    at normalizeFixes (.../vfy3test/node_modules/eslint/lib/linter/report-translator.js:198:16)
    at .../vfy3test/node_modules/eslint/lib/linter/report-translator.js:365:49
    at Object.report (.../vfy3test/node_modules/eslint/lib/linter/linter.js:1062:41)
    at Object.handler (.../vfy3test/node_modules/eslint-plugin-vuetify/lib/rules/no-deprecated-slots.js:85:19)
    at EventEmitter.VElement (.../vfy3test/node_modules/eslint-plugin-vuetify/lib/rules/no-deprecated-slots.js:191:17)
    at EventEmitter.emit (node:events:523:35)
    at NodeEventGenerator.applySelector (.../vfy3test/node_modules/vue-eslint-parser/index.js:4268:26)
    at NodeEventGenerator.applySelectors (.../vfy3test/node_modules/vue-eslint-parser/index.js:4282:22)
@travisricks
Copy link

I think this is happening when this rule is turned on:
'vuetify/no-deprecated-slots': 'error'

If I comment it out, eslint works as expected.

@KaelWD
Copy link
Member

KaelWD commented Dec 8, 2023

The existing test for this passes:

{
code:
`<template>
<v-dialog>
<template #activator="{ attrs, on }">
<v-btn v-bind="attrs" v-on="on" />
</template>
</v-dialog>
</template>`,
output:
`<template>
<v-dialog>
<template #activator="{ props }">
<v-btn v-bind="props" />
</template>
</v-dialog>
</template>`,
errors: [{ messageId: 'changedProps' }],
},

For some reason node.start/end exist in the tests but not an actual project.

@KaelWD KaelWD self-assigned this Dec 8, 2023
@KaelWD KaelWD added the bug Something isn't working label Dec 8, 2023
@KaelWD KaelWD closed this as completed in becadd7 Dec 8, 2023
@rafalh
Copy link

rafalh commented Dec 8, 2023

I was debugging it yesterday (what a coincidence) and was going to make a PR today so i'm surprised it's already fixed :)
I found this issue: eslint/eslint#8956 It seems eslint was inconsequently using start/stop/range properties in AST nodes and they decided to stick with range. So I suppose there may be a different version of ESLint in tests or different node types than when the bug appears.

@KaelWD when do you expect a new release with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants