Description
openedon Jul 26, 2023
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:
TypeScript/src/server/protocol.ts
Line 3487 in 3b45f4d
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.