@sixfold/editor-config
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

editor-config

How to use Prettier

  1. Install the config and prettier:
yarn add @sixfold/editor-config prettier -D
  1. Add the following line in the target service's package.json:
"prettier": "@sixfold/editor-config/prettier"
  1. Add the following scripts to your package.json
  "prettier": "prettier \"./src/**/**\"",
  "prettier:check": "yarn prettier --check",
  "prettier:fix": "yarn prettier --write",
  1. Add a .prettierignore file at the source of the repository, containing at least the following:
package.json
.DS_Store

Make sure to include .prettierignore in your docker (test) if you check prettier formatting as part of the tests.

  1. Configure your IDE to use Prettier:
  • VS Code
  • WebStorm (Should be installed by default, but you need to configure it.)
  1. Add yarn prettier:check as part of the test or build script to ensure that code is consistently formatted

Using prettier config with prettier APIs

When generating code programmatically, same configuration can be used to format generated output:

import * as prettier from 'prettier';
import * as prettierConfig from '@sixfold/editor-config';

const source = 'function main(){console.log("Hello")};main()';

console.log(prettier.format(source, prettierConfig));

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @sixfold/editor-config

    Weekly Downloads

    1

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    7.86 kB

    Total Files

    6

    Last publish

    Collaborators

    • poolik
    • henri