vuetifyjs / eslint-plugin-vuetify

An eslint plugin for Vuetify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix has invalid range

aelgn opened this issue · comments

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)

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.

commented

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.

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?