0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

chore: use Biome to format JS files (#10788)

* chore: configuration

* chore: update main commands

* chore: revert formatting package.json

* chore: rebase
This commit is contained in:
Emanuele Stoppa 2024-04-17 09:37:22 +01:00 committed by GitHub
parent d4c91cb109
commit 40e8450671
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 174 additions and 117 deletions

View file

@ -19,3 +19,12 @@ benchmark/results/
# Files
pnpm-lock.yaml
# Formatted by Biome
**/*.json
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
**/*.mjs
**/*.cjs

View file

@ -1,16 +1,44 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"files": {
"include": ["test/**", "e2e/**", "packages/**"],
"ignore": ["vendor", "dist/**"]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
"ignore": ["vendor", "dist/**"],
"include": ["test/**", "e2e/**", "packages/**"]
},
"formatter": {
"enabled": false
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 100,
"ignore": [
"benchmark/projects/",
"benchmark/results/",
"**/dist/**",
"**/smoke/**",
"**/fixtures/**",
"**/vendor/**",
"**/.vercel/**",
".changeset",
"pnpm-lock.yaml",
"package.json",
"*.astro"
]
},
"organizeImports": { "enabled": true },
"linter": { "enabled": false },
"javascript": {
"formatter": {
"trailingComma": "es5",
"quoteStyle": "single",
"semicolons": "always"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
},
"formatter": {
"indentStyle": "space",
"trailingCommas": "none"
}
}
}

View file

@ -16,8 +16,8 @@
"dev": "turbo run dev --concurrency=40 --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"format": "pnpm run format:code && pnpm run format:imports",
"format:ci": "pnpm run format:code:ci && pnpm run format:imports:ci",
"format:code": "prettier -w \"**/*\" --ignore-unknown --cache",
"format:code:ci": "prettier -w \"**/*\" --ignore-unknown --cache --check",
"format:code": "biome format ./ --write && prettier -w \"**/*\" --ignore-unknown --cache",
"format:code:ci": "biome format ./ && prettier -w \"**/*\" --ignore-unknown --cache --check",
"format:imports": "biome check --apply .",
"format:imports:ci": "biome ci .",
"test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
@ -53,7 +53,7 @@
},
"devDependencies": {
"@astrojs/check": "^0.5.8",
"@biomejs/biome": "1.5.3",
"@biomejs/biome": "1.6.4",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@eslint/eslintrc": "^3.0.2",

View file

@ -19,17 +19,18 @@ import {
// note: I spent 30 minutes looking for a nice node-based snapshot tool
// ...and I gave up. Enjoy big strings!
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
// prettier-ignore
// biome-ignore format: keep in one line
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>`;
function assertXmlDeepEqual(a, b) {

View file

@ -9,8 +9,6 @@
* Adapted from Reacts TypeScript definition from DefinitelyTyped.
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
*/
// BUG! Prettier 3.0 removes `declare`: https://github.com/prettier/prettier/issues/15207
// prettier-ignore
declare namespace astroHTML.JSX {
export type Child = Node | Node[] | string | number | boolean | null | undefined | unknown;
export type Children = Child | Child[];

View file

@ -1496,9 +1496,8 @@ export interface AstroUserConfig {
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
*
*/
// prettier-ignore
routing?:
{
| {
/**
* @docs
* @name i18n.routing.prefixDefaultLocale
@ -1569,7 +1568,7 @@ export interface AstroUserConfig {
* - `"pathname": The strategy is applied to the pathname of the URLs
*/
strategy?: 'pathname';
} |
}
/**
*
* @docs
@ -1594,7 +1593,7 @@ export interface AstroUserConfig {
* })
* ```
*/
'manual';
| 'manual';
/**
* @name i18n.domains

View file

@ -147,7 +147,9 @@ export default function assets({
: settings.config.outDir
)
)});
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(
settings.config.build.assets
)}, outDir);
export const getImage = async (options) => await getImageInternal(options, imageConfig);
`;
}

View file

@ -39,7 +39,9 @@ export async function getPackage<T>(
return packageImport as T;
} catch (e) {
if (options.optional) return undefined;
let message = `To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`;
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
packageName
)}.`;
if (ci.isCI) {
message += ` Packages cannot be installed automatically in CI environments.`;

View file

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

View file

@ -168,9 +168,7 @@ export const NoMatchingRenderer = {
${
validRenderersCount > 0
? `There ${plural ? 'are' : 'is'} ${validRenderersCount} renderer${
plural ? 's' : ''
} configured in your \`astro.config.mjs\` file,
? `There ${plural ? 'are' : 'is'} ${validRenderersCount} renderer${plural ? 's' : ''} configured in your \`astro.config.mjs\` file,
but ${plural ? 'none were' : 'it was not'} able to server-side render \`${componentName}\`.`
: `No valid renderer was found ${
componentExtension

View file

@ -195,8 +195,9 @@ export default {
if (placement === settings.config[setting.settingKey]) {
option.selected = true;
}
option.textContent =
`${placement.slice(0, 1).toUpperCase()}${placement.slice(1)}`.replace('-', ' ');
option.textContent = `${placement.slice(0, 1).toUpperCase()}${placement.slice(
1
)}`.replace('-', ' ');
astroSelect.append(option);
});
astroSelect.element.addEventListener('change', setting.changeEvent);

View file

@ -256,7 +256,9 @@ export class AstroDevToolbar extends HTMLElement {
width: 1px;
}
</style>
<div id="dev-toolbar-root" data-hidden ${settings.config.disableAppNotification ? 'data-no-notification' : ''} data-placement="${settings.config.placement}">
<div id="dev-toolbar-root" data-hidden ${
settings.config.disableAppNotification ? 'data-no-notification' : ''
} data-placement="${settings.config.placement}">
<div id="dev-bar-hitbox-above"></div>
<div id="dev-bar">
<div id="bar-container">
@ -281,7 +283,9 @@ export class AstroDevToolbar extends HTMLElement {
: ''
}
<div class="separator"></div>
${this.getAppTemplate(this.apps.find((app) => app.builtIn && app.id === 'astro:settings')!)}
${this.getAppTemplate(
this.apps.find((app) => app.builtIn && app.id === 'astro:settings')!
)}
</div>
</div>
<div id="dev-bar-hitbox-below"></div>

View file

@ -138,7 +138,11 @@ export class DevToolbarTooltip extends HTMLElement {
: ''
}
${section.content ? `<div class="section-content">${section.content}</div>` : ''}
${section.clickDescription ? `<span class="modal-cta">${section.clickDescription}</span>` : ''}
${
section.clickDescription
? `<span class="modal-cta">${section.clickDescription}</span>`
: ''
}
`;
fragment.append(sectionElement);

View file

@ -52,7 +52,11 @@ export default function (
return new Response(data);
}
${provideAddress ? `request[Symbol.for('astro.clientAddress')] = '0.0.0.0';` : ''}
${
provideAddress
? `request[Symbol.for('astro.clientAddress')] = '0.0.0.0';`
: ''
}
return super.render(request, routeData, locals);
}
}

View file

@ -35,8 +35,7 @@ export const RENAME_COLUMN_ERROR = (oldSelector: string, newSelector: string) =>
);
};
export const FILE_NOT_FOUND_ERROR = (path: string) =>
`${red('▶ File not found:')} ${bold(path)}\n`;
export const FILE_NOT_FOUND_ERROR = (path: string) => `${red('▶ File not found:')} ${bold(path)}\n`;
export const SHELL_QUERY_MISSING_ERROR = `${red(
'▶ Please provide a query to execute using the --query flag.'

View file

@ -133,7 +133,9 @@ export const dateColumnSchema = z.object({
.union([
sqlSchema,
// transform to ISO string for serialization
z.date().transform((d) => d.toISOString()),
z
.date()
.transform((d) => d.toISOString()),
])
.optional(),
}),

View file

@ -39,7 +39,11 @@ export async function getContext(argv: string[]): Promise<Context> {
);
const packageManager = detectPackageManager()?.name ?? 'npm';
const { _: [version = 'latest'] = [], '--help': help = false, '--dry-run': dryRun } = flags;
const {
_: [version = 'latest'] = [],
'--help': help = false,
'--dry-run': dryRun,
} = flags;
return {
help,

View file

@ -22,8 +22,8 @@ importers:
specifier: ^0.5.8
version: 0.5.10(prettier-plugin-astro@0.12.3)(prettier@3.2.5)(typescript@5.2.2)
'@biomejs/biome':
specifier: 1.5.3
version: 1.5.3
specifier: 1.6.4
version: 1.6.4
'@changesets/changelog-github':
specifier: ^0.4.8
version: 0.4.8
@ -6120,88 +6120,88 @@ packages:
'@babel/helper-validator-identifier': 7.22.20
to-fast-properties: 2.0.0
/@biomejs/biome@1.5.3:
resolution: {integrity: sha512-yvZCa/g3akwTaAQ7PCwPWDCkZs3Qa5ONg/fgOUT9e6wAWsPftCjLQFPXBeGxPK30yZSSpgEmRCfpGTmVbUjGgg==}
engines: {node: '>=14.*'}
/@biomejs/biome@1.6.4:
resolution: {integrity: sha512-3groVd2oWsLC0ZU+XXgHSNbq31lUcOCBkCcA7sAQGBopHcmL+jmmdoWlY3S61zIh+f2mqQTQte1g6PZKb3JJjA==}
engines: {node: '>=14.21.3'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@biomejs/cli-darwin-arm64': 1.5.3
'@biomejs/cli-darwin-x64': 1.5.3
'@biomejs/cli-linux-arm64': 1.5.3
'@biomejs/cli-linux-arm64-musl': 1.5.3
'@biomejs/cli-linux-x64': 1.5.3
'@biomejs/cli-linux-x64-musl': 1.5.3
'@biomejs/cli-win32-arm64': 1.5.3
'@biomejs/cli-win32-x64': 1.5.3
'@biomejs/cli-darwin-arm64': 1.6.4
'@biomejs/cli-darwin-x64': 1.6.4
'@biomejs/cli-linux-arm64': 1.6.4
'@biomejs/cli-linux-arm64-musl': 1.6.4
'@biomejs/cli-linux-x64': 1.6.4
'@biomejs/cli-linux-x64-musl': 1.6.4
'@biomejs/cli-win32-arm64': 1.6.4
'@biomejs/cli-win32-x64': 1.6.4
dev: true
/@biomejs/cli-darwin-arm64@1.5.3:
resolution: {integrity: sha512-ImU7mh1HghEDyqNmxEZBoMPr8SxekkZuYcs+gynKlNW+TALQs7swkERiBLkG9NR0K1B3/2uVzlvYowXrmlW8hw==}
engines: {node: '>=14.*'}
/@biomejs/cli-darwin-arm64@1.6.4:
resolution: {integrity: sha512-2WZef8byI9NRzGajGj5RTrroW9BxtfbP9etigW1QGAtwu/6+cLkdPOWRAs7uFtaxBNiKFYA8j/BxV5zeAo5QOQ==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-darwin-x64@1.5.3:
resolution: {integrity: sha512-vCdASqYnlpq/swErH7FD6nrFz0czFtK4k/iLgj0/+VmZVjineFPgevOb+Sr9vz0tk0GfdQO60bSpI74zU8M9Dw==}
engines: {node: '>=14.*'}
/@biomejs/cli-darwin-x64@1.6.4:
resolution: {integrity: sha512-uo1zgM7jvzcoDpF6dbGizejDLCqNpUIRkCj/oEK0PB0NUw8re/cn1EnxuOLZqDpn+8G75COLQTOx8UQIBBN/Kg==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-linux-arm64-musl@1.5.3:
resolution: {integrity: sha512-DYuMizUYUBYfS0IHGjDrOP1RGipqWfMGEvNEJ398zdtmCKLXaUvTimiox5dvx4X15mBK5M2m8wgWUgOP1giUpQ==}
engines: {node: '>=14.*'}
/@biomejs/cli-linux-arm64-musl@1.6.4:
resolution: {integrity: sha512-Hp8Jwt6rjj0wCcYAEN6/cfwrrPLLlGOXZ56Lei4Pt4jy39+UuPeAVFPeclrrCfxyL1wQ2xPrhd/saTHSL6DoJg==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-linux-arm64@1.5.3:
resolution: {integrity: sha512-cupBQv0sNF1OKqBfx7EDWMSsKwRrBUZfjXawT4s6hKV6ALq7p0QzWlxr/sDmbKMLOaLQtw2Qgu/77N9rm+f9Rg==}
engines: {node: '>=14.*'}
/@biomejs/cli-linux-arm64@1.6.4:
resolution: {integrity: sha512-wAOieaMNIpLrxGc2/xNvM//CIZg7ueWy3V5A4T7gDZ3OL/Go27EKE59a+vMKsBCYmTt7jFl4yHz0TUkUbodA/w==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-linux-x64-musl@1.5.3:
resolution: {integrity: sha512-UUHiAnlDqr2Y/LpvshBFhUYMWkl2/Jn+bi3U6jKuav0qWbbBKU/ByHgR4+NBxpKBYoCtWxhnmatfH1bpPIuZMw==}
engines: {node: '>=14.*'}
/@biomejs/cli-linux-x64-musl@1.6.4:
resolution: {integrity: sha512-wqi0hr8KAx5kBO0B+m5u8QqiYFFBJOSJVSuRqTeGWW+GYLVUtXNidykNqf1JsW6jJDpbkSp2xHKE/bTlVaG2Kg==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-linux-x64@1.5.3:
resolution: {integrity: sha512-YQrSArQvcv4FYsk7Q91Yv4uuu5F8hJyORVcv3zsjCLGkjIjx2RhjYLpTL733SNL7v33GmOlZY0eFR1ko38tuUw==}
engines: {node: '>=14.*'}
/@biomejs/cli-linux-x64@1.6.4:
resolution: {integrity: sha512-qTWhuIw+/ePvOkjE9Zxf5OqSCYxtAvcTJtVmZT8YQnmY2I62JKNV2m7tf6O5ViKZUOP0mOQ6NgqHKcHH1eT8jw==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-win32-arm64@1.5.3:
resolution: {integrity: sha512-HxatYH7vf/kX9nrD+pDYuV2GI9GV8EFo6cfKkahAecTuZLPxryHx1WEfJthp5eNsE0+09STGkKIKjirP0ufaZA==}
engines: {node: '>=14.*'}
/@biomejs/cli-win32-arm64@1.6.4:
resolution: {integrity: sha512-Wp3FiEeF6v6C5qMfLkHwf4YsoNHr/n0efvoC8jCKO/kX05OXaVExj+1uVQ1eGT7Pvx0XVm/TLprRO0vq/V6UzA==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@biomejs/cli-win32-x64@1.5.3:
resolution: {integrity: sha512-fMvbSouZEASU7mZH8SIJSANDm5OqsjgtVXlbUqxwed6BP7uuHRSs396Aqwh2+VoW8fwTpp6ybIUoC9FrzB0kyA==}
engines: {node: '>=14.*'}
/@biomejs/cli-win32-x64@1.6.4:
resolution: {integrity: sha512-mz183Di5hTSGP7KjNWEhivcP1wnHLGmOxEROvoFsIxMYtDhzJDad4k5gI/1JbmA0xe4n52vsgqo09tBhrMT/Zg==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [win32]
requiresBuild: true

View file

@ -9,7 +9,7 @@ export default {
plugins: ['prettier-plugin-astro'],
overrides: [
{
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
files: ['.*', '*.md', '*.toml', '*.yml'],
options: {
useTabs: false,
},