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 to support ref from composable #2519

Open
kong-troop opened this issue Aug 2, 2024 · 1 comment
Open

vue/no-ref-as-operand to support ref from composable #2519

kong-troop opened this issue Aug 2, 2024 · 1 comment

Comments

@kong-troop
Copy link

Please describe what the rule should do:

Current vue/no-ref-as-operand rule only support the local ref. If a ref is being returned from a composable and being use with operand (eg: returnedRef++) , it didnt throw any warning as expected.

What category should the rule belong to?

[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

const ok = ref(true)
const msg = ok ? 'yes' : 'no' // this throws warning as expected

// ---- //

const ok = useOk() // returned as Ref<boolean>
const msg = ok ? 'yes' : 'no' // No warning was shown

Additional context

@FloEdelmann
Copy link
Member

FloEdelmann commented Aug 22, 2024

ESLint and thus eslint-plugin-vue only has access to the current file while linting, so checking what might be returned from some other file is difficult.

Maybe if typescript-eslint's parser is used, we have access to the types and can report those cases then? Feel free to try that and submit a PR.

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