Fix a TODO (#15902)

This commit is contained in:
fisker Cheung authored and GitHub committed 2024-01-10 00:49:17 +08:00
1 parent b56fe35893
commit 45ad4668eb
6 files changed
+12 -13

No files matched your search

+1 -2
View File
@@ -53,8 +53,7 @@ jobs:
run: yarn lint:blog run: yarn lint:blog
- name: Lint docs code block - name: Lint docs code block
# TODO: Lint files in `website/versioned_docs/version-stable` too run: yarn prettier "{docs,website/versioned_docs/version-stable}/**/*.md" --check
run: yarn "docs/**/*.md"
env: env:
# Make Prettier throws on embeded format # Make Prettier throws on embeded format
PRETTIER_DEBUG: true PRETTIER_DEBUG: true
+1 -1
View File
@@ -2053,7 +2053,7 @@ Test <a href="https://prettier.io">abc</a>.
#### Fix broken format for `...infer T` ([#9044](https://github.com/prettier/prettier/pull/9044) by [@fisker](https://github.com/fisker)) #### Fix broken format for `...infer T` ([#9044](https://github.com/prettier/prettier/pull/9044) by [@fisker](https://github.com/fisker))
<!-- prettier-ignore --> <!-- prettier-ignore -->
```typescript ```ts
// Input // Input
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never; type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
+4 -4
View File
@@ -87,7 +87,7 @@ const user = {
Just like with objects, decorators are used for a lot of different things. Sometimes it makes sense to write decorators _above_ the line they're decorating, sometimes it’s nicer if they're on the _same_ line. We haven’t been able to find a good rule for this, so Prettier keeps your decorator positioned like you wrote them (if they fit on the line). This isn’t ideal, but a pragmatic solution to a difficult problem. Just like with objects, decorators are used for a lot of different things. Sometimes it makes sense to write decorators _above_ the line they're decorating, sometimes it’s nicer if they're on the _same_ line. We haven’t been able to find a good rule for this, so Prettier keeps your decorator positioned like you wrote them (if they fit on the line). This isn’t ideal, but a pragmatic solution to a difficult problem.
```js ```ts
@Component({ @Component({
selector: "hero-button", selector: "hero-button",
template: `<button>{{ label }}</button>`, template: `<button>{{ label }}</button>`,
@@ -108,14 +108,14 @@ class HeroButtonComponent {
There’s one exception: classes. We don’t think it ever makes sense to inline the decorators for them, so they are always moved to their own line. There’s one exception: classes. We don’t think it ever makes sense to inline the decorators for them, so they are always moved to their own line.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```js ```ts
// Before running Prettier: // Before running Prettier:
@observer class OrderLine { @observer class OrderLine {
@observable price: number = 0; @observable price: number = 0;
} }
``` ```
```js ```ts
// After running Prettier: // After running Prettier:
@observer @observer
class OrderLine { class OrderLine {
@@ -125,7 +125,7 @@ class OrderLine {
Note: Prettier 1.14.x and older tried to automatically move your decorators, so if you've run an older Prettier version on your code you might need to manually join up some decorators here and there to avoid inconsistencies: Note: Prettier 1.14.x and older tried to automatically move your decorators, so if you've run an older Prettier version on your code you might need to manually join up some decorators here and there to avoid inconsistencies:
```js ```ts
@observer @observer
class OrderLine { class OrderLine {
@observable price: number = 0; @observable price: number = 0;
+1 -1
View File
@@ -220,7 +220,7 @@ const {
We were omitting parens around type assertions inside decorators: We were omitting parens around type assertions inside decorators:
<!-- prettier-ignore --> <!-- prettier-ignore -->
```typescript ```ts
@(bind as ClassDecorator) @(bind as ClassDecorator)
class Decorated {} class Decorated {}
``` ```
+1 -1
View File
@@ -819,7 +819,7 @@ const x = async do {
`typescript` parser only, `babel-ts` doesn't have this issue. `typescript` parser only, `babel-ts` doesn't have this issue.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```typescript ```ts
// Input // Input
class Foo { class Foo {
bar() /* bat */; bar() /* bat */;
@@ -88,7 +88,7 @@ const user = {
Just like with objects, decorators are used for a lot of different things. Sometimes it makes sense to write decorators _above_ the line they're decorating, sometimes it’s nicer if they're on the _same_ line. We haven’t been able to find a good rule for this, so Prettier keeps your decorator positioned like you wrote them (if they fit on the line). This isn’t ideal, but a pragmatic solution to a difficult problem. Just like with objects, decorators are used for a lot of different things. Sometimes it makes sense to write decorators _above_ the line they're decorating, sometimes it’s nicer if they're on the _same_ line. We haven’t been able to find a good rule for this, so Prettier keeps your decorator positioned like you wrote them (if they fit on the line). This isn’t ideal, but a pragmatic solution to a difficult problem.
```js ```ts
@Component({ @Component({
selector: "hero-button", selector: "hero-button",
template: `<button>{{ label }}</button>`, template: `<button>{{ label }}</button>`,
@@ -109,14 +109,14 @@ class HeroButtonComponent {
There’s one exception: classes. We don’t think it ever makes sense to inline the decorators for them, so they are always moved to their own line. There’s one exception: classes. We don’t think it ever makes sense to inline the decorators for them, so they are always moved to their own line.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```js ```ts
// Before running Prettier: // Before running Prettier:
@observer class OrderLine { @observer class OrderLine {
@observable price: number = 0; @observable price: number = 0;
} }
``` ```
```js ```ts
// After running Prettier: // After running Prettier:
@observer @observer
class OrderLine { class OrderLine {
@@ -126,7 +126,7 @@ class OrderLine {
Note: Prettier 1.14.x and older tried to automatically move your decorators, so if you've run an older Prettier version on your code you might need to manually join up some decorators here and there to avoid inconsistencies: Note: Prettier 1.14.x and older tried to automatically move your decorators, so if you've run an older Prettier version on your code you might need to manually join up some decorators here and there to avoid inconsistencies:
```js ```ts
@observer @observer
class OrderLine { class OrderLine {
@observable price: number = 0; @observable price: number = 0;