Skip to content

Commit 5b91929

Browse files
authored
Upgrade prettier to be consistent across all packages (#855)
This pull request updates the test suites and dependencies for both the Preact and React transform packages to improve compatibility with Prettier v3 and to ensure all code formatting and test cases handle asynchronous formatting operations. The most significant changes are the upgrade of Prettier, the removal of obsolete type dependencies, and the refactoring of test cases to use async/await for formatting and assertions. **Dependency updates:** * Upgraded the `prettier` dependency to version 3.0.0 in both `preact-transform` and `react-transform` packages, and removed the now-unnecessary `@types/prettier` dependency.
1 parent 19ac39b commit 5b91929

File tree

6 files changed

+115
-117
lines changed

6 files changed

+115
-117
lines changed

docs/demos/todo/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const TodosViewModel: ModelConstructor<TodosViewModel> = createModel(() => {
136136
};
137137

138138
const debugData = computed(() => {
139-
return JSON.stringify({todosModel, filter, filteredTodos}, null, 2);
139+
return JSON.stringify({ todosModel, filter, filteredTodos }, null, 2);
140140
});
141141

142142
return {

packages/preact-transform/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@
5858
"@types/babel__helper-module-imports": "^7.18.3",
5959
"@types/babel__helper-plugin-utils": "^7.10.3",
6060
"@types/debug": "^4.1.12",
61-
"@types/prettier": "^2.7.3",
6261
"assert": "^2.0.0",
6362
"buffer": "^6.0.3",
6463
"path": "^0.12.7",
65-
"prettier": "^2.7.1"
64+
"prettier": "^3.0.0"
6665
},
6766
"publishConfig": {
6867
"access": "public",

packages/preact-transform/test/node/index.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ function transformCode(
2525
return result?.code || "";
2626
}
2727

28-
function runTest(
28+
async function runTest(
2929
input: string,
3030
expected: string,
3131
options: PluginOptions = { enabled: true },
3232
filename?: string,
3333
cjs?: boolean
3434
) {
3535
const output = transformCode(input, options, filename, cjs);
36-
expect(format(output)).to.equal(format(expected));
36+
expect(await format(output)).to.equal(await format(expected));
3737
}
3838

3939
describe("Preact Signals Babel Transform", () => {
4040
describe("signal naming", () => {
4141
const DEBUG_OPTIONS = { enabled: true };
4242

43-
const runDebugTest = (
43+
const runDebugTest = async (
4444
inputCode: string,
4545
expectedOutput: string,
4646
fileName: string
4747
) => {
48-
runTest(inputCode, expectedOutput, DEBUG_OPTIONS, fileName);
48+
await runTest(inputCode, expectedOutput, DEBUG_OPTIONS, fileName);
4949
};
5050

51-
it("injects names for signal calls", () => {
51+
it("injects names for signal calls", async () => {
5252
const inputCode = `
5353
function MyComponent() {
5454
const count = signal(0);
@@ -69,10 +69,10 @@ describe("Preact Signals Babel Transform", () => {
6969
}
7070
`;
7171

72-
runDebugTest(inputCode, expectedOutput, "Component.js");
72+
await runDebugTest(inputCode, expectedOutput, "Component.js");
7373
});
7474

75-
it("injects names for useSignal calls", () => {
75+
it("injects names for useSignal calls", async () => {
7676
const inputCode = `
7777
function MyComponent() {
7878
const count = useSignal(0);
@@ -93,10 +93,10 @@ describe("Preact Signals Babel Transform", () => {
9393
}
9494
`;
9595

96-
runDebugTest(inputCode, expectedOutput, "Component.js");
96+
await runDebugTest(inputCode, expectedOutput, "Component.js");
9797
});
9898

99-
it("doesn't inject names when already provided", () => {
99+
it("doesn't inject names when already provided", async () => {
100100
const inputCode = `
101101
function MyComponent() {
102102
const count = signal(0, { name: "myCounter" });
@@ -118,10 +118,10 @@ describe("Preact Signals Babel Transform", () => {
118118
}
119119
`;
120120

121-
runDebugTest(inputCode, expectedOutput, "Component.js");
121+
await runDebugTest(inputCode, expectedOutput, "Component.js");
122122
});
123123

124-
it("handles signals with no initial value", () => {
124+
it("handles signals with no initial value", async () => {
125125
const inputCode = `
126126
function MyComponent() {
127127
const count = useSignal();
@@ -138,7 +138,7 @@ describe("Preact Signals Babel Transform", () => {
138138
}
139139
`;
140140

141-
runDebugTest(inputCode, expectedOutput, "Component.js");
141+
await runDebugTest(inputCode, expectedOutput, "Component.js");
142142
});
143143
});
144144
});

packages/react-transform/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@
6262
"@types/babel__helper-module-imports": "^7.18.3",
6363
"@types/babel__helper-plugin-utils": "^7.10.3",
6464
"@types/debug": "^4.1.12",
65-
"@types/prettier": "^2.7.3",
6665
"@types/react": "^18.0.18",
6766
"@types/react-dom": "^18.0.6",
6867
"@types/use-sync-external-store": "^0.0.3",
6968
"assert": "^2.0.0",
7069
"buffer": "^6.0.3",
7170
"path": "^0.12.7",
72-
"prettier": "^2.7.1",
71+
"prettier": "^3.0.0",
7372
"react": "^18.2.0",
7473
"react-dom": "^18.2.0",
7574
"react-router-dom": "^6.9.0"

0 commit comments

Comments
 (0)