Skip to content

Commit

Permalink
chore: upgrade prettier and update snapshots (#2502)
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-yu committed Apr 30, 2024
1 parent ed0c149 commit 520cef0
Show file tree
Hide file tree
Showing 114 changed files with 4,114 additions and 667 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ crates/biome_js_formatter/report.*
crates/biome_json_formatter/report.*
crates/biome_json_formatter/report_incompatible.*
.vercel

# don't ignore any files inside prettier test specs
!crates/biome_js_formatter/tests/specs/prettier/**/*
!crates/biome_json_formatter/tests/specs/prettier/**/*
!crates/biome_css_formatter/tests/specs/prettier/**/*
27 changes: 21 additions & 6 deletions crates/biome_formatter_test/src/prettier/package-lock.json

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

2 changes: 1 addition & 1 deletion crates/biome_formatter_test/src/prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"start": "node prepare_tests"
},
"dependencies": {
"prettier": "3.1.0"
"prettier": "3.2.5"
}
}
2 changes: 1 addition & 1 deletion crates/biome_js_formatter/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ fn handle_if_statement_comment(
&& !comment.text_position().is_own_line()
&& comment.preceding_node().is_some()
{
return CommentPlacement::dangling(consequent, comment);
return CommentPlacement::trailing(consequent, comment);
}

// ```javascript
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function someFunctionName(
someLongBreakingParameterName,
anotherLongParameterName,
) {
return isEqual(a?.map(([t, _]) => t?.id), b?.map(([t, _]) => t?.id));
return isEqual(a.map(([t, _]) => t?.id), b.map(([t, _]) => t?.id));
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function someFunctionName(
someLongBreakingParameterName,
anotherLongParameterName,
) {
return isEqual(
a?.map(([t, _]) => t?.id),
b?.map(([t, _]) => t?.id),
);
return isEqual(
a.map(([t, _]) => t?.id),
b.map(([t, _]) => t?.id),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const theValue = Object.entries(someLongObjectName).filter(
([listingId]) => someListToCompareToHere?.includes(listingId),
);
const theValue2 = Object.entries(someLongObjectName).filter(
([listingId]) => someListToCompareToHere.includes(listingId),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const theValue = Object.entries(someLongObjectName).filter(([listingId]) =>
someListToCompareToHere?.includes(listingId),
);
const theValue2 = Object.entries(someLongObjectName).filter(([listingId]) =>
someListToCompareToHere.includes(listingId),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
logger.log(
`A long template string with a conditional: ${channel?.id}, and then some more content that continues until ${JSON.stringify(location)}`
);
logger.log(
`A long template string with a conditional: ${channel.id}, and then some more content that continues until ${JSON.stringify(location)}`
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
logger.log(
`A long template string with a conditional: ${channel?.id}, and then some more content that continues until ${JSON.stringify(location)}`,
);
logger.log(
`A long template string with a conditional: ${channel.id}, and then some more content that continues until ${JSON.stringify(location)}`,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: js/chain-expression/issue-15785-3.js
---
# Input

```js
logger.log(
`A long template string with a conditional: ${channel?.id}, and then some more content that continues until ${JSON.stringify(location)}`
);
logger.log(
`A long template string with a conditional: ${channel.id}, and then some more content that continues until ${JSON.stringify(location)}`
);
```
# Prettier differences
```diff
--- Prettier
+++ Biome
@@ -1,6 +1,14 @@
logger.log(
- `A long template string with a conditional: ${channel?.id}, and then some more content that continues until ${JSON.stringify(location)}`,
+ `A long template string with a conditional: ${
+ channel?.id
+ }, and then some more content that continues until ${JSON.stringify(
+ location,
+ )}`,
);
logger.log(
- `A long template string with a conditional: ${channel.id}, and then some more content that continues until ${JSON.stringify(location)}`,
+ `A long template string with a conditional: ${
+ channel.id
+ }, and then some more content that continues until ${JSON.stringify(
+ location,
+ )}`,
);
```
# Output
```js
logger.log(
`A long template string with a conditional: ${
channel?.id
}, and then some more content that continues until ${JSON.stringify(
location,
)}`,
);
logger.log(
`A long template string with a conditional: ${
channel.id
}, and then some more content that continues until ${JSON.stringify(
location,
)}`,
);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test()
.test2()
.test2(thing?.something);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test().test2().test2(thing?.something);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const randomFuncion = (value) => {
if (value.a) {
funcA(
"",
funcB(
dayjs(value.a?.toString())
.add(1, "day")
.toISOString()
)
);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const randomFuncion = (value) => {
if (value.a) {
funcA("", funcB(dayjs(value.a?.toString()).add(1, "day").toISOString()));
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{{{
const [lastCommittedX, lastCommittedY] =
multiElement?.lastCommittedPoint ?? [0, 0];
}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
{
{
{
const [lastCommittedX, lastCommittedY] =
multiElement?.lastCommittedPoint ?? [0, 0];
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function getLanguageByInterpreter(languages, file) {
return languages.find((language) => language.interpreters?.includes(interpreter),
);
return languages.find((language) =>language.interpreters.includes(interpreter),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function getLanguageByInterpreter(languages, file) {
return languages.find((language) =>
language.interpreters?.includes(interpreter),
);
return languages.find((language) =>
language.interpreters.includes(interpreter),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// https://github.com/marmelab/react-admin/blob/8c1ddfeb4e011a94609d709c0f4f139fb5d480e8/packages/ra-data-localstorage/src/index.ts#L112
export default (params) => {
return {
updateMany: (resource, params) => {
updateLocalStorage(() => {
params.ids.forEach(id => {
const index = data.data.data.data.data[resource]?.findIndex(
record => record.id == id
);
const index2 = data.data.data.data.data[resource].findIndex(
record => record.id == id
);
data[resource][index] = {
...data[resource][index],
...params.data,
};
});
});
return baseDataProvider.updateMany(resource, params);
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// https://github.com/marmelab/react-admin/blob/8c1ddfeb4e011a94609d709c0f4f139fb5d480e8/packages/ra-data-localstorage/src/index.ts#L112
export default (params) => {
return {
updateMany: (resource, params) => {
updateLocalStorage(() => {
params.ids.forEach((id) => {
const index = data.data.data.data.data[resource]?.findIndex(
(record) => record.id == id,
);
const index2 = data.data.data.data.data[resource].findIndex(
(record) => record.id == id,
);
data[resource][index] = {
...data[resource][index],
...params.data,
};
});
});
return baseDataProvider.updateMany(resource, params);
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ function inlineComment() {
) || 42
}


function multilineBlockSameLine() {
return (
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ function inlineComment() {
) || 42
}


function multilineBlockSameLine() {
return (
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// At the time of adding this test, the cursor positioning we end up with
// here seems clearly wrong.
// I'm adding the test case anyway to demonstrate the brokenness and ensure
// that if a future changes fixes it, it'll be obvious from the PR diff that
// the fix happened.
[
[
[
[
1,
2,
<|> 3, "looooooooooooooooooooooooooooooooooooooooooooooooooong",
"looooooooooooooooooooooooooooooooooooooooooooooooooong",
]
]
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// At the time of adding this test, the cursor positioning we end up with
// here seems clearly wrong.
// I'm adding the test case anyway to demonstrate the brokenness and ensure
// that if a future changes fixes it, it'll be obvious from the PR diff that
// the fix happened.
[
[
[
[
1,
2,
3,
<|> "looooooooooooooooooooooooooooooooooooooooooooooooooong",
"looooooooooooooooooooooooooooooooooooooooooooooooooong",
],
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// At the time of adding this test, the cursor positioning we end up with
// here seems clearly wrong.
// I'm adding the test case anyway to demonstrate the brokenness and ensure
// that if a future changes fixes it, it'll be obvious from the PR diff that
// the fix happened.
[
[
[
[
1,
2,
3 <|> ,"looooooooooooooooooooooooooooooooooooooooooooooooooong",
"looooooooooooooooooooooooooooooooooooooooooooooooooong",
]
]
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// At the time of adding this test, the cursor positioning we end up with
// here seems clearly wrong.
// I'm adding the test case anyway to demonstrate the brokenness and ensure
// that if a future changes fixes it, it'll be obvious from the PR diff that
// the fix happened.
[
[
[
[
1,
2,
3,
<|> "looooooooooooooooooooooooooooooooooooooooooooooooooong",
"looooooooooooooooooooooooooooooooooooooooooooooooooong",
],
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import lib from './lib.js';

function myFunction() { return 'foo'; }<|>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import lib from "./lib.js";

function myFunction() {
return "foo";
}<|>

0 comments on commit 520cef0

Please sign in to comment.