-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Cannot resolve await import('https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js');
#3118
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
Comments
Duplicate of #3107 |
Can you try running with |
Sure
|
Also it happens using classic syntax too w/ the URL @ https://github.com/KudoAI/kudoai.com/blob/78a93d41671059713d26d081bb5a00d368311a1f/assets/js/matrix-bg.js#L1 import * as datGui from 'https://cdn.skypack.dev/[email protected]' |
For that one it strangely tries multiple times
|
This isn’t surprising because node doesn’t support importing URLs. To resolve something with a URL, you’d need a custom resolver. (also, don’t use CDNs; always host your own assets) |
So your plugin being marketed as "help validate proper imports," and https://github.com/KudoAI/kudoai.com/blob/78a93d41671059713d26d081bb5a00d368311a1f/assets/js/matrix-bg.js#L1 import * as datGui from 'https://cdn.skypack.dev/[email protected]' ...is valid JS import (properly resolves to help generate matrix code background @ https://kudoai.com) means your plugin should be expected to also lint URL imports like this successfully regardless of what node supports right, or are you only targeting node users (also I intend to convert my other frontend pkgs like chatgpt.js to be node compatible eventually, then there will be
I'm not rich sir <3 free jsDelivr (but I kinda agree when they go down my so many users are rekt) |
No, it’s not a valid JS import, it’s a valid browser import, which we don’t support. |
Browser is not a language though, it is JS syntax (ES6) for 9 years and correctly resolved the resource so is valid JavaScript import and ESLint was made to lint JS (regardless of env) so I thought your plugin enhances the linter you're plugging into thus adheres to same principle of supporting all valid JS , but you have confirmed I am wrong (which is why I asked are you targeting node users only, again browser users also write in valid JS, but now I know the answer) |
The syntax is valid - but the spec doesn't talk about the specifier, and the URL comes from the WHATWG HTML specification, not the ecma-262 JavaScript specification. |
If it's valid syntax as you admit then it's valid JS import (JS literally means JavaScript, not what specifier is passed) which all ESLint plugins lint (regardless of env) except for yours. The spec not discussing specifier (syntax is ES6 btw not ECMA-262, valid for 9 years already as previously stated, much older than you're falsely suggesting 1 year) does not change this fact valid JS is being written. ESLint (+ JSLint) and its plugins effectively analyze JS regardless of the env. Yours simply doesn't. Also you should reflect on your crude labeling of JS in Node.js as "JS import" but JS in browser as not. They're both written in JS, you can't call one not. Before Node.js ever gained popularity JS was being written since the 90s, specifically for browsers. You can even pass relative paths as specifiers in both envs using the exact same valid JS syntax, so it's absurd to only call one of them JavaScript |
The contents of the string specifier aren’t part of JS, no. The syntax you’re using of course is, but that’s not where your problem lies. You’re asking about resolving a URL, which is browser-specific territory and not governed by the JS spec whatsoever. I didn’t say anything about a year; I’m very aware how the spec works having been on the spec committee for a decade. I understand that you’re upset, but this project simply does not resolve URLs, and never intended nor intends to, and if you want that feature, you’ll have to find your own custom import resolver (which is discussed in the readme). |
The problem lies on the fact you actively chose not to support resolving URLs as specifiers in perfectly valid JS, thus you are targeting node users only as I suspected (whereas other plugins target all valid JS)
That's not true, I asked are you only targeting node users, and if so, I understand you are not supporting perfectly valid JS in browsers (where imports also resolve URLs as a bonus) which is what ESLint plugins are supposed to lint, thus you don't lint all valid JS (unlike every other plugin) then I might even seek (or build) a plugin that does
You called the syntax ECMA-262 (2023) which is wrong it's from ES6 (2015) though
I'm not upset it's disbelief at things you said
I know you don't resolve URLs, I was pointing out you are ignoring valid JS (unlike every other plugin) + mislabeling it as invalid JS + falsely suggesting it was 1y old only |
“all valid JS” is impossible to target, because there’s infinite possibilities. Supporting URLs is just browsers (and deno, i suppose). |
Nobody said 1 year? Ecma-262 is the standard that comes out with a new edition every year, and is an umbrella term for “every version of JS ever”. |
But you dismiss it as "just" browsers even after acknowledging JS for browsers preceded Node.js, so why ignore such a large portion of valid JS? |
i.e. if you install any random ESLint plugin it will work with browser JS (of which alot of code is) so one would expect the same for yours for carrying the 'eslint-' prefix. You earlier cited WHATWG HTML spec but I didn't get why, are you saying that makes it difficult for you to support browser JS, or that it's still easy but the spec made you decide browser JS (of which alot of code is) is somehow undeserving of same treatment |
Or you meant just because the specifier wasn't in ES specs, the whole statement (valid in browser JS, of which alot of code is and ESLint plugins typically support) should not be supported (regardless of ease of implementation), if so how ccome |
I'm saying that the only place "importing URLs" is specified is in the browser-only WHATWG HTML spec. So yes, URLs are simply not part of the JS language. They're part of some JS engines which is an entirely distinct thing. If you read the readme, you should be able to understand that this plugin doesn't include resolution rules, it uses one or more "resolvers". You can use the node resolver, or the webpack resolver; there's a typescript resolver, and potentially even a URL resolver - in other words, it's not this plugin's job to resolve URLs, it's an import resolver's job to do so. |
It is highly relevant in that ESLint (and its plugins) lint JS to make it better agnostically of env (i.e. including/especially pre-node code) and you also carry the banner in the plugin's name, so are creating that expectation of lint JS (including/especially pre-node code) just like ESLint and its plugins
So what? The specifier varying by JS env does not change the fact valid JS was used by authors who look to ESLint (and plugins) to improve JS codebases. That's like saying browsers support Even your earlier "This isn’t surprising because node doesn’t support importing URLs" revealed to me it was likely intentional you don't treat imports outside node as deserving of ESLinting. Using same analogy, that is equivalent to someone revealing
But your plugin is called "eslint-plugin-import" not "eslint-plugin-node-import" whose naming convention implies lint the word after "eslint-plugin-" (which is imports not node imports), so if it can't resolve URLs in all imports then it's failing to perform its described job (not resolver's job) of "help validate proper imports" (not "help validate proper node imports" as you wote the former and named it ending in -imports) And from your earlier mislabeling of this 100% valid and proper import as somehow "not proper JS import" I understand why you actively chose not to support it, all I'm trying to get you to see it's actually very proper/valid JS import because it is syntactically valid JS that just happens to resolve a bonus type of specifier of URLs in a specific env supported by probably every ESLint plugin and yours is called eslint-plugin-something so your your description is misleading unless you change it to "in some envs" or "in Node.js" or implement URL resolver out-the-box or something |
Also it will probably false positive even not URLs but just any relative path when used in browser but not in node, despite it actually resolves in both envs, so your logic one is somehow proper JS but the other is not is very strange (the code is identical) reason to not support one but do for other |
You completely missed his point here. He's explaining to you that the plugin is intended to be flexible enough to support a wide range of resolution algorithms. Those resolution algorithms are encapsulated as "import resolvers". So you can plug and play different resolvers with this plugin to achieve different results. There's the default node resolver, there's a typescript resolver, etc. So if you really want the behavior that you're so passionately and endlessly arguing about, you're able to build a resolver that meets your needs and still use this plugin. |
https://github.com/adamlui/js-utils/blob/23b8bbb60944f8207e9793ad3ec021ffedb39f9e/geolocate/src/geolocate.js#L23
results in
error Unable to resolve path to module 'https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js' import/no-unresolved
The text was updated successfully, but these errors were encountered: