import-js / import-js/eslint-plugin-import

Rule proposal: no-relative-path

Open
#669 5 comments 24 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rule proposal
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

In larger projects I've noticed an increasing trend in using packages like [module-alias](https://www.npmjs.com/package/module-alias) to avoid using relative paths all together.

I work mostly in React based projects and it's very common to reuse components all over your application, making deeply nested relative paths a common problem.
But once an alias is used I've noticed that it's easy to forget using them because writing `import './Something'` is faster than the full aliased path.

That's why I think adding a rule that disable relative paths all together would be useful for projects that have aliasing in place.

I want to open a discussion about it first, and if you guys are busy with other stuff I'd be happy to submit a PR on it if you think this rule would make sense.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Issue #669 proposes a new ESLint rule for the eslint-plugin-import repository. Review existing import rules and their tests first, then determine how the rule should identify and report relative paths; done means the proposal has an agreed scope and coverage for the expected import forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.