Skip to content

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

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
leonsilicon opened this issue Apr 5, 2022 · 1 comment

Comments

@leonsilicon
Copy link

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

@leonsilicon leonsilicon changed the title using $ref sugar with $ref(0) conflicts with @typescript-eslint/restrict-plus-operands rule using $ref sugar with $ref(number) conflicts with @typescript-eslint/restrict-plus-operands rule Apr 5, 2022
@ota-meshi
Copy link
Member

Thank you for posting issue.

The typescript-eslint/restrict-plus-operands rule doesn't seem to allow intersection type of number. (intersection type of string seem to be allowed.)

https://typescript-eslint.io/play/#ts=4.6.2&sourceType=module&code=MYewdgzgLgBBMF4YHJkwIbwBTQE4EswBzGAMhgG8BfASgChRIQAbAUwDpmQicYBqFHmQ0A3HQbhoMMIhgAWAEwZsYAK4BbAEatcZSrQlM2nblhkCAjKLpA&rules=N4IgAgLgngDgpgZwMYCcCWMIFpEBs0B2EA9CohOktjLgK4JYD28KAhgQCYIgBcIcKFIxQgAvkA&tsConfig=N4XyA

If you want to solve it, please suggest a feature to typescript-eslint.
I think the issue posted in the past will be helpful.
typescript-eslint/typescript-eslint#2506

I close the issue, because we can't do anything with this repository.

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

No branches or pull requests

2 participants