Fix eslint warnings (#9721)

* Fix eslint warnings

* Revert endpoint changes to be safe
This commit is contained in:
Bjorn Lu 2024-01-18 23:54:28 +08:00 committed by GitHub
parent 2292d0b580
commit 259c30e7fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 13 additions and 24 deletions

View file

@ -23,8 +23,6 @@ chai.use(chaiXml);
// prettier-ignore
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
const validXmlWithoutWeb1FeedResult = `<?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></channel></rss>`;
// prettier-ignore
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
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>`;

View file

@ -71,6 +71,7 @@ export const GET: APIRoute = async ({ request }) => {
},
});
} catch (err: unknown) {
// eslint-disable-next-line no-console
console.error('Could not process image request:', err);
return new Response(`Server Error: ${err}`, { status: 500 });
}

View file

@ -89,6 +89,7 @@ export const GET: APIRoute = async ({ request }) => {
},
});
} catch (err: unknown) {
// eslint-disable-next-line no-console
console.error('Could not process image request:', err);
return new Response(`Server Error: ${err}`, { status: 500 });
}

View file

@ -10,12 +10,7 @@ import { resolveConfig } from '../../core/config/config.js';
import { createSettings } from '../../core/config/settings.js';
import * as msg from '../../core/messages.js';
import { DEFAULT_PREFERENCES } from '../../preferences/defaults.js';
import {
coerce,
isValidKey,
type PreferenceKey,
type PreferenceLocation,
} from '../../preferences/index.js';
import { coerce, isValidKey, type PreferenceKey } from '../../preferences/index.js';
import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
// @ts-expect-error flattie types are mispackaged
import { flattie } from 'flattie';

View file

@ -106,6 +106,7 @@ export class NodeApp extends App {
// an error in the ReadableStream's cancel callback, but
// also because of an error anywhere in the stream.
reader.cancel().catch((err) => {
// eslint-disable-next-line no-console
console.error(
`There was an uncaught error in the middle of the stream while rendering ${destination.req.url}.`,
err

View file

@ -484,9 +484,8 @@ async function generatePath(
gopts: GeneratePathOptions,
route: RouteData
) {
const { mod, scripts: hoistedScripts, styles: _styles, pageData } = gopts;
const { mod, scripts: hoistedScripts, styles: _styles } = gopts;
const manifest = pipeline.getManifest();
const logger = pipeline.getLogger();
pipeline.getEnvironment().logger.debug('build', `Generating: ${pathname}`);
const links = new Set<never>();

View file

@ -7,7 +7,7 @@ type ConsoleStream = Writable & {
};
export const nodeLogDestination: LogWritable<LogMessage> = {
write(event: LogMessage, newLine = true) {
write(event: LogMessage) {
let dest: ConsoleStream = process.stderr;
if (levels[event.level] < levels['error']) {
dest = process.stdout;

View file

@ -2,7 +2,6 @@ import { appendForwardSlash, joinPaths } from '@astrojs/internal-helpers/path';
import type { Locales, MiddlewareHandler, RouteData, SSRManifest } from '../@types/astro.js';
import type { PipelineHookFunction } from '../core/pipeline.js';
import { getPathByLocale, normalizeTheLocale } from './index.js';
import { shouldAppendForwardSlash } from '../core/build/util.js';
const routeDataSymbol = Symbol.for('astro.routeData');

View file

@ -1,5 +1,5 @@
import { bold } from 'kleur/colors';
import type { APIContext, EndpointHandler, Params } from '../../@types/astro.js';
import type { APIContext, EndpointHandler } from '../../@types/astro.js';
import type { Logger } from '../../core/logger/core.js';
/** Renders an endpoint request to completion, returning the body. */

View file

@ -28,7 +28,7 @@ const kebab = (k: string) =>
k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
const toStyleString = (obj: Record<string, any>) =>
Object.entries(obj)
.filter(([k, v]) => (typeof v === 'string' && v.trim()) || typeof v === 'number')
.filter(([_, v]) => (typeof v === 'string' && v.trim()) || typeof v === 'number')
.map(([k, v]) => {
if (k[0] !== '-' && k[1] !== '-') return `${kebab(k)}:${v}`;
return `${k}:${v}`;

View file

@ -795,7 +795,6 @@ describe('[SSG] i18n routing', () => {
it('should redirect to the english locale correctly when it has codes+path', async () => {
let html = await fixture.readFile('/spanish/start/index.html');
let $ = cheerio.load(html);
expect(html).to.include('http-equiv="refresh');
expect(html).to.include('url=/new-site/start');
html = await fixture.readFile('/spanish/index.html');

View file

@ -129,6 +129,10 @@ describe('trailing slashes for error pages', () => {
devServer = await fixture.startDevServer();
});
after(async () => {
await devServer.stop();
});
it('renders 404 page when a route does not match the request', async () => {
const response = await fixture.fetch('/ashbfjkasn');
expect(response).to.deep.include({ status: 404 });

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import { fileURLToPath } from 'node:url';
import { createRouteManifest } from '../../../dist/core/routing/manifest/create.js';
import { createBasicSettings, createFs, defaultLogger } from '../test-utils.js';
import { createBasicSettings, createFs } from '../test-utils.js';
import { Logger } from '../../../dist/core/logger/core.js';
const root = new URL('../../fixtures/alias/', import.meta.url);
@ -168,14 +168,6 @@ describe('routing - createRouteManifest', () => {
output: 'server',
base: '/search',
trailingSlash: 'never',
integrations: [
{
name: '@test',
hooks: {
'astro:config:setup': ({ injectRoute }) => {},
},
},
],
experimental: {
globalRoutePriority: true,
},