diff --git a/src/docs/guide/usage/formatter.md b/src/docs/guide/usage/formatter.md index 7cdfaf9f92b..ee681776e32 100644 --- a/src/docs/guide/usage/formatter.md +++ b/src/docs/guide/usage/formatter.md @@ -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) diff --git a/src/docs/guide/usage/formatter/ignore-comments.md b/src/docs/guide/usage/formatter/ignore-comments.md index beb413f2c4f..2bac6794c15 100644 --- a/src/docs/guide/usage/formatter/ignore-comments.md +++ b/src/docs/guide/usage/formatter/ignore-comments.md @@ -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. ```js @@ -14,6 +17,9 @@ const x = () => { return 2; }; {/* oxfmt-ignore */} ; + +const config={ retries:10, timeout:5000 }; // oxfmt-ignore +const data=[1,2,3]; /* prettier-ignore */ ``` @@ -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 diff --git a/src/docs/guide/usage/formatter/ignoring.md b/src/docs/guide/usage/formatter/ignoring.md index 35eb2731d51..4d5f1f86aad 100644 --- a/src/docs/guide/usage/formatter/ignoring.md +++ b/src/docs/guide/usage/formatter/ignoring.md @@ -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 */} ; -``` -::: 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). diff --git a/src/docs/guide/usage/formatter/quickstart.md b/src/docs/guide/usage/formatter/quickstart.md index 7ea3cd4d12a..3bcfcac1d95 100644 --- a/src/docs/guide/usage/formatter/quickstart.md +++ b/src/docs/guide/usage/formatter/quickstart.md @@ -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