Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/docs/guide/usage/formatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pnpm run fmt:check

- [Quickstart](./formatter/quickstart)
- [Configuration](./formatter/config)
- [Ignore files](./formatter/ignore-files)
- [Inline ignore comments](./formatter/ignore-comments)
- [Setup editors](./formatter/editors)
- [Setup CI](./formatter/ci)

Expand Down
12 changes: 9 additions & 3 deletions src/docs/guide/usage/formatter/ignore-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Inline ignore comments

For JS/TS files, use `oxfmt-ignore` to skip formatting the next statement:
For JS/TS files, use `oxfmt-ignore` or `prettier-ignore` to skip formatting:

- the next statement / expression, or
- the current statement / expression when the comment is trailing on the same line.

<!-- prettier-ignore-start -->
```js
Expand All @@ -14,6 +17,9 @@ const x = () => { return 2; };
{/* oxfmt-ignore */}
<span ugly format="" />
</>;

const config={ retries:10, timeout:5000 }; // oxfmt-ignore
const data=[1,2,3]; /* prettier-ignore */
```
<!-- prettier-ignore-end -->

Expand All @@ -23,5 +29,5 @@ Currently, TOML files do not support ignore comments.

## Prettier compatibility

- `prettier-ignore` comment is also supported
- Trailing ignore comments in JS/TS files are not supported for performance reasons
- `prettier-ignore` comments are supported for JS/TS
- Trailing ignore comments in JS/TS files are supported
20 changes: 10 additions & 10 deletions src/docs/guide/usage/formatter/ignoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ These cannot be formatted even if explicitly specified.

## Ignore comments

For JS/TS files, you can use a `prettier-ignore` comment.
For JS/TS files, you can use `oxfmt-ignore` or `prettier-ignore`.

This takes effect on the next statement/expression.
This takes effect on:

- the next statement / expression, or
- the current statement / expression when used as a trailing comment.

```js
// prettier-ignore
// oxfmt-ignore
const a=42;

/* prettier-ignore */
const x=()=>{return 2;}

<>
{/* prettier-ignore */}
{/* oxfmt-ignore */}
<span ugly format='' />
</>;
```

::: warning
(Not documented, but) Prettier supports trailing ignore comment too.
However, we don't support it to avoid a performance hit.
Please update your code in that case.
:::
const config={ retries:10, timeout:5000 }; // oxfmt-ignore
const data=[1,2,3]; /* prettier-ignore */
```

For non-JS files, the same convention as Prettier works.
Please see Prettier's [documentation](https://prettier.io/docs/ignore#html).
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/formatter/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ See [migrate from prettier](./migrate-from-prettier) for details.
oxfmt --list-different
```

This is useful for configuring [files to ignore](./ignore-files).
This is useful for configuring [files to ignore](./ignore-files). For per-line and per-node suppression, see [inline ignore comments](./ignore-comments).

### Piping file contents

Expand Down