microsoft / microsoft/TypeScript

[language server] Apply codefix to all files

Offen
#33,195 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

Search Terms

  • File is a CommonJS module; it may be converted to an ES6 module.
  • Apply codefixes to all files (vscode, visual studio code)
  • Convert all files from CommonJS to ES6

Suggestion

I would like to have some way to apply a specific codefix to all files in a directory. For example, convert a bunch of files from CommonJS format to the new ES6 module format using the codefix here.

Use Cases

I have a few hundred files in CommonJS module format that I want to convert to ES6 module syntax (export/import instead of exports/require).

Currently, my text editor (vscode) shows after some delay three dots at the top of the current file which, when hovered over with the mouse shows after a few more seconds delay a "quickFix" button that, when clicked, causes the current file to be converted. To convert all of my files with this method would take hours of tedious clicking.

I want some method of automating this process.

Examples

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit src/services/codefixes/convertToEs6Module.ts und verfolge, wie der TypeScript language server diesen Codefix in VS Code bereitstellt und anwendet. Ermittle das Design für die Auswahl eines Verzeichnisses und die Anwendung eines Codefixes auf alle darin enthaltenen Dateien; abgeschlossen ist die Aufgabe, wenn der angeforderte Codefix für alle anwendbaren Dateien automatisiert werden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript, vscode
Bereich
devtools
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.