Garo Gabrielyan
Garo Gabrielyan

Reputation: 673

WebStorm: use .prettierrc configurations for formatting

In WebStorm I want to use my custom configuration from .prettierrc file for code formatting.

It can change by the time I want to sync.

For example pressing Ctrl + Alt + P and Ctrl + Alt + L let my WebStorm formatting.

Upvotes: 0

Views: 5725

Answers (2)

Michał Szymański
Michał Szymański

Reputation: 354

If anyone wants to use configuration from other directory than root (let's say configs/.prettierrc), you can do this:

  1. In configs/.prettierrc change source config to .cjs file:
/** @type {import('prettier').Config} */
module.exports = {
    // ... your rules
};
  1. In root directory create another .prettierrc.cjs file and export source config from there:
module.exports = require("./configs/.prettierrc.cjs");

Restart IDE and that should do the trick.

Upvotes: 1

lena
lena

Reputation: 93868

Just place your .prettierrc in the project root and set up Prettier as the default formatter - this should do the thing

Upvotes: 2

Related Questions