Microsoft/TypeScript

Update import/export specifier sort on rename

Open

#57,975 创建于 2024年3月27日

在 GitHub 查看
 (7 评论) (1 反应) (0 负责人)TypeScript (6,726 fork)batch import
Experience EnhancementHelp WantedSuggestion

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

🔍 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

贡献者指南