Stop adding code in format/lint, use code actions instead #980
Labels
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/feature
A request for a new feature.
kind/improvement
An improvement to existing feature and code.
tech/engines/formatter engine
Issue in the Formatter Engine
topic: code action
LSP code actions
topic: formatting
In this video I demonstrate how our formatter acts differently compared what formatting typically does:
recording.mp4
The user does manual work, removes the front sides of all relations. The user has set the formatter to be run on save. When we run it, we do a thing that a formatter should not do: we add the relations back because we forgot to remove the back-relations before saving/formatting.
What a formatter typically should do:
Whatever we want to do additionally, like missing relation fields, should be happen through a code action. This would then require the user to go on top of a relation field, and if we notice it doesn't have the other side available, we'd be showing a light bulb in the editor through the language server protocol, and offering code actions for the user.
Example:
The user has only defined one forward relation field, and presses the code action quick key on top of the relation attribute, listing available code actions:
We can also do this from the other side, with different options:
The text was updated successfully, but these errors were encountered: