Skip to content

Add noUselessIndex to no-useless-path-segments #72

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

Merged
merged 5 commits into from
Jan 7, 2022
Merged

Conversation

rajsite
Copy link
Member

@rajsite rajsite commented Nov 16, 2021

Justification

Found code that was mixing usages of index imports and directory imports.

For example with the following npm package file structure:

- src
  - awesome
    - index.ts
  - other.ts

Some imports within the library would use import './awesome'; while others used import './awesome/index';.

In es6 modules world those resolve to two different absolute paths, ie C:/lib/src/awesome vs C:/lib/src/awesome/index so tooling that may not be aware of commonjs file resolution may treat them as different symbols. This is not a concern in modern versions of tooling that I have seen but enforcing the consistency seems useful anyway for readability.

This PR copies the exisiting airbnb rule for import/no-useless-path-segments and adds the noUselessIndex configuration.

@rajsite rajsite merged commit 975043b into main Jan 7, 2022
@rajsite rajsite deleted the no-useless-index branch January 7, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants