Skip to content

Commit

Permalink
Release 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jun 1, 2024
1 parent 8a88cdc commit c4ab460
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 63 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 @@ Don't fill the form below manually! Let a program create a report for you:
-->

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

```sh
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 @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:

**Environments:**

- Prettier Version: 3.2.5
- Prettier Version: 3.3.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
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.3.0

[diff](https://github.com/prettier/prettier/compare/3.2.5...3.3.0)

🔗 [Release Notes](https://prettier.io/blog/2024/06/01/3.3.0.html)

# 3.2.5

[diff](https://github.com/prettier/prettier/compare/3.2.4...3.2.5)
Expand Down
32 changes: 16 additions & 16 deletions docs/browser.md
Original file line number Diff line number Diff line change
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.2.5/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.3.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.2.5/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.2.5/plugins/graphql.js"></script>
<script src="https://unpkg.com/prettier@3.3.0/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.2.5/plugins/graphql.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.3.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.2.5/standalone.js",
"https://unpkg.com/prettier@3.2.5/plugins/graphql.js",
"https://unpkg.com/prettier@3.3.0/standalone.js",
"https://unpkg.com/prettier@3.3.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.2.5/standalone.js");
importScripts("https://unpkg.com/prettier@3.2.5/plugins/graphql.js");
importScripts("https://unpkg.com/prettier@3.3.0/standalone.js");
importScripts("https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.5/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.5/plugins/estree.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.3.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.5/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.5/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.2.5/plugins/html.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.3.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.3.0/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.3.0/plugins/html.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
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": "3.3.0-dev",
"version": "3.3.0",
"description": "Prettier is an opinionated code formatter",
"bin": "./bin/prettier.cjs",
"repository": "prettier/prettier",
Expand Down
32 changes: 16 additions & 16 deletions website/versioned_docs/version-stable/browser.md
Original file line number Diff line number Diff line change
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.2.5/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.3.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.2.5/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.2.5/plugins/graphql.js"></script>
<script src="https://unpkg.com/prettier@3.3.0/standalone.js"></script>
<script src="https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.2.5/plugins/graphql.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginGraphql from "https://unpkg.com/prettier@3.3.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.2.5/standalone.js",
"https://unpkg.com/prettier@3.2.5/plugins/graphql.js",
"https://unpkg.com/prettier@3.3.0/standalone.js",
"https://unpkg.com/prettier@3.3.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.2.5/standalone.js");
importScripts("https://unpkg.com/prettier@3.2.5/plugins/graphql.js");
importScripts("https://unpkg.com/prettier@3.3.0/standalone.js");
importScripts("https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.5/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.5/plugins/estree.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.3.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.3.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.2.5/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.5/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.5/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.2.5/plugins/html.mjs";
import * as prettier from "https://unpkg.com/prettier@3.3.0/standalone.mjs";
import prettierPluginBabel from "https://unpkg.com/prettier@3.3.0/plugins/babel.mjs";
import prettierPluginEstree from "https://unpkg.com/prettier@3.3.0/plugins/estree.mjs";
import prettierPluginHtml from "https://unpkg.com/prettier@3.3.0/plugins/html.mjs";
console.log(
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
Expand Down
16 changes: 11 additions & 5 deletions website/versioned_docs/version-stable/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ original_id: configuration

You can configure Prettier via (in order of precedence):

- A `"prettier"` key in your `package.json` file.
- A `"prettier"` key in your `package.json`, or [`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) file.
- A `.prettierrc` file written in JSON or YAML.
- A `.prettierrc.json`, `.prettierrc.yml`, `.prettierrc.yaml`, or `.prettierrc.json5` file.
- A `.prettierrc.js`, or `prettier.config.js` file that exports an object using `export default` or `module.exports` (depends on the [`type`](https://nodejs.org/api/packages.html#type) value in your `package.json`).
Expand All @@ -33,12 +33,15 @@ JSON:
}
```

JS(ESM):
JS (ES Modules):

```js
// prettier.config.js, .prettierrc.js, prettier.config.mjs, or .prettierrc.mjs

/** @type {import("prettier").Config} */
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
trailingComma: "es5",
tabWidth: 4,
Expand All @@ -49,12 +52,15 @@ const config = {
export default config;
```

JS(CommonJS):
JS (CommonJS):

```js
// prettier.config.js, .prettierrc.js, prettier.config.cjs, or .prettierrc.cjs

/** @type {import("prettier").Config} */
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
trailingComma: "es5",
tabWidth: 4,
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For more details see [the Vim setup guide](vim.md).

A formatter can be specified in your [Helix language configuration](https://docs.helix-editor.com/languages.html#language-configuration), which will take precedence over any language servers.

For more details see the [Helix external binary formatter configuration for Prettier](https://github.com/helix-editor/helix/wiki/External-binary-formatter-configuration#prettier).
For more details see the [Helix external binary formatter configuration for Prettier](https://github.com/helix-editor/helix/wiki/External-formatter-configuration#prettier).

## Sublime Text

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ For example, you can do the following to have Prettier run before each commit:
```bash
bun add --dev husky lint-staged
bunx husky init
bun --eval "fs.writeFileSync('.husky/pre-commit','pnpm exec lint-staged\n')"
bun --eval "fs.writeFileSync('.husky/pre-commit','bunx lint-staged\n')"
```

<!--END_DOCUSAURUS_CODE_TABS-->
Expand Down
6 changes: 3 additions & 3 deletions website/versioned_docs/version-stable/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function print(

The `print` function is passed the following parameters:

- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.getValue()`.
- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.node`.
- **`options`**: A persistent object, which contains global options and which a plugin may mutate to store contextual data.
- **`print`**: A callback for printing sub-nodes. This function contains the core printing logic that consists of steps whose implementation is provided by plugins. In particular, it calls the printer’s `print` function and passes itself to it. Thus, the two `print` functions – the one from the core and the one from the plugin – call each other while descending down the AST recursively.

Expand All @@ -215,7 +215,7 @@ import { doc } from "prettier";
const { group, indent, join, line, softline } = doc.builders;

function print(path, options, print) {
const node = path.getValue();
const node = path.node;

switch (node.type) {
case "list":
Expand Down Expand Up @@ -282,7 +282,7 @@ For example, a plugin that has nodes with embedded JavaScript might have the fol

```js
function embed(path, options) {
const node = path.getValue();
const node = path.node;
if (node.type === "javascript") {
return async (textToDoc) => {
return [
Expand Down
21 changes: 3 additions & 18 deletions website/versioned_docs/version-stable/precommit.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,7 @@ This will install [husky](https://github.com/typicode/husky) and [lint-staged](h

Read more at the [lint-staged](https://github.com/okonet/lint-staged#configuration) repo.

## Option 2. [pre-commit](https://github.com/pre-commit/pre-commit)

**Use Case:** Great when working with multi-language projects.

Copy the following config into your `.pre-commit-config.yaml` file:

```yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "" # Use the sha or tag you want to point at
hooks:
- id: prettier
```

Read more at [mirror of prettier package for pre-commit](https://github.com/pre-commit/mirrors-prettier) and the [pre-commit](https://pre-commit.com) website.

## Option 3. [Husky.Net](https://github.com/alirezanet/Husky.Net)
## Option 2. [Husky.Net](https://github.com/alirezanet/Husky.Net)

**Use Case:** A dotnet solution to use Prettier along with other code quality tools (e.g. dotnet-format, ESLint, Stylelint, etc.). It supports multiple file states (staged - last-commit, git-files etc.)

Expand All @@ -56,7 +41,7 @@ after installation you can add prettier task to the `task-runner.json`.
}
```

## Option 4. [git-format-staged](https://github.com/hallettj/git-format-staged)
## Option 3. [git-format-staged](https://github.com/hallettj/git-format-staged)

**Use Case:** Great for when you want to format partially-staged files, and other options do not provide a good fit for your project.

Expand Down Expand Up @@ -108,7 +93,7 @@ Add or remove file extensions to suit your project. Note that regardless of whic

To read about how git-format-staged works see [Automatic Code Formatting for Partially-Staged Files](https://www.olioapps.com/blog/automatic-code-formatting/).

## Option 5. Shell script
## Option 4. Shell script

Alternately you can save this script as `.git/hooks/pre-commit` and give it execute permission:

Expand Down

0 comments on commit c4ab460

Please sign in to comment.