[ci] format

This commit is contained in:
matthewp 2022-05-19 17:12:59 +00:00 committed by github-actions[bot]
parent 4007aebc6a
commit 435518845f
3 changed files with 8 additions and 9 deletions

View file

@ -41,9 +41,8 @@ export function fixViteErrorMessage(_err: unknown, server: ViteDevServer) {
return err; return err;
} }
const incompatiblePackages = { const incompatiblePackages = {
'react-spectrum': `@adobe/react-spectrum is not compatible with Vite's server-side rendering mode at the moment. You can still use React Spectrum from the client. Create an island React component and use the client:only directive. From there you can use React Spectrum.` 'react-spectrum': `@adobe/react-spectrum is not compatible with Vite's server-side rendering mode at the moment. You can still use React Spectrum from the client. Create an island React component and use the client:only directive. From there you can use React Spectrum.`,
}; };
const incompatPackageExp = new RegExp(`(${Object.keys(incompatiblePackages).join('|')})`); const incompatPackageExp = new RegExp(`(${Object.keys(incompatiblePackages).join('|')})`);
@ -52,7 +51,7 @@ function generateHint(err: ErrorWithMetadata): string | undefined {
return 'You likely need to add this package to `vite.ssr.noExternal` in your astro config file.'; return 'You likely need to add this package to `vite.ssr.noExternal` in your astro config file.';
} else { } else {
const res = incompatPackageExp.exec(err.stack); const res = incompatPackageExp.exec(err.stack);
if(res) { if (res) {
const key = res[0] as keyof typeof incompatiblePackages; const key = res[0] as keyof typeof incompatiblePackages;
return incompatiblePackages[key]; return incompatiblePackages[key];
} }

View file

@ -38,11 +38,11 @@ function removeViteHttpMiddleware(server: vite.Connect.Server) {
} }
function truncateString(str: string, n: number) { function truncateString(str: string, n: number) {
if (str.length > n) { if (str.length > n) {
return str.substring(0, n) + '…'; return str.substring(0, n) + '…';
} else { } else {
return str; return str;
} }
} }
function writeHtmlResponse(res: http.ServerResponse, statusCode: number, html: string) { function writeHtmlResponse(res: http.ServerResponse, statusCode: number, html: string) {

View file

@ -21,7 +21,7 @@ describe('Error packages: react-spectrum', () => {
it('properly detect syntax errors in template', async () => { it('properly detect syntax errors in template', async () => {
devServer = await fixture.startDevServer(); devServer = await fixture.startDevServer();
let html = await fixture.fetch('/').then(res => res.text()); let html = await fixture.fetch('/').then((res) => res.text());
let $ = cheerio.load(html); let $ = cheerio.load(html);
const msg = $('.error-message').text(); const msg = $('.error-message').text();
expect(msg).to.match(/@adobe\/react-spectrum is not compatible/); expect(msg).to.match(/@adobe\/react-spectrum is not compatible/);