Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/no-ref-as-operand only lint left identifier of a logical expression #2271

Open
2 tasks done
lakb248 opened this issue Aug 8, 2023 · 1 comment · May be fixed by #2273
Open
2 tasks done

vue/no-ref-as-operand only lint left identifier of a logical expression #2271

lakb248 opened this issue Aug 8, 2023 · 1 comment · May be fixed by #2273
Labels

Comments

@lakb248
Copy link

lakb248 commented Aug 8, 2023

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: v8.27.0
  • eslint-plugin-vue version: v9.7.0
  • Node version: v16.17.0
  • Operating System: MacOS

Please show your full configuration:

module.exports = {
  env: {
    browser: true,
    node: true,
    es6: true,
  },
  extends: [
    'plugin:vue/recommended',
    'eslint:recommended',
    '@vue/eslint-config-typescript/recommended',
  ],
  settings: {
    'import/resolver': {
      typescript: { directory: 'tsconfig.json' },
      alias: {
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
        map: [
          // for more custom alias config not included in tsconfig
        ],
      },
    },
  },
  plugins: [
    'import'
  ],
}

What did you do?

const myRef = ref(0);
const a = true;
if (a && myRef) {
  // do something
}

What did you expect to happen?
myRef will throw vue/no-ref-as-operand error, vue/no-ref-as-operand only lint left identifier of a logicalExpression

What actually happened?

eslint don't throw vue/no-ref-as-operand error, and

Repository to reproduce this issue

@FloEdelmann FloEdelmann added the bug label Aug 8, 2023
lakb248 added a commit to lakb248/eslint-plugin-vue that referenced this issue Aug 11, 2023
@grindpride
Copy link

Maybe put the logic for this rule in a separate no-ref-as-operand-strict rule, or customize with a parameter (strictCheck) of the current one?
In my code there are no cases of the following type

const refValue1: Ref<number>  = ref(0)
const maybeRefValue: Ref<number> | null = getMaybeRef()
const refValue2 = maybeRefValue || refValue1

But errors with such case use are often encountered

const refValue1: Ref<number>  = ref(0)
if (refValue1) {
  //incorrect condition
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants