Prettier is a tool to format .js, .ts, .css, .less, .scss, .vue, and .json code. With AppCode, you can format selected code fragments as well as entire files or directories using the Reformat with Prettier action. AppCode adds this action as soon as you install Prettier as a dependency in your project or globally on your computer.
Before you start
To install Prettier
npm install --save-dev --save-exact prettier
npm install --global prettier
Learn more about installation modes from the Prettier official website.
To configure Prettier in AppCode
On the Prettier page, that opens, specify the path to the prettier package and choose the Node.js interpreter to use. If you choose the Project alias, AppCode will automatically use the project default interpreter from the Node interpreter field on the Node.js and NPM page.
In most cases, AppCode detects the project default interpreter and fills in the field itself. You can also choose another configured local interpreter or click and configure a new one.
To reformat code with Prettier
AppCode can apply the key code style rules from the Prettier's configuration to the AppCode Code Style settings so that generated code (for example, after refactoring or quick-fix) and the code that is already processed with Prettier are formatted consistently.
To apply Prettier code style rules
In the project where Prettier is enabled, open package.json and click Yes in the pane at the top of the tab.
To re-apply the Prettier code style (after you've clicked No in the pane or modified the code style), press ⇧⌘A and select Apply Prettier Code Style Rules from the Find Action list.