Skip to content

Commit 40e8450

Browse files
authored
chore: use Biome to format JS files (#10788)
* chore: configuration * chore: update main commands * chore: revert formatting package.json * chore: rebase
1 parent d4c91cb commit 40e8450

File tree

20 files changed

+175
-118
lines changed

20 files changed

+175
-118
lines changed

.prettierignore

+9
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ benchmark/results/
1919

2020
# Files
2121
pnpm-lock.yaml
22+
23+
# Formatted by Biome
24+
**/*.json
25+
**/*.js
26+
**/*.ts
27+
**/*.tsx
28+
**/*.jsx
29+
**/*.mjs
30+
**/*.cjs

biome.json

+37-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,44 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
33
"files": {
4-
"include": ["test/**", "e2e/**", "packages/**"],
5-
"ignore": ["vendor", "dist/**"]
4+
"ignore": ["vendor", "dist/**"],
5+
"include": ["test/**", "e2e/**", "packages/**"]
66
},
7-
"organizeImports": {
8-
"enabled": true
7+
"formatter": {
8+
"indentStyle": "tab",
9+
"indentWidth": 2,
10+
"lineWidth": 100,
11+
"ignore": [
12+
"benchmark/projects/",
13+
"benchmark/results/",
14+
"**/dist/**",
15+
"**/smoke/**",
16+
"**/fixtures/**",
17+
"**/vendor/**",
18+
"**/.vercel/**",
19+
".changeset",
20+
"pnpm-lock.yaml",
21+
"package.json",
22+
"*.astro"
23+
]
924
},
10-
"linter": {
11-
"enabled": false
25+
"organizeImports": { "enabled": true },
26+
"linter": { "enabled": false },
27+
"javascript": {
28+
"formatter": {
29+
"trailingComma": "es5",
30+
"quoteStyle": "single",
31+
"semicolons": "always"
32+
}
1233
},
13-
"formatter": {
14-
"enabled": false
34+
"json": {
35+
"parser": {
36+
"allowComments": true,
37+
"allowTrailingCommas": true
38+
},
39+
"formatter": {
40+
"indentStyle": "space",
41+
"trailingCommas": "none"
42+
}
1543
}
1644
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"dev": "turbo run dev --concurrency=40 --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
1717
"format": "pnpm run format:code && pnpm run format:imports",
1818
"format:ci": "pnpm run format:code:ci && pnpm run format:imports:ci",
19-
"format:code": "prettier -w \"**/*\" --ignore-unknown --cache",
20-
"format:code:ci": "prettier -w \"**/*\" --ignore-unknown --cache --check",
19+
"format:code": "biome format ./ --write && prettier -w \"**/*\" --ignore-unknown --cache",
20+
"format:code:ci": "biome format ./ && prettier -w \"**/*\" --ignore-unknown --cache --check",
2121
"format:imports": "biome check --apply .",
2222
"format:imports:ci": "biome ci .",
2323
"test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
@@ -53,7 +53,7 @@
5353
},
5454
"devDependencies": {
5555
"@astrojs/check": "^0.5.8",
56-
"@biomejs/biome": "1.5.3",
56+
"@biomejs/biome": "1.6.4",
5757
"@changesets/changelog-github": "^0.4.8",
5858
"@changesets/cli": "^2.26.2",
5959
"@eslint/eslintrc": "^3.0.2",

packages/astro-rss/test/rss.test.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ import {
1919

2020
// note: I spent 30 minutes looking for a nice node-based snapshot tool
2121
// ...and I gave up. Enjoy big strings!
22-
// prettier-ignore
22+
23+
// biome-ignore format: keep in one line
2324
const validXmlResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItem.title}]]></title><link>${site}${phpFeedItem.link}/</link><guid isPermaLink="true">${site}${phpFeedItem.link}/</guid><description><![CDATA[${phpFeedItem.description}]]></description><pubDate>${new Date(phpFeedItem.pubDate).toUTCString()}</pubDate></item><item><title><![CDATA[${web1FeedItem.title}]]></title><link>${site}${web1FeedItem.link}/</link><guid isPermaLink="true">${site}${web1FeedItem.link}/</guid><description><![CDATA[${web1FeedItem.description}]]></description><pubDate>${new Date(web1FeedItem.pubDate).toUTCString()}</pubDate></item></channel></rss>`;
24-
// prettier-ignore
25+
// biome-ignore format: keep in one line
2526
const validXmlWithContentResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItemWithContent.title}]]></title><link>${site}${phpFeedItemWithContent.link}/</link><guid isPermaLink="true">${site}${phpFeedItemWithContent.link}/</guid><description><![CDATA[${phpFeedItemWithContent.description}]]></description><pubDate>${new Date(phpFeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${phpFeedItemWithContent.content}]]></content:encoded></item><item><title><![CDATA[${web1FeedItemWithContent.title}]]></title><link>${site}${web1FeedItemWithContent.link}/</link><guid isPermaLink="true">${site}${web1FeedItemWithContent.link}/</guid><description><![CDATA[${web1FeedItemWithContent.description}]]></description><pubDate>${new Date(web1FeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${web1FeedItemWithContent.content}]]></content:encoded></item></channel></rss>`;
26-
// prettier-ignore
27+
// biome-ignore format: keep in one line
2728
const validXmlResultWithAllData = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItem.title}]]></title><link>${site}${phpFeedItem.link}/</link><guid isPermaLink="true">${site}${phpFeedItem.link}/</guid><description><![CDATA[${phpFeedItem.description}]]></description><pubDate>${new Date(phpFeedItem.pubDate).toUTCString()}</pubDate></item><item><title><![CDATA[${web1FeedItemWithAllData.title}]]></title><link>${site}${web1FeedItemWithAllData.link}/</link><guid isPermaLink="true">${site}${web1FeedItemWithAllData.link}/</guid><description><![CDATA[${web1FeedItemWithAllData.description}]]></description><pubDate>${new Date(web1FeedItemWithAllData.pubDate).toUTCString()}</pubDate><category>${web1FeedItemWithAllData.categories[0]}</category><category>${web1FeedItemWithAllData.categories[1]}</category><author>${web1FeedItemWithAllData.author}</author><comments>${web1FeedItemWithAllData.commentsUrl}</comments><source url="${web1FeedItemWithAllData.source.url}">${web1FeedItemWithAllData.source.title}</source><enclosure url="${site}${web1FeedItemWithAllData.enclosure.url}" length="${web1FeedItemWithAllData.enclosure.length}" type="${web1FeedItemWithAllData.enclosure.type}"/></item></channel></rss>`;
28-
// prettier-ignore
29+
// biome-ignore format: keep in one line
2930
const validXmlWithCustomDataResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItemWithCustomData.title}]]></title><link>${site}${phpFeedItemWithCustomData.link}/</link><guid isPermaLink="true">${site}${phpFeedItemWithCustomData.link}/</guid><description><![CDATA[${phpFeedItemWithCustomData.description}]]></description><pubDate>${new Date(phpFeedItemWithCustomData.pubDate).toUTCString()}</pubDate>${phpFeedItemWithCustomData.customData}</item><item><title><![CDATA[${web1FeedItemWithContent.title}]]></title><link>${site}${web1FeedItemWithContent.link}/</link><guid isPermaLink="true">${site}${web1FeedItemWithContent.link}/</guid><description><![CDATA[${web1FeedItemWithContent.description}]]></description><pubDate>${new Date(web1FeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${web1FeedItemWithContent.content}]]></content:encoded></item></channel></rss>`;
30-
// prettier-ignore
31+
// biome-ignore format: keep in one line
3132
const validXmlWithStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.css"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link></channel></rss>`;
32-
// prettier-ignore
33+
// biome-ignore format: keep in one line
3334
const validXmlWithXSLStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.xsl" type="text/xsl"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link></channel></rss>`;
3435

