mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
chore: bump @typescript-eslint/no-unused-vars to error internally (#11173)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
This commit is contained in:
parent
536209aa74
commit
87c179a5f3
18 changed files with 25 additions and 64 deletions
|
@ -62,7 +62,7 @@ export default [
|
|||
// These off/configured-differently-by-default rules fit well for us
|
||||
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
'error',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
|
|
|
@ -169,7 +169,6 @@ test.describe('View Transitions', () => {
|
|||
|
||||
test('Moving from a page without ViewTransitions w/ back button', async ({ page, astro }) => {
|
||||
const loads = collectLoads(page);
|
||||
|
||||
// Go to page 1
|
||||
await page.goto(astro.resolveUrl('/one'));
|
||||
let p = page.locator('#one');
|
||||
|
@ -184,6 +183,10 @@ test.describe('View Transitions', () => {
|
|||
await page.goBack();
|
||||
p = page.locator('#one');
|
||||
await expect(p, 'should have content').toHaveText('Page 1');
|
||||
expect(
|
||||
loads.length,
|
||||
'There should be 3 page loads (for page one & three), and an additional loads for the back navigation'
|
||||
).toEqual(3);
|
||||
});
|
||||
|
||||
test('Stylesheets in the head are waited on', async ({ page, astro }) => {
|
||||
|
|
|
@ -50,7 +50,7 @@ import type {
|
|||
TransitionBeforePreparationEvent,
|
||||
TransitionBeforeSwapEvent,
|
||||
} from '../transitions/events.js';
|
||||
import type { DeepPartial, OmitIndexSignature, Simplify, WithRequired } from '../type-utils.js';
|
||||
import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
|
||||
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
||||
|
||||
export type { AstroIntegrationLogger, ToolbarServerHelpers };
|
||||
|
|
|
@ -43,6 +43,9 @@ const statusToCodeMap: Record<number, ActionErrorCode> = Object.entries(codeToSt
|
|||
{}
|
||||
);
|
||||
|
||||
// T is used for error inference with SafeInput -> isInputError.
|
||||
// See: https://github.com/withastro/astro/pull/11173/files#r1622767246
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export class ActionError<T extends ErrorInferenceObject = ErrorInferenceObject> extends Error {
|
||||
type = 'AstroActionError';
|
||||
code: ActionErrorCode = 'INTERNAL_SERVER_ERROR';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { extname } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import type { Plugin, Rollup } from 'vite';
|
||||
import type { Plugin } from 'vite';
|
||||
import type { AstroSettings, SSRElement } from '../@types/astro.js';
|
||||
import { getAssetsPrefix } from '../assets/utils/getAssetsPrefix.js';
|
||||
import type { BuildInternals } from '../core/build/internal.js';
|
||||
|
@ -129,22 +129,9 @@ export function astroConfigBuildPlugin(
|
|||
options: StaticBuildOptions,
|
||||
internals: BuildInternals
|
||||
): AstroBuildPlugin {
|
||||
let ssrPluginContext: Rollup.PluginContext | undefined = undefined;
|
||||
return {
|
||||
targets: ['server'],
|
||||
hooks: {
|
||||
'build:before': ({ target }) => {
|
||||
return {
|
||||
vitePlugin: {
|
||||
name: 'astro:content-build-plugin',
|
||||
generateBundle() {
|
||||
if (target === 'server') {
|
||||
ssrPluginContext = this;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
'build:post': ({ ssrOutputs, clientOutputs, mutate }) => {
|
||||
const outputs = ssrOutputs.flatMap((o) => o.output);
|
||||
const prependBase = (src: string) => {
|
||||
|
@ -232,8 +219,6 @@ export function astroConfigBuildPlugin(
|
|||
mutate(chunk, ['server'], newCode);
|
||||
}
|
||||
}
|
||||
|
||||
ssrPluginContext = undefined;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -199,7 +199,7 @@ async function generatePage(
|
|||
pipeline: BuildPipeline
|
||||
) {
|
||||
// prepare information we need
|
||||
const { config, internals, logger } = pipeline;
|
||||
const { config, logger } = pipeline;
|
||||
const pageModulePromise = ssrEntry.page;
|
||||
|
||||
// Calculate information of the page, like scripts, links and styles
|
||||
|
|
|
@ -8,7 +8,6 @@ import type {
|
|||
import { getOutputDirectory } from '../../prerender/utils.js';
|
||||
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||
import type { SSRManifest } from '../app/types.js';
|
||||
import { DEFAULT_404_COMPONENT } from '../constants.js';
|
||||
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';
|
||||
import { RedirectSinglePageBuiltModule } from '../redirects/index.js';
|
||||
import { Pipeline } from '../render/index.js';
|
||||
|
|
5
packages/astro/src/env/runtime.ts
vendored
5
packages/astro/src/env/runtime.ts
vendored
|
@ -4,6 +4,7 @@ import type { ValidationResultInvalid } from './validators.js';
|
|||
export { validateEnvVariable, getEnvFieldType } from './validators.js';
|
||||
|
||||
export type GetEnv = (key: string) => string | undefined;
|
||||
type OnSetGetEnv = (reset: boolean) => void
|
||||
|
||||
let _getEnv: GetEnv = (key) => process.env[key];
|
||||
|
||||
|
@ -13,9 +14,9 @@ export function setGetEnv(fn: GetEnv, reset = false) {
|
|||
_onSetGetEnv(reset);
|
||||
}
|
||||
|
||||
let _onSetGetEnv = (reset: boolean) => {};
|
||||
let _onSetGetEnv: OnSetGetEnv = () => {};
|
||||
|
||||
export function setOnSetGetEnv(fn: typeof _onSetGetEnv) {
|
||||
export function setOnSetGetEnv(fn: OnSetGetEnv) {
|
||||
_onSetGetEnv = fn;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,12 +126,6 @@ const a11y_required_content = [
|
|||
|
||||
const a11y_distracting_elements = ['blink', 'marquee'];
|
||||
|
||||
// Unused for now
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const a11y_nested_implicit_semantics = new Map([
|
||||
['header', 'banner'],
|
||||
['footer', 'contentinfo'],
|
||||
]);
|
||||
const a11y_implicit_semantics = new Map([
|
||||
['a', 'link'],
|
||||
['area', 'link'],
|
||||
|
@ -624,19 +618,6 @@ export const a11y: AuditRuleWithSelector[] = [
|
|||
},
|
||||
];
|
||||
|
||||
// Unused for now
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const a11y_labelable = [
|
||||
'button',
|
||||
'input',
|
||||
'keygen',
|
||||
'meter',
|
||||
'output',
|
||||
'progress',
|
||||
'select',
|
||||
'textarea',
|
||||
];
|
||||
|
||||
/**
|
||||
* Exceptions to the rule which follows common A11y conventions
|
||||
* TODO make this configurable by the user
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { SSRResult } from '../../../../@types/astro.js';
|
||||
import type { ComponentSlots } from '../slot.js';
|
||||
import type { AstroComponentFactory, AstroFactoryReturnValue } from './factory.js';
|
||||
import type { AstroComponentFactory } from './factory.js';
|
||||
|
||||
import { isPromise } from '../../util.js';
|
||||
import { renderChild } from '../any.js';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { AstroConfig, RouteData, SSRResult } from '../../../@types/astro.js';
|
||||
import type { RouteData, SSRResult } from '../../../@types/astro.js';
|
||||
import { type NonAstroPageComponent, renderComponentToString } from './component.js';
|
||||
import type { AstroComponentFactory } from './index.js';
|
||||
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from './events.js';
|
||||
import type { TransitionBeforePreparationEvent } from './events.js';
|
||||
import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from './events.js';
|
||||
import {
|
||||
deselectScripts,
|
||||
restoreFocus,
|
||||
saveFocus,
|
||||
swapBodyElement,
|
||||
swapHeadElements,
|
||||
swapRootAttributes,
|
||||
} from './swap-functions.js';
|
||||
import type { Direction, Fallback, Options } from './types.js';
|
||||
|
||||
type State = {
|
||||
|
|
|
@ -3,9 +3,8 @@ import type { ModuleLoader } from '../core/module-loader/index.js';
|
|||
import type { DevPipeline } from './pipeline.js';
|
||||
|
||||
import { collectErrorMetadata } from '../core/errors/dev/index.js';
|
||||
import { AstroErrorData, createSafeError } from '../core/errors/index.js';
|
||||
import { createSafeError } from '../core/errors/index.js';
|
||||
import { formatErrorMessage } from '../core/messages.js';
|
||||
import { eventError, telemetry } from '../events/index.js';
|
||||
|
||||
export function recordServerError(
|
||||
loader: ModuleLoader,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import type http from 'node:http';
|
||||
import type { ComponentInstance, ManifestData, RouteData } from '../@types/astro.js';
|
||||
import {
|
||||
DEFAULT_404_COMPONENT,
|
||||
REROUTE_DIRECTIVE_HEADER,
|
||||
REWRITE_DIRECTIVE_HEADER_KEY,
|
||||
clientLocalsSymbol,
|
||||
|
|
2
packages/astro/templates/env/module.mjs
vendored
2
packages/astro/templates/env/module.mjs
vendored
|
@ -25,6 +25,8 @@ const _internalGetSecret = (key) => {
|
|||
throw createInvalidVariablesError(key, type, result);
|
||||
};
|
||||
|
||||
// used while generating the virtual module
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
setOnSetGetEnv((reset) => {
|
||||
// @@ON_SET_GET_ENV@@
|
||||
});
|
||||
|
|
|
@ -106,8 +106,6 @@ describe('Reuse injected entrypoint', () => {
|
|||
});
|
||||
|
||||
routes.forEach(({ description, url, fourOhFour, h1, p, htmlMatch }) => {
|
||||
const isEndpoint = htmlMatch && !h1 && !p;
|
||||
|
||||
// checks URLs as written above
|
||||
it(description, async () => {
|
||||
const html = await fixture.fetch(url).then((res) => res.text());
|
||||
|
|
|
@ -4,8 +4,7 @@ export const isValidUrl = (s: any) => {
|
|||
return false;
|
||||
}
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const dummy = new URL(s);
|
||||
new URL(s);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue