Skip to content
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

Rule proposal: warn when import uses ../ too many times #776

Closed
lencioni opened this issue Mar 23, 2017 · 3 comments
Closed

Rule proposal: warn when import uses ../ too many times #776

lencioni opened this issue Mar 23, 2017 · 3 comments

Comments

@lencioni
Copy link
Contributor

I'm not sure if there is a term for this, and describing it is a bit awkward, but I'll give it a shot.

Let's say you have a directory structure like:

/foo/bar/baz.js
/foo/bar/boop.js

In baz.js you want to import boop.js. Normally you would write it like this:

import boop from './boop';

However, if you aren't paying attention, especially when moving code around, you might end up doing something like this instead:

import boop from '../bar/boop';

Or in a more deeply nested structure, you might end up with something like this that overshoots its target:

import boop from '../../../bar/boop';

It would be really great to have a rule that warns against these.

@ljharb
Copy link
Member

ljharb commented Mar 23, 2017

Perhaps if a relative import path does not match path.normalize() of that path, it warns?

@danny-andrews
Copy link
Contributor

@ljharb Dupe of #471?

@ljharb
Copy link
Member

ljharb commented Aug 16, 2017

Indeed, this is a duplicate of #471.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants