vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.47k stars 667 forks source link

no-ref-as-operand fails to trigger depending on boolean operator order #2599

Closed tiagoroldao closed 2 weeks ago

tiagoroldao commented 2 weeks ago

Checklist

Tell us about your environment

Please show your full configuration:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: ['plugin:vue/essential', '@vue/typescript', '@vue/prettier',],
  rules: {
    'no-console': 'warn',
    'no-debugger': 'warn',
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': [
      'warn',
      {
        argsIgnorePattern: '^_',
        caughtErrorsIgnorePattern: '^_',
        destructuredArrayIgnorePattern: '^_',
        varsIgnorePattern: '^_',
        ignoreRestSiblings: true,
      },
    ],
    'spaced-comment': ['warn', 'always'],
    'vue/valid-v-slot': [
      'error',
      {
        allowModifiers: true,
      },
    ],
    'vue/no-ref-as-operand': 'warn',
    'vue/component-name-in-template-casing': ['error', 'PascalCase', { registeredComponentsOnly: false }],
    'vue/custom-event-name-casing': ['error', 'kebab-case'],
    'vue/padding-line-between-blocks': ['error', 'always'],
  },
  parserOptions: {
    parser: '@typescript-eslint/parser',
  },
};

What did you do?

// `isUpdating` is a ComputedRef

function onValidationChanged() {
  config.value.steps.forEach((step, index) => {
    if (index <= stepIndex.value || isUpdating) {
      step.state = validations.value[index]?.$invalid ? 'invalid' : 'valid';
    }
  });
}

What did you expect to happen? vue/no-ref-as-operand to be trigered on isUpdating

What actually happened?

No error is found. It is found if the order is reversed, though. Below are IDE snapshots for clarity, but this happens when running eslint via CLI on the file too:

Screenshot 2024-11-06 at 13 16 55 Screenshot 2024-11-06 at 13 16 40

Repository to reproduce this issue

Can provide one if requested.

FloEdelmann commented 2 weeks ago

Duplicate of https://github.com/vuejs/eslint-plugin-vue/issues/2271