3536
function assertXmlDeepEqual(a, b) {

packages/astro/astro-jsx.d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* Adapted from React’s TypeScript definition from DefinitelyTyped.
1010
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
1111
*/
12-
// BUG! Prettier 3.0 removes `declare`: https://github.com/prettier/prettier/issues/15207
13-
// prettier-ignore
1412
declare namespace astroHTML.JSX {
1513
export type Child = Node | Node[] | string | number | boolean | null | undefined | unknown;
1614
export type Children = Child | Child[];

packages/astro/src/@types/astro.ts

+40-41
Original file line numberDiff line numberDiff line change
@@ -1496,9 +1496,8 @@ export interface AstroUserConfig {
14961496
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
14971497
*
14981498
*/
1499-
// prettier-ignore
1500-
routing?:
1501-
{
1499+
routing?:
1500+
| {
15021501
/**
15031502
* @docs
15041503
* @name i18n.routing.prefixDefaultLocale
@@ -1515,18 +1514,18 @@ export interface AstroUserConfig {
15151514
* When `true`, all URLs will display a language prefix.
15161515
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
15171516
* Localized folders are used for every language, including the default.
1518-
*
1519-
* ```js
1520-
* export default defineConfig({
1521-
* i18n: {
1522-
* defaultLocale: "en",
1523-
* locales: ["en", "fr", "pt-br", "es"],
1524-
* routing: {
1525-
* prefixDefaultLocale: true,
1526-
* }
1527-
* }
1528-
* })
1529-
* ```
1517+
*
1518+
* ```js
1519+
* export default defineConfig({
1520+
* i18n: {
1521+
* defaultLocale: "en",
1522+
* locales: ["en", "fr", "pt-br", "es"],
1523+
* routing: {
1524+
* prefixDefaultLocale: true,
1525+
* }
1526+
* }
1527+
* })
1528+
* ```
15301529
*/
15311530
prefixDefaultLocale?: boolean;
15321531

@@ -1569,32 +1568,32 @@ export interface AstroUserConfig {
15691568
* - `"pathname": The strategy is applied to the pathname of the URLs
15701569
*/
15711570
strategy?: 'pathname';
1572-
} |
1573-
/**
1574-
*
1575-
* @docs
1576-
* @name i18n.routing.manual
1577-
* @kind h4
1578-
* @type {string}
1579-
* @version 4.6.0
1580-
* @description
1581-
* When this option is enabled, Astro will **disable** its i18n middleware so that you can implement your own custom logic. No other `routing` options (e.g. `prefixDefaultLocale`) may be configured with `routing: "manual"`.
1582-
*
1583-
* You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
1584-
*
1585-
* ```js
1586-
* export default defineConfig({
1587-
* i18n: {
1588-
* defaultLocale: "en",
1589-
* locales: ["en", "fr", "pt-br", "es"],
1590-
* routing: {
1591-
* prefixDefaultLocale: true,
1592-
* }
1593-
* }
1594-
* })
1595-
* ```
1596-
*/
1597-
'manual';
1571+
}
1572+
/**
1573+
*
1574+
* @docs
1575+
* @name i18n.routing.manual
1576+
* @kind h4
1577+
* @type {string}
1578+
* @version 4.6.0
1579+
* @description
1580+
* When this option is enabled, Astro will **disable** its i18n middleware so that you can implement your own custom logic. No other `routing` options (e.g. `prefixDefaultLocale`) may be configured with `routing: "manual"`.
1581+
*
1582+
* You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
1583+
*
1584+
* ```js
1585+
* export default defineConfig({
1586+
* i18n: {
1587+
* defaultLocale: "en",
1588+
* locales: ["en", "fr", "pt-br", "es"],
1589+
* routing: {
1590+
* prefixDefaultLocale: true,
1591+
* }
1592+
* }
1593+
* })
1594+
* ```
1595+
*/
1596+
| 'manual';
15981597

15991598
/**
16001599
* @name i18n.domains

packages/astro/src/assets/vite-plugin-assets.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export default function assets({
147147
: settings.config.outDir
148148
)
149149
)});
150-
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
150+
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(
151+
settings.config.build.assets
152+
)}, outDir);
151153
export const getImage = async (options) => await getImageInternal(options, imageConfig);
152154
`;
153155
}

packages/astro/src/cli/install-package.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export async function getPackage<T>(
3939
return packageImport as T;
4040
} catch (e) {
4141
if (options.optional) return undefined;
42-
let message = `To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`;
42+
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
43+
packageName
44+
)}.`;
4345

4446
if (ci.isCI) {
4547
message += ` Packages cannot be installed automatically in CI environments.`;

packages/astro/src/core/errors/dev/utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackIn
171171
error.pluginCode ||
172172
error.id ||
173173
// TODO: this could be better, `src` might be something else
174-
stackText.split('\n').find((ln) => ln.includes('src') || ln.includes('node_modules'));
174+
stackText
175+
.split('\n')
176+
.find((ln) => ln.includes('src') || ln.includes('node_modules'));
175177
// Disable eslint as we're not sure how to improve this regex yet
176178
// eslint-disable-next-line regexp/no-super-linear-backtracking
177179
const source = possibleFilePath?.replace?.(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');

packages/astro/src/core/errors/errors-data.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ export const NoMatchingRenderer = {
168168
169169
${
170170
validRenderersCount > 0
171-
? `There ${plural ? 'are' : 'is'} ${validRenderersCount} renderer${
172-
plural ? 's' : ''
173-
} configured in your \`astro.config.mjs\` file,
171+
? `There ${plural ? 'are' : 'is'} ${validRenderersCount} renderer${plural ? 's' : ''} configured in your \`astro.config.mjs\` file,
174172
but ${plural ? 'none were' : 'it was not'} able to server-side render \`${componentName}\`.`
175173
: `No valid renderer was found ${
176174
componentExtension

packages/astro/src/runtime/client/dev-toolbar/apps/settings.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ export default {
195195
if (placement === settings.config[setting.settingKey]) {
196196
option.selected = true;
197197
}
198-
option.textContent =
199-
`${placement.slice(0, 1).toUpperCase()}${placement.slice(1)}`.replace('-', ' ');
198+
option.textContent = `${placement.slice(0, 1).toUpperCase()}${placement.slice(
199+
1
200+
)}`.replace('-', ' ');
200201
astroSelect.append(option);
201202
});
202203
astroSelect.element.addEventListener('change', setting.changeEvent);

packages/astro/src/runtime/client/dev-toolbar/toolbar.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ export class AstroDevToolbar extends HTMLElement {
256256
width: 1px;
257257
}
258258
</style>
259-
<div id="dev-toolbar-root" data-hidden ${settings.config.disableAppNotification ? 'data-no-notification' : ''} data-placement="${settings.config.placement}">
259+
<div id="dev-toolbar-root" data-hidden ${
260+
settings.config.disableAppNotification ? 'data-no-notification' : ''
261+
} data-placement="${settings.config.placement}">
260262
<div id="dev-bar-hitbox-above"></div>
261263
<div id="dev-bar">
262264
<div id="bar-container">
@@ -281,7 +283,9 @@ export class AstroDevToolbar extends HTMLElement {
281283
: ''
282284
}
283285
<div class="separator"></div>
284-
${this.getAppTemplate(this.apps.find((app) => app.builtIn && app.id === 'astro:settings')!)}
286+
${this.getAppTemplate(
287+
this.apps.find((app) => app.builtIn && app.id === 'astro:settings')!
288+
)}
285289
</div>
286290
</div>
287291
<div id="dev-bar-hitbox-below"></div>

packages/astro/src/runtime/client/dev-toolbar/ui-library/tooltip.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ export class DevToolbarTooltip extends HTMLElement {
138138
: ''
139139
}
140140
${section.content ? `<div class="section-content">${section.content}</div>` : ''}
141-
${section.clickDescription ? `<span class="modal-cta">${section.clickDescription}</span>` : ''}
141+
${
142+
section.clickDescription
143+
? `<span class="modal-cta">${section.clickDescription}</span>`
144+
: ''
145+
}
142146
`;
143147
fragment.append(sectionElement);
144148

packages/astro/src/transitions/router.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ async function transition(
482482
preparationEvent.sourceElement instanceof HTMLFormElement
483483
? preparationEvent.sourceElement
484484
: preparationEvent.sourceElement instanceof HTMLElement &&
485-
'form' in preparationEvent.sourceElement
485+
'form' in preparationEvent.sourceElement
486486
? (preparationEvent.sourceElement.form as HTMLFormElement)
487487
: preparationEvent.sourceElement?.closest('form');
488488
// Form elements without enctype explicitly set default to application/x-www-form-urlencoded.

packages/astro/test/test-adapter.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ export default function (
5252
return new Response(data);
5353
}
5454
55-
${provideAddress ? `request[Symbol.for('astro.clientAddress')] = '0.0.0.0';` : ''}
55+
${
56+
provideAddress
57+
? `request[Symbol.for('astro.clientAddress')] = '0.0.0.0';`
58+
: ''
59+
}
5660
return super.render(request, routeData, locals);
5761
}
5862
}

packages/db/src/core/errors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export const RENAME_COLUMN_ERROR = (oldSelector: string, newSelector: string) =>
3535
);
3636
};
3737

38-
export const FILE_NOT_FOUND_ERROR = (path: string) =>
39-
`${red('▶ File not found:')} ${bold(path)}\n`;
38+
export const FILE_NOT_FOUND_ERROR = (path: string) => `${red('▶ File not found:')} ${bold(path)}\n`;
4039

4140
export const SHELL_QUERY_MISSING_ERROR = `${red(
4241
'▶ Please provide a query to execute using the --query flag.'

packages/db/src/core/schemas.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ export const dateColumnSchema = z.object({
133133
.union([
134134
sqlSchema,
135135
// transform to ISO string for serialization
136-
z.date().transform((d) => d.toISOString()),
136+
z
137+
.date()
138+
.transform((d) => d.toISOString()),
137139
])
138140
.optional(),
139141
}),

packages/upgrade/src/actions/context.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ export async function getContext(argv: string[]): Promise<Context> {
3939
);
4040

4141
const packageManager = detectPackageManager()?.name ?? 'npm';
42-
const { _: [version = 'latest'] = [], '--help': help = false, '--dry-run': dryRun } = flags;
42+
const {
43+
_: [version = 'latest'] = [],
44+
'--help': help = false,
45+
'--dry-run': dryRun,
46+
} = flags;
4347

4448
return {
4549
help,

0 commit comments

Comments
 (0)