Skip to content

No ref as operand in composable #2615

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

Closed
2 tasks done
timothee-durand opened this issue Nov 18, 2024 · 1 comment
Closed
2 tasks done

No ref as operand in composable #2615

timothee-durand opened this issue Nov 18, 2024 · 1 comment

Comments

@timothee-durand
Copy link

timothee-durand commented Nov 18, 2024

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.49.0
  • eslint-plugin-vue version: ^9.17.0 (i also tried with ^9.31.0)
  • Vue version: ^3.4.15
  • Node version: 20.11.0
  • Operating System: ubuntu 24

Please show your full configuration:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
  root: true,
  ignorePatterns: ['*.legacy.vue'],
  env: { node: true, es6: true, browser: true, jest: true },
  extends: [
    'eslint:recommended',
    '@vue/eslint-config-typescript',
    'plugin:vue/vue3-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:import/recommended',
    'plugin:import/typescript',
    '@vue/eslint-config-prettier',
  ],
  parser: 'vue-eslint-parser',
  parserOptions: {
    ecmaVersion: 'latest',
    parser: '@typescript-eslint/parser',
  },
  plugins: ['import', '@typescript-eslint', 'unused-imports'],
  settings: {
    'import/resolver': {
      typescript: {
        alwaysTryTypes: true,
        project: './tsconfig.app.json',
      },
      node: true,
    },
  },
  rules: {
    quotes: [
      'error',
      'single',
      { avoidEscape: true, allowTemplateLiterals: false },
    ],
    '@typescript-eslint/no-explicit-any': 'error',
    '@typescript-eslint/explicit-function-return-type': 'warn',
    'import/newline-after-import': 'error',
    'import/no-unresolved': 'error',
    'import/order': [
      'error',
      {
        'newlines-between': 'always',
        groups: [
          'builtin',
          'external',
          'internal',
          'parent',
          'sibling',
          'index',
        ],
        alphabetize: { order: 'asc', caseInsensitive: true },
      },
    ],
    'no-console': 'warn',
    'no-use-before-define': 'off',
    'no-warning-comments': 'warn',
    'padding-line-between-statements': 'off',
    'unused-imports/no-unused-imports': 'error',
    'vue/no-multiple-template-root': 'off',
    'vue/no-ref-as-operand': 'error',
    'vue/no-undef-components': 'error',
    'vue/html-self-closing': 'off',
    'vue/component-name-in-template-casing': [
      'error',
      'PascalCase',
      {
        registeredComponentsOnly: true,
      },
    ],
  },
  globals: {
    'i18n-t': 'readonly',
  },
}

What did you do?

<script setup>
function useSomething() {
  const testRef = ref('test')
  const testComputed = computed(() => {
    return testRef.value !== 'test'
  })
  return {
    testComputed,
    testRef,
  }
}

const isTestComputedOk = computed(() => {
  const { testComputed } = useSomething()
  if (testComputed) {
    return 'yes'
  } else {
    return 'no'
  }
})
</script>

What did you expect to happen?
The testComputed in the isTestComputedOk should throw a vue/no-ref-as-operand lint error

What actually happened?
It doesn't throw

Repository to reproduce this issue
https://github.com/timothee-durand/minimal-reproduce-no-ref-as-operand

@waynzh
Copy link
Member

waynzh commented Nov 24, 2024

This is a duplicate of #2519.
Thanks for the detailed info. Let's track the issue there.

@waynzh waynzh closed this as completed Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants