Skip to content

Commit e1dd51d

Browse files
Copilotneilime
andcommitted
Add migration to remove prettier oxc plugin and update e2e tests
Co-authored-by: neilime <[email protected]>
1 parent 4a9796f commit e1dd51d

File tree

6 files changed

+115
-0
lines changed

6 files changed

+115
-0
lines changed

TODO-PRETTIER-OXC.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# TODO: Re-enable Prettier OXC Plugin
2+
3+
## Background
4+
5+
The `@prettier/plugin-oxc` plugin was temporarily disabled due to stability issues. The plugin was removed in migration `20250623095600-remove-prettier-oxc.ts`.
6+
7+
## Action Required
8+
9+
When a stable release of `@prettier/plugin-oxc` becomes available:
10+
11+
1. Create a new migration to re-add the plugin to the prettier configuration
12+
2. Update the migration to add:
13+
```json
14+
{
15+
"prettier": {
16+
"plugins": ["@prettier/plugin-oxc"]
17+
}
18+
}
19+
```
20+
3. Test thoroughly to ensure the plugin is stable
21+
4. Update this file or remove it once completed
22+
23+
## Related Files
24+
25+
- Migration that added the plugin: `packages/core/src/install/migrations/20250623095500-add-prettier-oxc.ts`
26+
- Migration that removed the plugin: `packages/core/src/install/migrations/20250623095600-remove-prettier-oxc.ts`
27+
28+
## References
29+
30+
- Prettier OXC Plugin: https://github.com/prettier/plugin-oxc
31+
- Monitor releases: https://github.com/prettier/plugin-oxc/releases

packages/core/src/core.e2e.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ describe(`E2E - ${packageToTest}`, () => {
9494

9595
expect(buildStderr).toBeFalsy();
9696
expect(buildCode).toBe(0);
97+
98+
const { code: formatCode, stderr: formatStderr } = await exec(testProjectDir, "npm run format");
99+
100+
expect(formatStderr).toBeFalsy();
101+
expect(formatCode).toBe(0);
97102
}, 200000);
98103
});
99104

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { PackageJson } from "../../services/PackageJson";
2+
import { createProjectForTestFile, deleteTestProject } from "../../tests/test-project";
3+
import { up } from "./20250623095600-remove-prettier-oxc";
4+
5+
// Set to false to avoid using the cache
6+
const useCache = true;
7+
// Set to false to inspect the test project directory after the test
8+
const shouldCleanupAfterTest = true;
9+
10+
describe("Migration 20250623095600-remove-prettier-oxc", () => {
11+
let testProjectDir: string;
12+
13+
beforeAll(async () => {
14+
if (!useCache) {
15+
console.warn("Cache is disabled. Enable it one dev is done.");
16+
}
17+
if (!shouldCleanupAfterTest) {
18+
console.warn("Cleanup is disabled. Enable it one dev is done.");
19+
}
20+
21+
testProjectDir = await createProjectForTestFile(__filename, useCache);
22+
});
23+
24+
afterEach(async () => {
25+
if (shouldCleanupAfterTest) {
26+
await deleteTestProject(__filename);
27+
}
28+
});
29+
30+
describe("Up", () => {
31+
it("should apply migration and remove prettier plugins", async () => {
32+
// First, add the prettier oxc plugin to simulate the previous migration
33+
const packageJson = PackageJson.fromDirPath(testProjectDir);
34+
packageJson.merge({
35+
prettier: {
36+
plugins: ["@prettier/plugin-oxc"],
37+
},
38+
});
39+
40+
// Apply the migration to remove it
41+
await up(testProjectDir);
42+
43+
const packageJsonContent = PackageJson.fromDirPath(testProjectDir).getContent();
44+
45+
expect(packageJsonContent).toMatchSnapshot();
46+
});
47+
});
48+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { MigrationUpFunction } from "../../services/MigrationsService";
2+
import { JsonFileData, PackageJson } from "../../services/PackageJson";
3+
4+
export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promise<void> => {
5+
const packageJson = PackageJson.fromDirPath(absoluteProjectDir);
6+
7+
const packageJsonContent = packageJson.getContent();
8+
9+
// Remove prettier.plugins if it exists
10+
if (packageJsonContent.prettier && typeof packageJsonContent.prettier === "object") {
11+
const prettierConfig = packageJsonContent.prettier as JsonFileData;
12+
if (prettierConfig.plugins) {
13+
delete prettierConfig.plugins;
14+
packageJson.setContent(packageJsonContent);
15+
}
16+
}
17+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`Migration 20250623095600-remove-prettier-oxc Up should apply migration and remove prettier plugins 1`] = `
4+
{
5+
"license": "MIT",
6+
"prettier": {},
7+
"version": "1.0.0",
8+
}
9+
`;

packages/react/src/react.e2e.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ describe(`E2E - ${packageToTest}`, () => {
9292

9393
expect(buildStderr).toBeFalsy();
9494
expect(buildCode).toBe(0);
95+
96+
const { code: formatCode, stderr: formatStderr } = await exec(testProjectDir, "npm run format");
97+
98+
expect(formatStderr).toBeFalsy();
99+
expect(formatCode).toBe(0);
95100
}, 200000);
96101
});
97102

0 commit comments

Comments
 (0)