Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Rule request: preferred-package-imports #422

Closed
JoshuaKGoldberg opened this issue Apr 18, 2018 · 3 comments
Closed

Rule request: preferred-package-imports #422

JoshuaKGoldberg opened this issue Apr 18, 2018 · 3 comments
Labels
External Issues that should be addressed in other repositories. Status: In Discussion Please continue discussing the proposed change before sending a pull request.
Milestone

Comments

@JoshuaKGoldberg
Copy link

Name proposal could probably be improved for such an unusual rule...

When there are two modules that declare variables with the same name, it's easy to mistakenly import from the wrong package:

import { action } from "mobx"; // this one?
import { action } from "mobx-safe"; // or this one?

A rule that lets projects map imports to their preferred package imports would help:

{
    "rules": {
        "preferred-package-imports": {
            "mobx-safe": {
                "action": {
                    "override": ["*"],
                    "reason": ["Technical mumbo jumbo..."]
                }
            }
        }
    }
}

Bonus points if this rule comes with an auto-fixer!

@HamletDRC
Copy link
Member

@JoshuaKGoldberg Your IDE is picking the wrong import, right?
It sounds like maybe we should try to extend this existing rule: https://palantir.github.io/tslint/rules/import-blacklist/

@JoshuaKGoldberg
Copy link
Author

I can try posting there!

@JoshuaKGoldberg JoshuaKGoldberg added Status: In Discussion Please continue discussing the proposed change before sending a pull request. External Issues that should be addressed in other repositories. labels Jul 5, 2018
@JoshuaKGoldberg
Copy link
Author

JoshuaKGoldberg commented Jul 5, 2018

palantir/tslint#3926

@JoshuaKGoldberg JoshuaKGoldberg modified the milestones: 5.0.4, 5.1.0 Jul 18, 2018
@JoshuaKGoldberg JoshuaKGoldberg added this to the None milestone Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Issues that should be addressed in other repositories. Status: In Discussion Please continue discussing the proposed change before sending a pull request.
Projects
None yet
Development

No branches or pull requests

2 participants