Skip to content

Set up Prettier#51

Merged
10xjs merged 1 commit intomasterfrom
prettier
Mar 15, 2018
Merged

Set up Prettier#51
10xjs merged 1 commit intomasterfrom
prettier

Conversation

@10xjs
Copy link
Copy Markdown
Contributor

@10xjs 10xjs commented Mar 15, 2018

Prettier takes code as input and spits out the same code with a prettier format.

It drops most the original styling and formats the code from its syntax tree, the output style is always consistent.

The npm run lint task asserts that all of the .js files match both the current eslint rules and are formatted correctly according to Prettier. It is necessary to run Prettier to reformat any new changes in-place before committing.

Run npm run format before committing to reformat any changed code, or configure your editor to automatically run Prettier as files are changed:

Sublime Text 3:

  • Install JsPrettier (there is not need to install prettier globally, the local dependency will be used)
  • Configure JsPrettier to auto format files on save:
  // ~/Library/Application Support/Sublime Text 3/Packages/User/JsPrettier.sublime-settings

  {
    "auto_format_on_save": true,
    "auto_format_on_save_excludes": [
      "*/package.json",
      "*/package-lock.json",
    ]
  }

Atom:

  • Install Prettier for Atom
  • Enable "format on save" (Packages → Prettier → Toggle Format on Save)

Prettier takes code as input and spits out the same code with a prettier format.

It drops most the original styling and formats the code from its syntax tree, the output style is always consistent.

The `npm run lint` task asserts that all of the `.js` files match both the current eslint rules and are formatted correctly according to Prettier. It is necessary to run Prettier to reformat any new changes in-place before committing.

Run `npm run format` before committing to reformat any changed code, _or_ configure your editor to automatically run Prettier as files are changed:

**Sublime Text 3:**
  - Install [JsPrettier](https://github.com/jonlabelle/SublimeJsPrettier) (there is not need to install `prettier` globally, the local dependency will be used)
  - Configure JsPrettier to auto format files on save:
  ```json
    // ~/Library/Application Support/Sublime Text 3/Packages/User/JsPrettier.sublime-settings

    {
      "auto_format_on_save": true,
      "auto_format_on_save_excludes": [
        "*/package.json",
        "*/package-lock.json",
      ]
    }
  ```

**Atom:**
 - Install [Prettier for Atom](https://atom.io/packages/prettier-atom)
 - Enable "format on save" (Packages → Prettier → Toggle Format on Save)
Copy link
Copy Markdown
Contributor

@izaakschroeder izaakschroeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@10xjs 10xjs merged commit 8436097 into master Mar 15, 2018
@10xjs 10xjs deleted the prettier branch March 15, 2018 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants