-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use absolute import paths (/foo) instead of relative (../../foo) ones #8190
Comments
As a not-developer, I would like to +100 this. It's especially confusing when sometimes there are multiple directories with the same name ( |
And a more extreme example: |
This issue has been open for a while, what next steps are needed to move it forward? Is it still an issue needing resolved? On the surface, here's some thoughts on what would need to happen:
Some considerations:
Absolute imports are attractive to me to get rid of the |
This is no longer an issue since Enzyme was upgraded to support React 16.3. There are still 2 places when files are imported by traversing to the top of repository and down:
Otherwise, all imports are within the package. I would personally check whether we can improve something for those 2 occurrences and close this issue. |
I agree. The problem in these cases is that we should be traversing outside a package's own files. Within the context of a package, there should not be much folder depth. Arguably, the relative traversal can serve as a deterrent in order to encourage a flatter folder structure. |
This started in https://wordpress.slack.com/archives/C02QB2JS7/p1531255855000083
We use relative import paths (
../../foo
) all over the place, but I think it makes it really difficult to reason about where the code is in the project and it makes it harder to open that file because you can't just copy the path and open it in your editor. The only real benefit is that it makes imports within a module self-contained, but as refactors happen less than wanting to open a related file, I think that's a weak argument for keeping relative imports. I find the cognitive overhead of stepping through a number of../
s to be high as well. Take, for instance, something like: https://github.com/WordPress/gutenberg/pull/8188/files#diff-4651e808991ae4dc4bd68adfb417d888R11I think we should be using absolute import paths everywhere.
The text was updated successfully, but these errors were encountered: