Skip to content

Commit

Permalink
Release 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Nov 13, 2023
1 parent 6a1d409 commit e8ac9f8
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/formatting.md
Expand Up @@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you:
-->

**Prettier 3.0.3**
**Prettier 3.1.0**
[Playground link](https://prettier.io/playground/#.....)

```sh
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/integration.md
Expand Up @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:

**Environments:**

- Prettier Version: 3.0.3
- Prettier Version: 3.1.0
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
- Runtime: <!-- Node.js v14, Chrome v83, etc. -->
- Operating System: <!-- Windows, Linux, macOS, etc. -->
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
# 3.1.0

[diff](https://github.com/prettier/prettier/compare/3.0.3...3.1.0)

🔗 [Release Notes](https://prettier.io/blog/2023/11/13/3.1.0.html)

# 3.0.3

[diff](https://github.com/prettier/prettier/compare/3.0.2...3.0.3)
Expand Down
32 changes: 16 additions & 16 deletions docs/browser.md
Expand Up @@ -18,7 +18,7 @@ Required options:

- **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use.

- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.0.3/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.1.0/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.

You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.

Expand All @@ -29,8 +29,8 @@ See below for examples.
### Global

```html
<script src="https://unpkg.com/prettier@3.0.3/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.0.3/plugins/graphql.js"></script>
<script src="https://unpkg.com/prettier@3.1.0/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.1.0/plugins/graphql.js"></script>
<script>
(async () => {
const formatted = await prettier.format("type Query { hello: String }", {
Expand All @@ -47,8 +47,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.0.3/plugins/graphql.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.1.0/plugins/graphql.mjs";
const formatted = await prettier.format("type Query { hello: String }", {
parser: "graphql",
Expand All @@ -61,8 +61,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack

```js
define([
"https://unpkg.com/prettier@3.0.3/standalone.js",
"https://unpkg.com/prettier@3.0.3/plugins/graphql.js",
"https://unpkg.com/prettier@3.1.0/standalone.js",
"https://unpkg.com/prettier@3.1.0/plugins/graphql.js",
], async (prettier, ...plugins) => {
const formatted = await prettier.format("type Query { hello: String }", {
parser: "graphql",
Expand Down Expand Up @@ -90,8 +90,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
### Worker

```js
importScripts("https://unpkg.com/prettier@3.0.3/standalone.js");
importScripts("https://unpkg.com/prettier@3.0.3/plugins/graphql.js");
importScripts("https://unpkg.com/prettier@3.1.0/standalone.js");
importScripts("https://unpkg.com/prettier@3.1.0/plugins/graphql.js");

(async () => {
const formatted = await prettier.format("type Query { hello: String }", {
Expand All @@ -107,9 +107,9 @@ If you want to format [embedded code](options.md#embedded-language-formatting),

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.0.3/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.0.3/plugins/estree.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.0/plugins/estree.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
Expand All @@ -125,10 +125,10 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.0.3/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.0.3/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.0.3/plugins/html.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.0/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.1.0/plugins/html.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "3.1.0-dev",
"version": "3.1.0",
"description": "Prettier is an opinionated code formatter",
"bin": "./bin/prettier.cjs",
"repository": "prettier/prettier",
Expand Down
16 changes: 8 additions & 8 deletions website/versioned_docs/version-stable/api.md
Expand Up @@ -34,9 +34,9 @@ await prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" });
// -> { formatted: '1;\n', cursorOffset: 1 }
```

## `prettier.resolveConfig(filePath [, options])`
## `prettier.resolveConfig(fileUrlOrPath [, options])`

`resolveConfig` can be used to resolve configuration for a given source file, passing its path as the first argument. The config search will start at the file path and continue to search up the directory (you can use `process.cwd()` to start searching from the current directory). Or you can pass directly the path of the config file as `options.config` if you don’t wish to search for it. A promise is returned which will resolve to:
`resolveConfig` can be used to resolve configuration for a given source file, passing its path or url as the first argument. The config search will start at the file location and continue to search up the directory (you can use `process.cwd()` to start searching from the current directory). Or you can pass directly the path of the config file as `options.config` if you don’t wish to search for it. A promise is returned which will resolve to:

- An options object, providing a [config file](configuration.md) was found.
- `null`, if no file was found.
Expand All @@ -58,7 +58,7 @@ If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editor
- `indent_size`/`tab_width`
- `max_line_length`

## `prettier.resolveConfigFile([filePath])`
## `prettier.resolveConfigFile([fileUrlOrPath])`

`resolveConfigFile` can be used to find the path of the Prettier configuration file that will be used when resolving the config (i.e. when calling `resolveConfig`). A promise is returned which will resolve to:

Expand All @@ -67,7 +67,7 @@ If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editor

The promise will be rejected if there was an error parsing the configuration file.

The search starts at `process.cwd()`, or at `filePath` if provided. Please see the [cosmiconfig docs](https://github.com/davidtheclark/cosmiconfig#explorersearch) for details on how the resolving works.
The search starts at `process.cwd()`, or at `fileUrlOrPath` if provided. Please see the [lilconfig docs](https://github.com/antonk52/lilconfig) for details on how the resolving works.

```js
const configFile = await prettier.resolveConfigFile(filePath);
Expand All @@ -78,7 +78,7 @@ const configFile = await prettier.resolveConfigFile(filePath);

When Prettier loads configuration files and plugins, the file system structure is cached for performance. This function will clear the cache. Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.

## `prettier.getFileInfo(filePath [, options])`
## `prettier.getFileInfo(fileUrlOrPath [, options])`

`getFileInfo` can be used by editor extensions to decide if a particular file needs to be formatted. This method returns a promise, which resolves to an object with the following properties:

Expand All @@ -89,11 +89,11 @@ When Prettier loads configuration files and plugins, the file system structure i
}
```

The promise will be rejected if the type of `filePath` is not `string`.
The promise will be rejected if the type of `fileUrlOrPath` is not `string` or `URL`.

Setting `options.ignorePath` (`string | string[]`) and `options.withNodeModules` (`boolean`) influence the value of `ignored` (`false` by default).
Setting `options.ignorePath` (`string | URL | (string | URL)[]`) and `options.withNodeModules` (`boolean`) influence the value of `ignored` (`false` by default).

If the given `filePath` is ignored, the `inferredParser` is always `null`.
If the given `fileUrlOrPath` is ignored, the `inferredParser` is always `null`.

Providing [plugin](plugins.md) paths in `options.plugins` (`string[]`) helps extract `inferredParser` for files that are not supported by Prettier core.

Expand Down
32 changes: 16 additions & 16 deletions website/versioned_docs/version-stable/browser.md
Expand Up @@ -19,7 +19,7 @@ Required options:

- **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use.

- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.0.3/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.1.0/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.

You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.

Expand All @@ -30,8 +30,8 @@ See below for examples.
### Global

```html
<script src="https://unpkg.com/prettier@3.0.3/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.0.3/plugins/graphql.js"></script>
<script src="https://unpkg.com/prettier@3.1.0/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.1.0/plugins/graphql.js"></script>
<script>
(async () => {
const formatted = await prettier.format("type Query { hello: String }", {
Expand All @@ -48,8 +48,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.0.3/plugins/graphql.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.1.0/plugins/graphql.mjs";
const formatted = await prettier.format("type Query { hello: String }", {
parser: "graphql",
Expand All @@ -62,8 +62,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack

```js
define([
"https://unpkg.com/prettier@3.0.3/standalone.js",
"https://unpkg.com/prettier@3.0.3/plugins/graphql.js",
"https://unpkg.com/prettier@3.1.0/standalone.js",
"https://unpkg.com/prettier@3.1.0/plugins/graphql.js",
], async (prettier, ...plugins) => {
const formatted = await prettier.format("type Query { hello: String }", {
parser: "graphql",
Expand Down Expand Up @@ -91,8 +91,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
### Worker

```js
importScripts("https://unpkg.com/prettier@3.0.3/standalone.js");
importScripts("https://unpkg.com/prettier@3.0.3/plugins/graphql.js");
importScripts("https://unpkg.com/prettier@3.1.0/standalone.js");
importScripts("https://unpkg.com/prettier@3.1.0/plugins/graphql.js");

(async () => {
const formatted = await prettier.format("type Query { hello: String }", {
Expand All @@ -108,9 +108,9 @@ If you want to format [embedded code](options.md#embedded-language-formatting),

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.0.3/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.0.3/plugins/estree.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.0/plugins/estree.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
Expand All @@ -126,10 +126,10 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser

```html
<script type="module">
import * as prettier from "https://unpkg.com/prettier@3.0.3/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.0.3/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.0.3/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.0.3/plugins/html.mjs";
import * as prettier from "https://unpkg.com/prettier@3.1.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.0/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.1.0/plugins/html.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/configuration.md
Expand Up @@ -4,7 +4,7 @@ title: Configuration File
original_id: configuration
---

Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support. This means you can configure Prettier via (in order of precedence):
Prettier uses [lilconfig](https://github.com/antonk52/lilconfig) for configuration file support. This means you can configure Prettier via (in order of precedence):

- A `"prettier"` key in your `package.json` file.
- A `.prettierrc` file written in JSON or YAML.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/ignore.md
Expand Up @@ -25,7 +25,7 @@ coverage

It’s recommended to have a `.prettierignore` in your project! This way you can run `prettier --write .` to make sure that everything is formatted (without mangling files you don’t want, or choking on generated files). And – your editor will know which files _not_ to format!

By default prettier ignores files in version control systems directories (".git", ".svn" and ".hg") and `node_modules` (if [`--with-node-modules` CLI option](cli.md#--with-node-modules) not specified)
By default prettier ignores files in version control systems directories (".git", ".sl", ".svn" and ".hg") and `node_modules` (unless the [`--with-node-modules` CLI option](cli.md#--with-node-modules) is specified). Prettier will also follow rules specified in the ".gitignore" file if it exists in the same directory from which it is run.

So by default it will be

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/install.md
Expand Up @@ -48,7 +48,7 @@ build
coverage
```

> Tip! Base your .prettierignore on .gitignore and .eslintignore (if you have one).
> Tip! Prettier will follow rules specified in .gitignore if it exists in the same directory from which it is run. You can also base your .prettierignore on .eslintignore (if you have one).
> Another tip! If your project isn’t ready to format, say, HTML files yet, add `*.html`.
Expand Down
13 changes: 13 additions & 0 deletions website/versioned_docs/version-stable/options.md
Expand Up @@ -10,6 +10,19 @@ Prettier ships with a handful of format options.

If you change any options, it’s recommended to do it via a [configuration file](configuration.md). This way the Prettier CLI, [editor integrations](editors.md) and other tooling knows what options you use.

## Experimental Ternaries

Try prettier's [new ternary formatting](https://github.com/prettier/prettier/pull/13183) before it becomes the default behavior.

Valid options:

- `true` - Use curious ternaries, with the question mark after the condition.
- `false` - Retain the default behavior of ternaries; keep question marks on the same line as the consequent.

| Default | CLI Override | API Override |
| ------- | -------------------------- | ------------------------------- |
| `false` | `--experimental-ternaries` | `experimentalTernaries: <bool>` |

## Print Width

Specify the line length that the printer will wrap on.
Expand Down
1 change: 1 addition & 0 deletions website/versioned_docs/version-stable/plugins.md
Expand Up @@ -53,6 +53,7 @@ Strings provided to `plugins` are ultimately passed to [`import()` expression](h
- [`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) by [**@NaridaL**](https://github.com/NaridaL)
- [`prettier-plugin-go-template`](https://github.com/NiklasPor/prettier-plugin-go-template) by [**@NiklasPor**](https://github.com/NiklasPor)
- [`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster)
- [`prettier-plugin-jinja-template`](https://github.com/davidodenwald/prettier-plugin-jinja-template) by [**@davidodenwald**](https://github.com/davidodenwald)
- [`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi)
- [`prettier-plugin-kotlin`](https://github.com/Angry-Potato/prettier-plugin-kotlin) by [**@Angry-Potato**](https://github.com/Angry-Potato)
- [`prettier-plugin-motoko`](https://github.com/dfinity/prettier-plugin-motoko) by [**@dfinity**](https://github.com/dfinity)
Expand Down

0 comments on commit e8ac9f8

Please sign in to comment.