microsoft / microsoft/TypeScript
Allow files to be excluded from organizeImports
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Suggestion
🔍 Search Terms
- organizeImports
✅ 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
I use source.organizeImports as an automated action on save in VS Code. It works great for 99% of my files. However, for some files, it will break my application due to it being destructive. For the 1% of files it will break, I would like source.organizeImports to ignore them.
Would it be possible to add a feature where there is a way to exclude certain files from source.organizeImports to prevent it from running on files it will break?
Thank you!
📃 Motivating Example
In my web application, I have a main.js file that has imports that are not directly used, but needed by other files. The organizeImports feature removes these imports, which breaks my application.
💻 Use Cases
The only workaround for this is to either
- Not automatically run
organizeImportson save - Not edit files that
organizeImportswill break using VS Code - Use
sortImportsand lose the automated cleanuporganizeImportsprovides
None of these workarounds are ideal.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando l’azione source.organizeImports e il modo in cui seleziona i file per l’esecuzione automatizzata, quindi esamina il comportamento esistente di sortImports e organizeImports. Definisci un meccanismo di esclusione per i file selezionati e verifica che i file esclusi rimangano invariati, mentre gli altri file mantengano l’attuale comportamento di pulizia.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100