Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

tsserver feature: importModuleSpecifierPreference: "non-relative" but allow siblings #55160

Open
5 tasks done
llllvvuu opened this issue Jul 26, 2023 · 1 comment
Open
5 tasks done
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import Suggestion An idea for TypeScript

Comments

@llllvvuu
Copy link

Suggestion

πŸ” Search Terms

importModuleSpecifierPreference
allow sibling

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Let auto-imports mirror:
https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-parent-imports.md
or the old:
microsoft/tslint-microsoft-contrib#778

New option, could be named anything, "non-relative-allow-sibling", "no-parent", "relative-iff-sibling", etc

πŸ“ƒ Motivating Example

re: "why this feature improves the language", this is not a language feature, but an IDE feature which happens to be handled by TypeScript repo:

readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";

Motivating example: When you auto-import, you want to import as ./foo if in same directory, otherwise something like @/utils/foo. shortest doesn't necessarily work since ../foo could be shorter than e.g. @/modules/feature/foo

πŸ’» Use Cases

Currently using importModuleSpecifierPreference: "non-relative" as-is.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import labels Jul 26, 2023
@dmitri-gb
Copy link
Contributor

Duplicate of #48192 and #45015.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants