I have a structure like:
/ham/egg/chips/index.js
/ham/egg/foo.js
then in /ham/egg/chips/index.js I sometimes have code that accidental ends up like:
import x from '../../egg/foo.js'
but I'd much rather it be:
import x from '../foo.js'
Ooo, nice. Yeah, that would be cool. Not sure what to call it, but would be a pretty straightforward rule. Would basically enforce that the path be the same as the path.relative(currentFile, importedFile).
Need a good name, though. shortest-path?
(edit: I initially misused path.resolve when I meant path.relative)
import/no-up-a-directory-then-down-the-same-directory ;)
Could also be an easy auto fix too
:+1:
no-extraneous-path / no-extraneous-relative-path?
@jfmengels ooo, I like [something]-relative-path. extraneous doesn't have the right connotation for this case, though, I think. #bikeshedding
shortest-relative-path?
I think extraneous fits, as you have extraneous "steps".
Otherwise no-superfluous, no-unneeded, no-unnecessary, ...
I'd be fine with shortest-relative-path too (though I dig it less than extraneous at the moment :smile: ).
I like extraneous
On 2 Aug 2016 21:52, "Jeroen Engels" [email protected] wrote:
I think extraneous fits, as you have extraneous "steps".
Otherwise no-superfluous, no-unneeded, no-unnecessary, ...I'd be fine with shortest-relative-path too (though I dig it less than
extraneous at the moment ๐ ).โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/benmosher/eslint-plugin-import/issues/471#issuecomment-237039703,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZQTNDFlwIECuF3AbHx0h1XGqT_jRGfks5qb63tgaJpZM4Ja5Zv
.
I guess I've just got other meaning primed for extraneous from the no-extraneous-deps issue discussion. Feels like this is something else to me. also no-extraneous-relative-path is a mouthful. (keyboardful?)
also also I don't love no- for this, I think because it's more enforcing a good thing (shorter path) than rejecting a bad thing (longer path).
I have weak and meandering enough opinions on this that I'm going to abstain from further name discussion. no-/extraneous-something is fine. ๐ค
I'm starting to like shortest-relative-path (I agree that extraneous is a mouthful). Maybe let me sleep on it :smile:
You can't use "relative" because it's redundant. All paths in node are
relative
On 2 Aug 2016 22:10, "Jeroen Engels" [email protected] wrote:
I'm starting to like shortest-relative-path (I agree that extraneous is a
mouthful). Maybe let me sleep on it ๐โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/benmosher/eslint-plugin-import/issues/471#issuecomment-237045080,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZQTEVUa8tipYDQVhvCsB4lfr0aeDpGks5qb7JJgaJpZM4Ja5Zv
.
NODE_PATH lets you around that. I'm fine with shortest-path but I think it's less obvious. #abstainfail
NODE_PATH and support for other non relative paths is being removed
https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md#521-removal-of-non-local-dependencies
On 2 Aug 2016 22:30, "Ben Mosher" [email protected] wrote:
NODE_PATH lets you around that. I'm fine with shortest-path but I think
it's less obvious. #abstainfailโ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/benmosher/eslint-plugin-import/issues/471#issuecomment-237050614,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZQTKFXv_49YOg4oX-At_WcMTRb2yRtks5qb7b5gaJpZM4Ja5Zv
.
You can't use "relative" because it's redundant. All paths in node are relative
External modules (things installed with npm for instance), internal modules (when you use Webpack) are not relative. Also, I'm pretty sure you can specify an absolute path.
NODE_PATH and support for other non relative paths is being removed
https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md#521-removal-of-non-local-dependencies
Does that also apply to require statements, or only import?
External modules are actually relative to the current module, they just go
up to the nearest node_modules dir. Absolute paths will never trigger this
issue
On 2 Aug 2016 22:39, "Jeroen Engels" [email protected] wrote:
You can't use "relative" because it's redundant. All paths in node are
relativeExternal modules (things installed with npm for instance), internal
modules (when you use Webpack) are not relative. Also, I'm pretty sure you
can specify an absolute path.โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/benmosher/eslint-plugin-import/issues/471#issuecomment-237053879,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZQTOnDelfmoh7knaWHvwojkUzEtu-cks5qb7krgaJpZM4Ja5Zv
.
Only import, but I presume everyone will switch to import/ whatever dynamic
module loading gets specified
On 2 Aug 2016 22:41, "Thomas Grainger" [email protected] wrote:
External modules are actually relative to the current module, they just go
up to the nearest node_modules dir. Absolute paths will never trigger this
issueOn 2 Aug 2016 22:39, "Jeroen Engels" [email protected] wrote:
You can't use "relative" because it's redundant. All paths in node are
relativeExternal modules (things installed with npm for instance), internal
modules (when you use Webpack) are not relative. Also, I'm pretty sure you
can specify an absolute path.โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/benmosher/eslint-plugin-import/issues/471#issuecomment-237053879,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZQTOnDelfmoh7knaWHvwojkUzEtu-cks5qb7krgaJpZM4Ja5Zv
.
@graingert mind blown.
I'd still like to see this implemented. If someone wants to have a go at it, let's go with no-extraneous-path as the name until someone has a good reason against it or a better name. But let the name not be a blocker for this nice idea.
@benmosher another aberration I've discovered in my travels:
import foo from './../foo';
which should of course be
import foo from '../foo';
@benmosher I've bike-sheded this a bit more, and think that no-useless-path-segments would be the best. To go with the other eslint "no-useless-" rules.
simplest-path?
simplest-local-path?
I'd like it to start with no- or no-useless-
no-useless-path-segments; see #912.
Most helpful comment
import/no-up-a-directory-then-down-the-same-directory ;)
Could also be an easy auto fix too