-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Retrieve auto-imported component / function names #15015
Comments
This should be a discussion instead of an issue |
@manniL feel free to move it in the right place if you can, the edge between "feature request" and "discussion about feature request" isn't fully clear to me, but I believe that the issue has a better chance of prompt feedback, and described problem is important for me enough to put it here :) |
You would be better off using typescript eslint rules, which will just automatically work: https://typescript-eslint.io/docs/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors. |
The authors write:
|
@danielroe I know about this recommendation, but it can't be used here as I noticed in issue text, last paragraph. What if I want to use JS, not TS? Or if I migrate some project from JS to TS and it's obvious it can't be done in a single commit? Well, I turned off
But pure JS Currently I can't even apply different ESLint rules to And anyway, even if I can separate Also you skipped the section about components (with I understand the urge to say "just turn those rules off, write everything in TS and be happy", but migrating from JS to TS is a long process, and during this process components need to be maintained (even before they are rewritten to TS), and disabling rules during a transition increases the chance of errors |
@MorevM there is a discussion how to export auto imported functions for eslint here https://github.com/nuxt/framework/discussions/4607 |
We discussed this and think a good solution would be to write a file with components metadata based on setting an option in |
I don't know the relationship between nuxt and this plugin here https://github.com/antfu/unplugin-auto-import But if we add this config below on nuxt import configs will solve the globals issues eslintrc: {
enabled: false, // If we set this true is going to generate a file with all eslint globals
filepath: './.eslintrc-auto-import.json',
globalsPropValue: true,
}, |
Describe the feature
Hi, I'm not sure if this is a feature request or just a question, but I didn't find any related issues / docs.
Context:
I have an ESLint configuration and it contains rules
no-undef
andvue/no-undef-components
that report undeclared functions/variables/components.Nuxt automatically imports many things and I like it, I don't want to import them explicitly.
This is slightly related issue, but I don't need to import them explicitly, I need an option to retrieve a names of all auto-imported components/functions to declare them as global in
.eslintrc
file.My current workaround is define them manually and declare as global like that:
Although this is a working solution, there are some limitations:
@nuxt/image
) or new composables (such as@vueuse/nuxt
)nuxt.config.ts
viaimports.dirs
and create a new file inside it.So, a lot of manual work every time something was changed.
This can be done using custom module, but I believe it should be done by Nuxt itself.
Feature request:
Expose an auto-imported functions / components names to allow import them and mark as global in
.eslintrc
Additional info
I know it's recommended to disable
no-undef
for TypeScript at all, but currently, as far I know, there is no robust way to separate<script lang="ts">
and<script>
in ESLint confgurations for.vue
files.Also Nuxt isn't only TypeScript framework. and global components still needs to be configured
Additional information
Final checks
The text was updated successfully, but these errors were encountered: