eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

`vue/no-ref-as-operand` should not autofix when variable is `Ref | NotARef`

Open jacekkarczmarczyk opened this issue 2 years ago • 1 comments

Checklist

  • [x] I have tried restarting my IDE and the issue persists.
  • [x] I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.23.1
  • eslint-plugin-vue version: 9.5.1
  • Node version: 16.14.2
  • Operating System: win

Please show your full configuration:

module.exports = {
  extends: ['jkarczm/vuetify'],
  parserOptions: {
    project: 'tsconfig.json',
  },
}

(where jkarczm/vuetify is from https://github.com/jacekkarczmarczyk/eslint-config-jkarczm package, but probably including only vue/no-ref-as-operand matters)

What did you do?

let foo: Ref<number> | undefined;

if (!foo) {
  foo = ref(5);
}

What did you expect to happen?

no error, no autofixing

What actually happened?

code was "fixed" to

let foo: Ref<number> | undefined;

if (!foo.value) {
  foo.value = ref(5);
}

jacekkarczmarczyk avatar Sep 17 '22 19:09 jacekkarczmarczyk

let foo;
foo = Reactive(bar)

triggers the same bug.

ylavoie avatar Sep 19 '22 00:09 ylavoie

This was caused by #1965 I think, because those cases didn't trigger an error before and they now do

Tofandel avatar Sep 22 '22 15:09 Tofandel