-
-
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/no-extraneous-dependencies
and import/order
false postives since version 2.23
#2065
Comments
I'm having this same issue with |
@mlbiche for the |
@ljharb Here it is :
It is doing the same whenever there are two files at the same path with a common prefix. Before, the shortest one was considered first. |
Updated to
app.component.ts:7;
|
#2071 should fix the ordering issue. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Is the defect still present ? |
ah ok I see the problem. the problem is rxjs /operators/package.json exists with this content
So it isconsidered as an independent module, what is not the case... What can we do for this ? |
2.23 brought a number of breaking changes, including: - import/order `type` sorting: import-js/eslint-plugin-import#2070 - `import/no-extraneous-dependencies`: import-js/eslint-plugin-import#2065
That is the To find the root
Alternatively, the |
@paztis package.json files are only the root of an installed project when |
No, this is not true. I do this recursive search explicitely to support the. Monolithic repositories (multiple packages in one repository). Standards are 1 package.json for each delivreable |
In case we of monorepo, what is possible is to resolve the import file without resolving the symbolic links. Potentially this may also us to check the node_module path. We still have the case of scoped modules to verify |
Note that this in |
solution I propose in #2072 might resolve your problem. It's will be a little less strict on the imports but might be enough for these cases |
Disable the mentioned package from being managed by Renovate until import-js/eslint-plugin-import#2065 is fixed.
2.23 introduced import-js/eslint-plugin-import#2065, let's re-enable once that issue is fixed
@paztis i said an installed project. In other words, if you're inside a node_modules directory, then you're not in a monorepo, you're an npm-installed package, and the rule I described applies. |
2.23 introduced import-js/eslint-plugin-import#2065, let's re-enable once that issue is fixed
I really understand your problem. So when you resolve the filename of the imports, the resolver can give you the real path of the file that is not under node_modules. And as I can it control the resolvers as they are plugins of eslit-import (lot of plugins exist on nom), I won't just check if I'm under node module or not |
2.23 introduced import-js/eslint-plugin-import#2065, let's re-enable once that issue is fixed
@paztis yes, but the symlink will be realpathed, so the resulting paths won't be under node_modules. |
Either way, "supporting a monorepo" is of zero importance compared to "supporting normally installed dependencies", if there's a conflict between the two. |
Sorry but the only non standard thing here is the rocks module that produces abnormal package.json in its subfolders. Now I've propose you a solution that will resolve your errors. So do you want it or not ? |
Nested package.jsons aren't abnormal, they are an explicitly encouraged pattern with node's native ESM support. I'll take a look at your comment in #2072. |
To detect the module package from one package file, we're using read-pkg-up, downloaded 38 228 565 times on npm. |
Esm in node is really recent. Monorepo are older. |
Yes, if they're using read-pkg-up and stopping at the first package.json AND using it as the project root, then they all have this bug. Nested package.jsons aren't recent; node has always supported nested package.json files with a "main". The issue is that the closest package.json hasn't ever been guaranteed to be the package root, so that's the bug that needs fixing. |
From its readme:
To me, that's not a bug, but instead the expected behaviour. |
Of that package, absolutely. However, anyone naively using it to find the root package.json for a package is what has a bug. |
But, how to detect the actual package root? |
@piranna there isn't a robust way for things not inside a node_modules folder. There's reliable signals - if it has "exports", or "publishConfig", or "private", I'd call it top-level. If the repo has a ".git" directory, it's probably top-level. It'd be a heuristics-based approach. |
eslint-plugin-import bug import-js/eslint-plugin-import#2065
I am having this very same problem with Firebase imports. |
I've proposed a fix for extraneous-dependencies in PR #2097 |
did you list This issue happened mainly for sub module or sub files of module detected as individual module which is already resolved. While |
Oh, I didn't know about the scope thing at all. And I don't know why firebase is using separate modules as its own packages when it says it's not supposed to be used directly :D Anyways, all good when I removed the "@" and used Thanks for the info. |
Since the update to version 2.23, we have a lot of false positives in our project being part of two categories :
error 'rxjs/operators' should be listed in the project's dependencies. Run 'npm i -S rxjs/operators' to add it import/no-extraneous-dependencies
:rxjs/operators
is a sub-module ofrxjs
so I don't have to add it to project dependencies.*
error `@models/partner/partner-id` import should occur before import of `@models/partner/partner` import/order
: I can fix these issues, but it seems that the order has changed between two versions and I don not understand why and if it is on purpose ? I can not find mention to this in the changelogs.Cheers 🤙
The text was updated successfully, but these errors were encountered: