Skip to content

Commit 2a5b391

Browse files
theScottyJamfisker
andauthored
Explain ASI issues aren't always auto-fixed (#14174)
Co-authored-by: fisker Cheung <[email protected]>
1 parent cf409fe commit 2a5b391

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

docs/rationale.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,24 @@ With a semicolon in front of that `[` such issues never happen. It makes the lin
187187

188188
This practice is also common in [standard] which uses a semicolon-free style.
189189

190+
Note that if your program currently has a semicolon-related bug in it, Prettier _will not_ auto-fix the bug for you. Remember, Prettier only reformats code, it does not change the behavior of the code. Take this buggy piece of code as an example, where the developer forgot to place a semicolon before the `(`:
191+
192+
<!-- prettier-ignore -->
193+
```js
194+
console.log('Running a background task')
195+
(async () => {
196+
await doBackgroundWork()
197+
})()
198+
```
199+
200+
If you feed this into Prettier, it will not alter the behavior of this code, instead, it will reformat it in a way that shows how this code will actually behave when ran.
201+
202+
```js
203+
console.log("Running a background task")(async () => {
204+
await doBackgroundWork();
205+
})();
206+
```
207+
190208
[standard]: https://standardjs.com/rules.html#semicolons
191209

192210
### Print width

website/versioned_docs/version-stable/rationale.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ With a semicolon in front of that `[` such issues never happen. It makes the lin
188188

189189
This practice is also common in [standard] which uses a semicolon-free style.
190190

191+
Note that if your program currently has a semicolon-related bug in it, Prettier _will not_ auto-fix the bug for you. Remember, Prettier only reformats code, it does not change the behavior of the code. Take this buggy piece of code as an example, where the developer forgot to place a semicolon before the `(`:
192+
193+
<!-- prettier-ignore -->
194+
```js
195+
console.log('Running a background task')
196+
(async () => {
197+
await doBackgroundWork()
198+
})()
199+
```
200+
201+
If you feed this into Prettier, it will not alter the behavior of this code, instead, it will reformat it in a way that shows how this code will actually behave when ran.
202+
203+
```js
204+
console.log("Running a background task")(async () => {
205+
await doBackgroundWork();
206+
})();
207+
```
208+
191209
[standard]: https://standardjs.com/rules.html#semicolons
192210

193211
### Print width

0 commit comments

Comments
 (0)