Generate TypeScript code according to Prettier rules

I'm using Prettier to format my code and IntelliJ is able to reformat code thanks to the Prettier plug-in. But if IntelliJ generates TypeScript code, for example when an import is added, it is not formatted according to the Prettier rules. I've to explicitly reformat the code each time, what is pretty annoying.

Is there a way to configure IntelliJ so that it generates code according to the prettier rules?

Comment actions Permalink

IDEA normally prompts you to import code style preferences from Prettier:


You can also use Apply Prettier Code Style Rules in the .prettierrc right-click menu to import preferences:

But, please, note that applying code style settings won't cause the IDE's 'Reformat Code' to match Prettier's code style exactly. Prettier is an opinionated formatter without a spec, with stylistic changes introduced in patch releases.

We import code style settings to the IDE to configure basic features like indent size to be used on Enter.
If you want the formatting to match exactly, use the 'Reformat With Prettier' action (described in a blog post)

Comment actions Permalink

Thanks for your reply. If I remember correctly, I've accepted the suggestion "Use code style based on Prettier for this project", and now I've clicked "Apply Prettier Code Style Rules" from the context menu, as you suggested. However if I let IntelliJ generate a method to implement an interface for example, I get code not in line with the Prettier rules. For example IntelliJ adds semicolons, while Prettier removes them.

Is this the behavior I should expect? If so, it would be nice if IntelliJ would try to come closer to the style Prettier would produce.

Comment actions Permalink

>Is this the behavior I should expect? 

yes, it's expected

You can set Semicolons to Don't use in Settings | Editor | Code Style | TypeScript | Punctuation if you don't like semicolons being generated


Please sign in to leave a comment.