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: no-extraneous-slashes #915

Closed
danny-andrews opened this issue Aug 16, 2017 · 6 comments
Closed

Rule proposal: no-extraneous-slashes #915

danny-andrews opened this issue Aug 16, 2017 · 6 comments

Comments

@danny-andrews
Copy link
Contributor

danny-andrews commented Aug 16, 2017

It would be nice to have a rule which catches extraneous slashes in paths. It could either be one rule: no-extraneous-slashes with options allowMultiple and allowTrailing (both defaulting to false) or two: no-multiple-slashes/no-trailing-slashes.

Fail

import blah from './src//util';
import React from 'react/';

Related to #557.

I'm leaning towards one rule.

@ljharb
Copy link
Member

ljharb commented Aug 16, 2017

"Multiple" would be handled by #912 (ie, ensuring the shortest path).

"Trailing" isn't safe, because './foo' and './foo/' might be very different modules, depending on if foo/index.js coexists with foo.js (and any other require.extensions) - so to implement that, the rule would have to check for any cases where the two things didn't resolve to the same path based on what's on disk.

However, #912's solution would presumably handle that as well, so I'm going to close this as a duplicate of #471.

@ljharb ljharb closed this as completed Aug 16, 2017
@danny-andrews
Copy link
Contributor Author

Sick! I found that PR first, but wasn't sure if it covered these cases.

@ljharb
Copy link
Member

ljharb commented Aug 16, 2017

If it doesn't, it should :-) i believe there is some existing discussion on it related to "trailing".

@graingert
Copy link
Contributor

It covers the // case. I've not fixed it to do the trailing slash... Yet

@wottpal
Copy link

wottpal commented Dec 12, 2023

It covers the // case. I've not fixed it to do the trailing slash... Yet

Should be probably reopened then?

@ljharb
Copy link
Member

ljharb commented Dec 12, 2023

@wottpal since that comment 6 years ago, the PR was adapted to include that, so no. If you have a problem with the latest version, please file a new issue.

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

No branches or pull requests

4 participants