Skip to content

Commit

Permalink
Release 1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Jan 20, 2019
1 parent a9fd8e2 commit 3a5fc65
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Tip! Don't write this stuff manually.
-->

**Prettier 1.15.3**
**Prettier 1.16.0**
[Playground link](https://prettier.io/playground/#.....)
```sh
# Options (if any):
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BEFORE SUBMITTING AN ISSUE:
-->

**Environments:**
- Prettier Version: 1.15.3
- Prettier Version: 1.16.0
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
- Runtime: <!-- Node.js v6, Chrome v67, etc. -->
- Operating System: <!-- Windows, Linux, macOS, etc. -->
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.16.0

[diff](https://github.com/prettier/prettier/compare/1.15.3...1.16.0)

🔗 [Release Notes](https://prettier.io/blog/2019/01/20/1.16.0.html)

# 1.15.3

[diff](https://github.com/prettier/prettier/compare/1.15.2...1.15.3)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "1.16.0-dev",
"version": "1.16.0",
"description": "Prettier is an opinionated code formatter",
"bin": {
"prettier": "./bin/prettier.js"
Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-stable/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const prettier = require("prettier");
`format` is used to format text using Prettier. [Options](options.md) may be provided to override the defaults.

```js
prettier.format("foo ( );", { semi: false, parser: "babylon" });
prettier.format("foo ( );", { semi: false, parser: "babel" });
// -> "foo()"
```

## `prettier.check(source [, options])`

`check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`. This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
`check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`. This is similar to the `--check` or `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.

## `prettier.formatWithCursor(source [, options])`

Expand All @@ -28,7 +28,7 @@ prettier.format("foo ( );", { semi: false, parser: "babylon" });
The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`.

```js
prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babylon" });
prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" });
// -> { formatted: '1;\n', cursorOffset: 1 }
```

Expand Down Expand Up @@ -131,8 +131,8 @@ Prettier's built-in parsers are exposed as properties on the `parsers` argument.

```js
prettier.format("lodash ( )", {
parser(text, { babylon }) {
const ast = babylon(text);
parser(text, { babel }) {
const ast = babel(text);
ast.program.body[0].expression.callee.name = "_";
return ast;
}
Expand Down
34 changes: 34 additions & 0 deletions website/versioned_docs/version-stable/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ Don't forget the quotes around the globs! The quotes make sure that Prettier exp

Prettier CLI will ignore files located in `node_modules` directory. To opt-out from this behavior use `--with-node-modules` flag.

## `--check`

When you want to check if your files are formatted, you can run Prettier with the `--check` flag (or `-c`).
This will output a human-friendly message and a list of unformatted files, if any.

```bash
prettier --check "src/**/*.js"
```

Console output if all files are formatted:

```
Checking formatting...
All matched files use Prettier code style!
```

Console output if some of the files require re-formatting:

```
Checking formatting...
src/fileA.js
src/fileB.js
Code style issues found in the above file(s). Forgot to run Prettier?
```

The command will return exit code 1 in the second case, which is helpful inside the CI pipelines.
Human-friendly status messages help project contributors react on possible problems.
To minimise the number of times `prettier --check` finds unformatted files, you may be interested in configuring a [pre-commit hook](precommit.md) in your repo.
Applying this practice will minimise the number of times the CI fails because of code formatting problems.

If you need to pipe the list of unformatted files to another command, you can use [`--list-different`](cli.md#list-different) flag instead of `--check`.

## `--debug-check`

If you're worried that Prettier will change the correctness of your code, add `--debug-check` to the command. This will cause Prettier to print an error message if it detects that code correctness might have changed. Note that `--write` cannot be used with `--debug-check`.
Expand Down Expand Up @@ -73,6 +105,8 @@ Another useful flag is `--list-different` (or `-l`) which prints the filenames o
prettier --single-quote --list-different "src/**/*.js"
```

You can also use [`--check`](cli.md#check) flag, which works the same way as `--list-different`, but also prints a human-friendly summary message to stdout.

## `--no-config`

Do not look for a configuration file. The default settings will be used.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ For example, to get Prettier to format its own `.prettierrc` file, you can do:
}
```

You can also switch to the `flow` parser instead of the default `babylon` for .js files:
You can also switch to the `flow` parser instead of the default `babel` for .js files:

```json
{
Expand Down
7 changes: 4 additions & 3 deletions website/versioned_docs/version-stable/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ Specify which parser to use.

Prettier automatically infers the parser from the input file path, so you shouldn't have to change this setting.

Both the `babylon` and `flow` parsers support the same set of JavaScript features (including Flow type annotations). They might differ in some edge cases, so if you run into one of those you can try `flow` instead of `babylon`.
Both the `babel` and `flow` parsers support the same set of JavaScript features (including Flow type annotations). They might differ in some edge cases, so if you run into one of those you can try `flow` instead of `babel`.

Valid options:

- `"babylon"` (via [@babel/parser](https://github.com/babel/babel/tree/master/packages/babel-parser))
- `"babel"` (via [@babel/parser](https://github.com/babel/babel/tree/master/packages/babel-parser)) _Named `"babylon"` until v1.16.0_
- `"babel-flow"` (Same as `"babel"` but enables Flow parsing explicitly to avoid ambiguity) _First available in v1.16.0_
- `"flow"` (via [flow-parser](https://github.com/facebook/flow/tree/master/src/parser))
- `"typescript"` (via [typescript-estree](https://github.com/JamesHenry/typescript-estree)) _First available in v1.4.0_
- `"css"` (via [postcss-scss](https://github.com/postcss/postcss-scss) and [postcss-less](https://github.com/shellscape/postcss-less), autodetects which to use) _First available in v1.7.1_
Expand Down Expand Up @@ -311,7 +312,7 @@ If you want to make sure that your git repository only contains Linux-style line

1. Set `endOfLine` option to `lf`
1. Configure [a pre-commit hook](precommit.md) that will run Prettier
1. Configure Prettier to run in your CI pipeline (e.g. using [`prettier-check` npm package](https://www.npmjs.com/package/prettier-check))
1. Configure Prettier to run in your CI pipeline using [`--check` flag](cli.md#check)
1. Ask Windows users to run `git config core.autocrlf false` before working on your repo so that git did not convert `LF` to `CRLF` on checkout.
Alternatively, you can add `* text=auto eol=lf` to the repo's `.gitattributes` file to achieve this.

Expand Down
1 change: 1 addition & 0 deletions website/versioned_docs/version-stable/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Providing at least one path to `--plugin-search-dir`/`pluginSearchDirs` turns of
- [`prettier-plugin-java`](https://github.com/thorbenvh8/prettier-java) by [**@thorbenvh8**](https://github.com/thorbenvh8)
- [`prettier-plugin-pg`](https://github.com/benjie/prettier-plugin-pg) by [**@benjie**](https://github.com/benjie)
- [`prettier-plugin-ruby`](https://github.com/iamsolankiamit/prettier-ruby) by [**@iamsolankiamit**](https://github.com/iamsolankiamit)
- [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)

## Developing Plugins

Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-stable/precommit.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ Alternately you can save this script as `.git/hooks/pre-commit` and give it exec

```bash
#!/bin/sh
jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" | tr '\n' ' ')
[ -z "$jsfiles" ] && exit 0
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

# Prettify all staged .js files
echo "$jsfiles" | xargs ./node_modules/.bin/prettier --write
# Prettify all selected files
echo "$FILES" | xargs ./node_modules/.bin/prettier --write

# Add back the modified/prettified files to staging
echo "$jsfiles" | xargs git add
echo "$FILES" | xargs git add

exit 0
```
Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-stable/webstorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ For older IDE versions, please follow the instructions below.

To automatically format your files using `prettier` on save, you can use a [File Watcher](https://plugins.jetbrains.com/plugin/7177-file-watchers).

In the _Settings/Preferences_ dialog (`⌘,` on Mac or `Ctrl+Alt+S` on Windows and Linux), click **File Watchers** under **Tools** and click **+** to add a new watcher.
Go to _Preferences | Tools | File Watchers_ and click **+** to add a new watcher.

Select Prettier from the list, review the configuration, add any additional arguments if needed, and click OK.
In Webstorm 2018.2, select Prettier from the list, review the configuration, add any additional arguments if needed, and click OK.

In older IDE versions, select Custom and do the following configuration:

Expand All @@ -41,11 +41,11 @@ In older IDE versions, select Custom and do the following configuration:

If you are using ESLint with [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier), use the `Fix ESLint Problems` action to reformat the currect file – find it using _Find Action_ (`Cmd/Ctrl-Shift-A`) or [add a keyboard shortcut](https://www.jetbrains.com/help/webstorm/configuring-keyboard-shortcuts.html) to it in _Preferences | Keymap_ and then use it.

Make sure that the ESLint integration is enabled in the _Settings/Preferences_ dialog (`⌘,` on Mac or `Ctrl+Alt+S` on Windows) click **ESLint** under **Languages & Frameworks | JavaScript | Code Quality Tools**
Make sure that the ESLint integration is enabled in _Preferences | Languages & Frameworks | JavaScript | Code Quality Tools | ESLint_.

### Using Prettier as External Tool

In the _Settings/Preferences_ dialog (`⌘,` on Mac or `Ctrl+Alt+S` on Windows and Linux) click **External Tools** under **Tools** and click **+** to add a new tool. Let’s name it **Prettier**.
Go to _Preferences | Tools | External Tools_ and click **+** to add a new tool. Let’s name it **Prettier**.

- **Program**: `prettier` on macOS and Linux or `C:\Users\user_name\AppData\Roaming\npm\prettier.cmd` on Windows (or whatever `npm prefix -g` returns), if Prettier is installed globally
- **Parameters**: `--write [other options] $FilePathRelativeToProjectRoot$`
Expand All @@ -59,4 +59,4 @@ Press `Cmd/Ctrl-Shift-A` (_Find Action_), search for _Prettier_, and then hit `E

It will run `prettier` for the current file.

You can [add a keyboard shortcut](https://www.jetbrains.com/help/webstorm/configuring-keyboard-shortcuts.html) to run this External tool configuration in the _Settings/Preferences_ dialog (`⌘,` on Mac or `Ctrl+Alt+S` on Windows and Linux) click **Keymap**.
You can [add a keyboard shortcut](https://www.jetbrains.com/help/webstorm/configuring-keyboard-shortcuts.html) to run this External tool configuration in _Preferences | Keymap_.

0 comments on commit 3a5fc65

Please sign in to comment.