Skip to content

using $ref sugar with $ref(number) conflicts with @typescript-eslint/restrict-plus-operands rule #1839

Closed
@leonsilicon

Description

@leonsilicon

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.12.0
  • eslint-plugin-vue version: 8>5.0
  • Node version: 16.14.1
  • Operating System: macOS

Please show your full configuration:

module.exports = {
	extends: ['plugin:@typescript-eslint/recommended', 'plugin:vue/vue3-recommended'],
	plugins: ['@typescript-eslint'],
	parserOptions: {
		parser: '@typescript-eslint/parser',
		ecmaVersion: 2018,
		sourceType: 'module',
		extraFileExtensions: ['.vue'],
		project: './tsconfig.json'
	},
	rules: {
		'@typescript-eslint/restrict-plus-operands': 'error'
	}
}

What did you do?

<script setup lang="ts">
const a = $ref(0);
console.log(a + 1);
</script>

<template>
  <div>div</div>
</template>

What did you expect to happen?
No lint error

What actually happened?

/Users/leonzalion/projects/eslint-bug/src/App.vue
  3:13  error  Operands of '+' operation must either be both strings or both numbers  @typescript-eslint/restrict-plus-operands

✖ 1 problem (1 error, 0 warnings)

 ELIFECYCLE  Command failed with exit code 1.

Repository to reproduce this issue

https://github.com/leonzalion/vue-ref-eslint-bug

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