Skip to content

Commit

Permalink
Upgrade Prettier to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Apr 25, 2023
1 parent d91ab8e commit 59f7669
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"node-notifier": "^10.0.0",
"p-limit": "^3.1.0",
"pkg-dir": "^5.0.0",
"prettier": "^2.1.1",
"prettier": "3.0.0-alpha.11",
"promise": "^8.0.2",
"read-pkg": "^5.2.0",
"resolve": "^1.20.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
"@babel/preset-typescript": "^7.0.0",
"@types/babel__template": "^7.0.2",
"@types/node": "*",
"@types/prettier": "^2.1.5",
"babel-plugin-tester": "^11.0.2",
"prettier": "^2.1.1"
"prettier": "3.0.0-alpha.11"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/semver": "^7.1.0",
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"prettier": "^2.1.1",
"prettier": "3.0.0-alpha.11",
"tsd-lite": "^0.7.0"
},
"engines": {
Expand Down
10 changes: 6 additions & 4 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const IGNORE_PATTERN = '**/__{tests,mocks}__/**';
const INLINE_REQUIRE_EXCLUDE_LIST =
/packages\/expect|(jest-(circus|diff|get-type|jasmine2|matcher-utils|message-util|regex-util|snapshot))|pretty-format\//;

const prettierConfig = prettier.resolveConfig.sync(
const prettierConfig = await prettier.resolveConfig(
fileURLToPath(import.meta.url),
);
prettierConfig.trailingComma = 'none';
Expand Down Expand Up @@ -76,7 +76,7 @@ function buildNodePackage({packageDir, pkg}) {
process.stdout.write(`${OK}\n`);
}

function buildFile(file, silent) {
async function buildFile(file, silent) {
const destPath = getBuildPath(file, BUILD_DIR);

if (micromatch.isMatch(file, IGNORE_PATTERN)) {
Expand Down Expand Up @@ -131,7 +131,7 @@ function buildFile(file, silent) {
}

const transformed = babel.transformFileSync(file, options).code;
const prettyCode = prettier.format(transformed, prettierConfig);
const prettyCode = await prettier.format(transformed, prettierConfig);

fs.writeFileSync(destPath, prettyCode);

Expand All @@ -150,7 +150,9 @@ function buildFile(file, silent) {
const files = process.argv.slice(2);

if (files.length) {
files.forEach(file => buildFile(file));
for (const file of files) {
await buildFile(file);
}
} else {
const packages = getPackages();
process.stdout.write(chalk.inverse(' Building packages \n'));
Expand Down
4 changes: 2 additions & 2 deletions scripts/bundleTs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import prettier from 'prettier';
import rimraf from 'rimraf';
import {getPackages} from './buildUtils.mjs';

const prettierConfig = prettier.resolveConfig.sync(
const prettierConfig = await prettier.resolveConfig(
fileURLToPath(import.meta.url).replace(/\.js$/, '.d.ts'),
);

Expand Down Expand Up @@ -194,7 +194,7 @@ await Promise.all(
...definitionFile.split(copyrightSnippet),
].join('\n');

const formattedContent = prettier.format(definitionFile, {
const formattedContent = await prettier.format(definitionFile, {
...prettierConfig,
filepath,
});
Expand Down
18 changes: 13 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2886,7 +2886,7 @@ __metadata:
node-notifier: ^10.0.0
p-limit: ^3.1.0
pkg-dir: ^5.0.0
prettier: ^2.1.1
prettier: 3.0.0-alpha.11
promise: ^8.0.2
read-pkg: ^5.2.0
resolve: ^1.20.0
Expand Down Expand Up @@ -6317,9 +6317,8 @@ __metadata:
"@types/babel__template": ^7.0.2
"@types/babel__traverse": ^7.0.6
"@types/node": "*"
"@types/prettier": ^2.1.5
babel-plugin-tester: ^11.0.2
prettier: ^2.1.1
prettier: 3.0.0-alpha.11
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -13201,7 +13200,7 @@ __metadata:
jest-message-util: "workspace:^"
jest-util: "workspace:^"
natural-compare: ^1.4.0
prettier: ^2.1.1
prettier: 3.0.0-alpha.11
pretty-format: "workspace:^"
semver: ^7.3.5
tsd-lite: ^0.7.0
Expand Down Expand Up @@ -17194,7 +17193,16 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^2.1.1, prettier@npm:^2.8.3":
"prettier@npm:3.0.0-alpha.11":
version: 3.0.0-alpha.11
resolution: "prettier@npm:3.0.0-alpha.11"
bin:
prettier: bin/prettier.cjs
checksum: ce0a252201cc3758825a0e03d895bd88c876daf6cc9aab1365ef3164075807535146ad3d338582f652337d23914480fac309d84b3558f9576b6d2bd8bdbed57b
languageName: node
linkType: hard

"prettier@npm:^2.8.3":
version: 2.8.7
resolution: "prettier@npm:2.8.7"
bin:
Expand Down

0 comments on commit 59f7669

Please sign in to comment.