Skip to content

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

Closed
@jacekkarczmarczyk

Description

@jacekkarczmarczyk

Checklist

  • I have tried restarting my IDE and the issue persists.
  • 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);
}

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