Skip to content

Commit

Permalink
chore(deps): update dependency prettier to v3 (#237)
Browse files Browse the repository at this point in the history
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [prettier](https://prettier.io)
([source](https://togithub.com/prettier/prettier)) | [`^2.8.3` ->
`^3.0.0`](https://renovatebot.com/diffs/npm/prettier/2.8.4/3.0.2) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/prettier/3.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/prettier/3.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/prettier/2.8.4/3.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/prettier/2.8.4/3.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>prettier/prettier (prettier)</summary>

###
[`v3.0.2`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#302)

[Compare
Source](https://togithub.com/prettier/prettier/compare/3.0.1...3.0.2)

[diff](https://togithub.com/prettier/prettier/compare/3.0.1...3.0.2)

##### Break after `=` of assignment if RHS is poorly breakable
AwaitExpression or YieldExpression
([#&#8203;15204](https://togithub.com/prettier/prettier/pull/15204) by
[@&#8203;seiyab](https://togithub.com/seiyab))

<!-- prettier-ignore -->

```js
// Input
const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData);

// Prettier 3.0.1
const { section, rubric, authors, tags } = await utils.upsertCommonData(
  mainData,
);

// Prettier 3.0.2
const { section, rubric, authors, tags } =
  await utils.upsertCommonData(mainData);
```

##### Do not add trailing comma for grouped scss comments
([#&#8203;15217](https://togithub.com/prettier/prettier/pull/15217) by
[@&#8203;auvred](https://togithub.com/auvred))

<!-- prettier-ignore -->

```scss
/* Input */
$foo: (
	'property': (),
	// comment 1
	// comment 2
)

/* Prettier 3.0.1 */
$foo: (
  "property": (),
  // comment 1
  // comment 2,
);

/* Prettier 3.0.2 */
$foo: (
  "property": (),
  // comment 1
  // comment 2
);
```

##### Print `declare` and `export` keywords for nested namespace
([#&#8203;15249](https://togithub.com/prettier/prettier/pull/15249) by
[@&#8203;sosukesuzuki](https://togithub.com/sosukesuzuki))

<!-- prettier-ignore -->

```tsx
// Input
declare namespace abc1.def {}
export namespace abc2.def {}

// Prettier 3.0.1
namespace abc1.def {}
namespace abc2.def {}

// Prettier 3.0.2
declare namespace abc1.def {}
export namespace abc2.def {}
```

###
[`v3.0.1`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#301)

[Compare
Source](https://togithub.com/prettier/prettier/compare/3.0.0...3.0.1)

[diff](https://togithub.com/prettier/prettier/compare/3.0.0...3.0.1)

##### Fix cursor positioning for a special case
([#&#8203;14812](https://togithub.com/prettier/prettier/pull/14812) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```js
// <|> is the cursor position

/* Input */
// All messages are represented in JSON.
// So, the prettier.py controls a subprocess which spawns "node {this_file}".
import {<|>  } from "fs"

/* Prettier 3.0.0 */
// All messages are represented in JSON.
// So, the prettier.py <|>controls a subprocess which spawns "node {this_file}".
import {} from "fs"

/* Prettier 3.0.1 */
// All messages are represented in JSON.
// So, the prettier.py controls a subprocess which spawns "node {this_file}".
import {<|>} from "fs"
```

##### Fix plugins/estree.d.ts to make it a module
([#&#8203;15018](https://togithub.com/prettier/prettier/pull/15018) by
[@&#8203;kingyue737](https://togithub.com/kingyue737))

Add `export {}` in `plugins/estree.d.ts` to fix the "File is not a
module" error

##### Add parenthesis around leading multiline comment in return
statement
([#&#8203;15037](https://togithub.com/prettier/prettier/pull/15037) by
[@&#8203;auvred](https://togithub.com/auvred))

<!-- prettier-ignore -->

```jsx
// Input
function fn() {
  return (
    /**
     * @&#8203;type {...}
     */ expresssion
  )
}

// Prettier 3.0.0
function fn() {
  return /**
   * @&#8203;type {...}
   */ expresssion;
}

// Prettier 3.0.1
function fn() {
  return (
    /**
     * @&#8203;type {...}
     */ expresssion
  );
}
```

##### Add support for Vue "Generic Components"
([#&#8203;15066](https://togithub.com/prettier/prettier/pull/15066) by
[@&#8203;auvred](https://togithub.com/auvred))

https://blog.vuejs.org/posts/vue-3-3#generic-components

<!-- prettier-ignore -->

```vue
<!-- Input -->
<script setup lang="ts" generic="T extends Type1 & Type2 & (Type3 | Type4), U extends string | number | boolean"></script>

<!-- Prettier 3.0.0 -->
<script
  setup
  lang="ts"
  generic="T extends Type1 & Type2 & (Type3 | Type4), U extends string | number | boolean"
></script>

<!-- Prettier 3.0.1 -->
<script
  setup
  lang="ts"
  generic="
    T extends Type1 & Type2 & (Type3 | Type4),
    U extends string | number | boolean
  "
></script>
```

##### Fix comments print in `IfStatement`
([#&#8203;15076](https://togithub.com/prettier/prettier/pull/15076) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```js
function a(b) {
  if (b) return 1; // comment
  else return 2;
}

/* Prettier 3.0.0 */
Error: Comment "comment" was not printed. Please report this error!

/* Prettier 3.0.1 */
function a(b) {
  if (b) return 1; // comment
  else return 2;
}
```

##### Add missing type definition for `printer.preprocess`
([#&#8203;15123](https://togithub.com/prettier/prettier/pull/15123) by
[@&#8203;so1ve](https://togithub.com/so1ve))

```diff
export interface Printer<T = any> {
  // ...
+ preprocess?:
+   | ((ast: T, options: ParserOptions<T>) => T | Promise<T>)
+   | undefined;
}
```

##### Add missing `getVisitorKeys` method type definition for `Printer`
([#&#8203;15125](https://togithub.com/prettier/prettier/pull/15125) by
[@&#8203;auvred](https://togithub.com/auvred))

```tsx
const printer: Printer = {
  print: () => [],
  getVisitorKeys(node, nonTraversableKeys) {
    return ["body"];
  },
};
```

##### Add typing to support `readonly` array properties of AST Node
([#&#8203;15127](https://togithub.com/prettier/prettier/pull/15127) by
[@&#8203;auvred](https://togithub.com/auvred))

<!-- prettier-ignore -->

```tsx
// Input
interface TestNode {
  readonlyArray: readonly string[];
}

declare const path: AstPath<TestNode>;

path.map(() => "", "readonlyArray");

// Prettier 3.0.0
interface TestNode {
  readonlyArray: readonly string[];
}

declare const path: AstPath<TestNode>;

path.map(() => "", "readonlyArray");
//                  ^ Argument of type '"readonlyArray"' is not assignable to parameter of type '"regularArray"'. ts(2345)

// Prettier 3.0.1
interface TestNode {
  readonlyArray: readonly string[];
}

declare const path: AstPath<TestNode>;

path.map(() => "", "readonlyArray");
```

##### Add space before unary minus followed by a function call
([#&#8203;15129](https://togithub.com/prettier/prettier/pull/15129) by
[@&#8203;pamelalozano](https://togithub.com/pamelalozano))

<!-- prettier-ignore -->

```less
// Input
div {
  margin: - func();
}

// Prettier 3.0.0
div {
  margin: -func();
}

// Prettier 3.0.1
div {
  margin: - func();
}
```

###
[`v3.0.0`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#300)

[Compare
Source](https://togithub.com/prettier/prettier/compare/2.8.8...3.0.0)


[diff](https://togithub.com/prettier/prettier/compare/3.0.0-alpha.6...3.0.0)

🔗 [Release Notes](https://prettier.io/blog/2023/07/05/3.0.0.html)

###
[`v2.8.8`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#288)

[Compare
Source](https://togithub.com/prettier/prettier/compare/2.8.7...2.8.8)

This version is a republished version of v2.8.7.
A bad version was accidentally published and [it can't be
unpublished](https://togithub.com/npm/cli/issues/1686), apologies for
the churn.

###
[`v2.8.7`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#287)

[Compare
Source](https://togithub.com/prettier/prettier/compare/2.8.6...2.8.7)

[diff](https://togithub.com/prettier/prettier/compare/2.8.6...2.8.7)

##### Allow multiple decorators on same getter/setter
([#&#8203;14584](https://togithub.com/prettier/prettier/pull/14584) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```ts
// Input
class A {
  @&#8203;decorator()
  get foo () {}
  
  @&#8203;decorator()
  set foo (value) {}
}

// Prettier 2.8.6
SyntaxError: Decorators cannot be applied to multiple get/set accessors of the same name. (5:3)
  3 |   get foo () {}
  4 |   
> 5 |   @&#8203;decorator()
    |   ^^^^^^^^^^^^
  6 |   set foo (value) {}
  7 | }

// Prettier 2.8.7
class A {
  @&#8203;decorator()
  get foo() {}

  @&#8203;decorator()
  set foo(value) {}
}
```

###
[`v2.8.6`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#286)

[Compare
Source](https://togithub.com/prettier/prettier/compare/2.8.5...2.8.6)

[diff](https://togithub.com/prettier/prettier/compare/2.8.5...2.8.6)

##### Allow decorators on private members and class expressions
([#&#8203;14548](https://togithub.com/prettier/prettier/pull/14548) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```ts
// Input
class A {
  @&#8203;decorator()
  #privateMethod () {}
}

// Prettier 2.8.5
SyntaxError: Decorators are not valid here. (2:3)
  1 | class A {
> 2 |   @&#8203;decorator()
    |   ^^^^^^^^^^^^
  3 |   #privateMethod () {}
  4 | }

// Prettier 2.8.6
class A {
  @&#8203;decorator()
  #privateMethod() {}
}
```

###
[`v2.8.5`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#285)

[Compare
Source](https://togithub.com/prettier/prettier/compare/2.8.4...2.8.5)

[diff](https://togithub.com/prettier/prettier/compare/2.8.4...2.8.5)

##### Support TypeScript 5.0
([#&#8203;14391](https://togithub.com/prettier/prettier/pull/14391) by
[@&#8203;fisker](https://togithub.com/fisker),
[#&#8203;13819](https://togithub.com/prettier/prettier/pull/13819) by
[@&#8203;fisker](https://togithub.com/fisker),
[@&#8203;sosukesuzuki](https://togithub.com/sosukesuzuki))

TypeScript 5.0 introduces two new syntactic features:

-   `const` modifiers for type parameters
-   `export type *` declarations

##### Add missing parentheses for decorator
([#&#8203;14393](https://togithub.com/prettier/prettier/pull/14393) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
class Person {
  @&#8203;(myDecoratorArray[0])
  greet() {}
}

// Prettier 2.8.4
class Person {
  @&#8203;myDecoratorArray[0]
  greet() {}
}

// Prettier 2.8.5
class Person {
  @&#8203;(myDecoratorArray[0])
  greet() {}
}
```

##### Add parentheses for `TypeofTypeAnnotation` to improve readability
([#&#8203;14458](https://togithub.com/prettier/prettier/pull/14458) by
[@&#8203;fisker](https://togithub.com/fisker))

<!-- prettier-ignore -->

```tsx
// Input
type A = (typeof node.children)[];

// Prettier 2.8.4
type A = typeof node.children[];

// Prettier 2.8.5
type A = (typeof node.children)[];
```

##### Support `max_line_length=off` when parsing `.editorconfig`
([#&#8203;14516](https://togithub.com/prettier/prettier/pull/14516) by
[@&#8203;josephfrazier](https://togithub.com/josephfrazier))

If an .editorconfig file is in your project and it sets
`max_line_length=off` for the file you're formatting,
it will be interpreted as a `printWidth` of `Infinity` rather than being
ignored
(which previously resulted in the default `printWidth` of 80 being
applied, if not overridden by Prettier-specific configuration).

<!-- prettier-ignore -->

```html
<!-- Input -->
<div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}/>

<!-- Prettier 2.8.4 -->
<div
  className="HelloWorld"
  title={`You are visitor number ${num}`}
  onMouseOver={onMouseOver}
/>;

<!-- Prettier 2.8.5 -->
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver} />;
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/JoshuaKGoldberg/ts-api-utils).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTkuNyIsInVwZGF0ZWRJblZlciI6IjM2LjQzLjIiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
  • Loading branch information
renovate[bot] and JoshuaKGoldberg authored Aug 18, 2023
1 parent f464d04 commit 92c50de
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 260 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"npm-package-json-lint": "^7.0.0",
"npm-package-json-lint-config-default": "^6.0.0",
"pnpm-deduplicate": "^0.4.1",
"prettier": "^2.8.3",
"prettier": "^3.0.0",
"prettier-plugin-packagejson": "^2.4.2",
"release-it": "^16.0.0",
"sentences-per-line": "^0.2.1",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("forEachComment", () => {
sourceFile.getFullText(),
expect.objectContaining({
kind: ts.SyntaxKind.SingleLineCommentTrivia,
})
}),
);
});

Expand All @@ -45,7 +45,7 @@ describe("forEachComment", () => {
sourceFile.getFullText(),
expect.objectContaining({
kind: ts.SyntaxKind.SingleLineCommentTrivia,
})
}),
);
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function canHaveTrailingTrivia(token: ts.Node): boolean {
* @internal
*/
function isJsxElementOrFragment(
node: ts.Node
node: ts.Node,
): node is ts.JsxElement | ts.JsxFragment {
return (
node.kind === ts.SyntaxKind.JsxElement ||
Expand All @@ -60,7 +60,7 @@ function isJsxElementOrFragment(
*/
export type ForEachCommentCallback = (
fullText: string,
comment: ts.CommentRange
comment: ts.CommentRange,
) => void;

/**
Expand All @@ -79,7 +79,7 @@ export type ForEachCommentCallback = (
export function forEachComment(
node: ts.Node,
callback: ForEachCommentCallback,
sourceFile: ts.SourceFile = node.getSourceFile()
sourceFile: ts.SourceFile = node.getSourceFile(),
): void {
/* Visit all tokens and skip trivia.
Comment ranges between tokens are parsed without the need of a scanner.
Expand All @@ -97,16 +97,16 @@ export function forEachComment(
fullText,
// skip shebang at position 0
token.pos === 0 ? (ts.getShebang(fullText) ?? "").length : token.pos,
commentCallback
commentCallback,
);
if (notJsx || canHaveTrailingTrivia(token))
return ts.forEachTrailingCommentRange(
fullText,
token.end,
commentCallback
commentCallback,
);
},
sourceFile
sourceFile,
);
function commentCallback(pos: number, end: number, kind: ts.CommentKind) {
callback(fullText, { pos, end, kind });
Expand Down
Loading

0 comments on commit 92c50de

Please sign in to comment.