Microsoft/TypeScript

Update import/export specifier sort on rename

Open

#57,975 opened on 2024幎3月27日

GitHub で芋る
 (7 comments) (1 reaction) (0 assignees)TypeScript (6,726 forks)batch import
Experience EnhancementHelp WantedSuggestion

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (平均マヌゞ 6d 17h) (30d で 9 merged PRs)

説明

🔍 Search Terms

organizeImports import sort rename

✅ Viability Checklist

⭐ Suggestion

Renaming an exported function that is imported as one of many named imports can make that list of import specifiers become unsorted. When we execute auto-imports, we try to detect how/whether an existing list of named imports is currently sorted and insert the new specifier in the correct spot. We could do something similar when updating an import or export specifier during a Rename command.

📃 Motivating Example

We have an eslint rule that enforces import sort order. I just renamed a function impliedNodeFormatForEmit to getImpliedNodeFormatForEmit, and afterwards I had to go fix the eslint rule failure in 6 different files. It would be nice not to have to do that.

💻 Use Cases

  1. What do you want to use this for? Easier refactoring that doesn't make linters mad
  2. What shortcomings exist with current approaches? They require me to do a lot of tedious clicking around
  3. What workarounds are you using in the meantime? A lot of tedious clicking around

コントリビュヌタヌガむド