Skip to content

Commit eaecdcf

Browse files
Copilotneilime
andcommitted
Address PR feedback: remove only oxc plugin from array and delete TODO file
Co-authored-by: neilime <[email protected]>
1 parent a07a04a commit eaecdcf

File tree

6 files changed

+47
-38
lines changed

6 files changed

+47
-38
lines changed

TODO-PRETTIER-OXC.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ exports[`E2E - core Simple project Installs core package 2`] = `
103103

104104
exports[`E2E - core Simple project Installs core package 3`] = `
105105
{
106+
"plugins": [],
106107
"printWidth": 100,
107108
"semi": true,
108109
"trailingComma": "es5",

packages/core/src/install/migrations/20250623095600-remove-prettier-oxc.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ describe("Migration 20250623095600-remove-prettier-oxc", () => {
1717
if (!shouldCleanupAfterTest) {
1818
console.warn("Cleanup is disabled. Enable it once dev is done.");
1919
}
20+
});
2021

22+
beforeEach(async () => {
2123
testProjectDir = await createProjectForTestFile(__filename, useCache);
2224
});
2325

@@ -28,7 +30,7 @@ describe("Migration 20250623095600-remove-prettier-oxc", () => {
2830
});
2931

3032
describe("Up", () => {
31-
it("should apply migration and remove prettier plugins", async () => {
33+
it("should remove only @prettier/plugin-oxc from plugins array", async () => {
3234
// First, add the prettier oxc plugin to simulate the previous migration
3335
const packageJson = PackageJson.fromDirPath(testProjectDir);
3436
packageJson.merge({
@@ -44,5 +46,22 @@ describe("Migration 20250623095600-remove-prettier-oxc", () => {
4446

4547
expect(packageJsonContent).toMatchSnapshot();
4648
});
49+
50+
it("should keep other plugins when removing @prettier/plugin-oxc", async () => {
51+
// Add prettier config with multiple plugins
52+
const packageJson = PackageJson.fromDirPath(testProjectDir);
53+
packageJson.merge({
54+
prettier: {
55+
plugins: ["@prettier/plugin-oxc", "prettier-plugin-other"],
56+
},
57+
});
58+
59+
// Apply the migration
60+
await up(testProjectDir);
61+
62+
const packageJsonContent = PackageJson.fromDirPath(testProjectDir).getContent();
63+
64+
expect(packageJsonContent).toMatchSnapshot();
65+
});
4766
});
4867
});

packages/core/src/install/migrations/20250623095600-remove-prettier-oxc.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ export const up: MigrationUpFunction = async (absoluteProjectDir: string): Promi
66

77
const packageJsonContent = packageJson.getContent();
88

9-
// Remove prettier.plugins if it exists
9+
// Remove @prettier/plugin-oxc from prettier.plugins if it exists
1010
if (packageJsonContent.prettier && typeof packageJsonContent.prettier === "object") {
1111
const prettierConfig = packageJsonContent.prettier as JsonFileData;
12-
if (prettierConfig.plugins) {
13-
delete prettierConfig.plugins;
14-
packageJson.setContent(packageJsonContent);
12+
if (Array.isArray(prettierConfig.plugins)) {
13+
const plugins = prettierConfig.plugins as string[];
14+
const filteredPlugins = plugins.filter((plugin) => plugin !== "@prettier/plugin-oxc");
15+
16+
if (filteredPlugins.length !== plugins.length) {
17+
prettierConfig.plugins = filteredPlugins;
18+
packageJson.setContent(packageJsonContent);
19+
}
1520
}
1621
}
1722
};
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`Migration 20250623095600-remove-prettier-oxc Up should apply migration and remove prettier plugins 1`] = `
3+
exports[`Migration 20250623095600-remove-prettier-oxc Up should keep other plugins when removing @prettier/plugin-oxc 1`] = `
44
{
55
"license": "MIT",
6-
"prettier": {},
6+
"prettier": {
7+
"plugins": [
8+
"prettier-plugin-other",
9+
],
10+
},
11+
"version": "1.0.0",
12+
}
13+
`;
14+
15+
exports[`Migration 20250623095600-remove-prettier-oxc Up should remove only @prettier/plugin-oxc from plugins array 1`] = `
16+
{
17+
"license": "MIT",
18+
"prettier": {
19+
"plugins": [],
20+
},
721
"version": "1.0.0",
822
}
923
`;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ exports[`E2E - react Simple project Installs react package 2`] = `
126126

127127
exports[`E2E - react Simple project Installs react package 3`] = `
128128
{
129+
"plugins": [],
129130
"printWidth": 100,
130131
"semi": true,
131132
"trailingComma": "es5",

0 commit comments

Comments
 (0)