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

disallow importing macros: defineProps etc #2437

Open
dcecile opened this issue Mar 26, 2024 · 0 comments
Open

disallow importing macros: defineProps etc #2437

dcecile opened this issue Mar 26, 2024 · 0 comments

Comments

@dcecile
Copy link

dcecile commented Mar 26, 2024

It it worth tracking approved but closed #1906 as a new issue here? Although this may be better as a core feature.

Example playground that includes vue/prefer-import-from-vue rule enabled: link

This playground code triggers a compiler message about the macro import:

[@vue/compiler-sfc] `defineProps` is a compiler macro and no longer needs to be imported.

Please describe what the rule should do: It should warn if defineProps, defineEmits and similar are imported from vue (autofixable)

What category should the rule belong to?

[x] Enforces code style (layout)
[ ] 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:

bad:

<script setup>
import { defineProps } from '@vue/runtime-dom';

defineProps<{}>();
</script>

good:

<script setup>
defineProps<{}>();
</script>

good:

<script setup>
import { defineProps } from 'my-lib';

defineProps('whatever');

Additional context Useful when define* are added to eslint globals, there's no need to import them manually. If project was using imports and then dev switched to globals then autofix would just automatically remove unnecessary imports

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

1 participant