-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
import/extensions breaks when a scoped package's scope is just @
#1598
Comments
|
Yeah, that seems to be an issue - If I change it to '../router', there is no error (If I use '../router.js', I get the "unexpected use of js" message) Not sure if a newer version would help, I hesitate to update, as there were issues with using the latest eslint / eslint-plugins and airbnb eslint plugins with Vue. Thanks. |
It's possible - there's unreleased stuff on master - but it's also possible that nobody expected an |
Ohhh I see what you mean by "@x"... I do have a lot of imports with just the @ - |
It's happening on other files too, and give errors when I build my vue app. As far as I see, using the @/ is normal for a vue application
|
Oh I wasn't suggesting permanently changing everything :-) just trying it out on one file to see if the problem you're reporting goes away. |
I ended up adding a rule to my eslint.js file to basically ignore it.. |
I’d appreciate it if you could try my suggestion; that would help make it an easy fix to help you, or anyone else with the same problem in the future. |
Oh sorry, thought I had mentioned it. When I did change it to be in the format of '@src/feedback', it seem to do the right thing (opposed to keep suggesting the opposite ("add a .js", or "missing .js") |
Great, thanks - that makes it straightforward to fix. |
@
I had the same issue even tho I had |
@ljharb since you added |
Based on this, https://github.com/benmosher/eslint-plugin-import/blob/b4d5fd38a29073e273523e262d7d59a7c48e30fe/src/rules/extensions.js#L114 Which it does a look up on patterns https://github.com/benmosher/eslint-plugin-import/blob/b4d5fd38a29073e273523e262d7d59a7c48e30fe/src/rules/extensions.js#L110 It doesn't work for use since Data input: { extension: '', importPath: '@/utils/i18n' } |
@yordis in general that label means "please submit a PR that takes care of this" :-) If that ends up with an answer of "configure it with an empty string for extension" then fine, but the issue i thought was that the "is scope" logic is not considering a scope of "@" |
@ljharb would you mind helping to understand why is that scope thing important? I am guessing you are talking about https://github.com/benmosher/eslint-plugin-import/blob/b4d5fd38a29073e273523e262d7d59a7c48e30fe/src/core/importType.js#L53 |
yes - i believe changing that regex from |
@ljharb confirmed, it fixes the issue |
@ljharb is there any possibility to release the changes to NPM sooner? 🙏 |
Sooner than when? I just released v2.20.1, so let's call it "sooner than tomorrow", and yes :-p |
@ljharb 😢 I forgot to finish the sentences 😭 English is hard Thanks a lot! Appreciated it. |
So far, this version looks like it's fixed the issue. I'll do some more testing but 👍 |
In a Vue application, using version with packages:
and an eslint.js of:
In a .vue file, when trying to do an import of a .js file, the eslint plugin can't decide if the .js extension is needed or not:
This:
import router from '@/router';
shows:
Missing file extension for "@/router"
If I change it to:
import router from '@/router.js';
I now get:
Unexpected use of file extension "js" for "@/router.js"
So which do you want?!?
FYI, the jsconfig.json is:
The text was updated successfully, but these errors were encountered: