vuetifyjs / eslint-plugin-vuetify

An eslint plugin for Vuetify
Other
120 stars 22 forks source link

Fix has invalid range #76

Closed aelgn closed 7 months ago

aelgn commented 8 months ago

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 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 commented 7 months ago

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 commented 7 months ago

The existing test for this passes: https://github.com/vuetifyjs/eslint-plugin-vuetify/blob/d3cc998362aa7d3c64183b72e1b8f339a4a0816c/tests/rules/no-deprecated-slots.js#L47-L65 For some reason node.start/end exist in the tests but not an actual project.

rafalh commented 7 months ago

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: https://github.com/eslint/eslint/issues/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?