diff --git a/.eslintignore b/.eslintignore index 28768c1b90dd..f5104aedd5b4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ **/*.d.ts +packages/**/*.min.js packages/**/dist/**/* packages/**/fixtures/**/* packages/webapi/**/* diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a7ec9c8eaccf..3e4d26b01437 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,23 +1,53 @@ module.exports = { + extends: [ + 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', + 'prettier', + ], parser: '@typescript-eslint/parser', - extends: ['plugin:@typescript-eslint/recommended', 'prettier'], + parserOptions: { + project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'], + tsconfigRootDir: __dirname, + }, plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'], rules: { + // These off/configured-differently-by-default rules fit well for us + '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], + '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], + 'no-only-tests/no-only-tests': 'error', + '@typescript-eslint/no-shadow': ['error'], + 'no-console': 'warn', + + // Todo: do we want these? + '@typescript-eslint/array-type': 'off', '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/camelcase': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/class-literal-property-style': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', + '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/dot-notation': 'off', + '@typescript-eslint/no-base-to-string': 'off', + '@typescript-eslint/no-confusing-void-expression': 'off', '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-floating-promises': 'off', + '@typescript-eslint/no-misused-promises': 'off', + '@typescript-eslint/no-redundant-type-constituents': 'off', '@typescript-eslint/no-this-alias': 'off', - 'no-console': 'warn', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/prefer-string-starts-ends-with': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/restrict-plus-operands': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/sort-type-constituents': 'off', + '@typescript-eslint/unbound-method': 'off', + + // These rules enabled by the preset configs don't work well for us + '@typescript-eslint/await-thenable': 'off', 'prefer-const': 'off', - 'no-shadow': 'off', - '@typescript-eslint/no-shadow': ['error'], - 'no-only-tests/no-only-tests': 'error', }, overrides: [ { @@ -41,6 +71,7 @@ module.exports = { { files: ['benchmark/**/*.js'], rules: { + '@typescript-eslint/no-unused-vars': 'off', 'no-console': 'off', }, }, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf9e8fcbe1f7..83867d38f9e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ env: jobs: lint: name: Lint - timeout-minutes: 3 + timeout-minutes: 5 runs-on: ubuntu-latest steps: - name: Check out repository @@ -50,6 +50,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build (ignoring failures) + run: pnpm run build || true + # Lint autofix cannot run on forks, so just skip those! See https://github.com/wearerequired/lint-action/issues/13 - name: Lint (External) if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != github.repository_owner }} diff --git a/package.json b/package.json index b65d19e88979..32fae77e848d 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e", "test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match", "benchmark": "astro-benchmark", - "lint": "eslint --cache .", + "lint": "eslint . --report-unused-disable-directives", "version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format", "preinstall": "npx only-allow pnpm" }, @@ -78,8 +78,8 @@ "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.1", "@types/node": "^18.16.18", - "@typescript-eslint/eslint-plugin": "^5.60.0", - "@typescript-eslint/parser": "^5.60.0", + "@typescript-eslint/eslint-plugin": "6.0.0-alpha.158", + "@typescript-eslint/parser": "6.0.0-alpha.158", "esbuild": "^0.17.19", "eslint": "^8.43.0", "eslint-config-prettier": "^8.8.0", diff --git a/packages/astro/astro.js b/packages/astro/astro.js index 1fcf633a9f28..37ea869bcae7 100755 --- a/packages/astro/astro.js +++ b/packages/astro/astro.js @@ -1,5 +1,4 @@ #!/usr/bin/env node -/* eslint-disable no-console */ 'use strict'; // ISOMORPHIC FILE: NO TOP-LEVEL IMPORT/REQUIRE() ALLOWED diff --git a/packages/astro/e2e/css-sourcemaps.test.js b/packages/astro/e2e/css-sourcemaps.test.js index 919d3c864219..50b18834f04d 100644 --- a/packages/astro/e2e/css-sourcemaps.test.js +++ b/packages/astro/e2e/css-sourcemaps.test.js @@ -1,5 +1,5 @@ import { expect } from '@playwright/test'; -import { getColor, isWindows, testFactory } from './test-utils.js'; +import { isWindows, testFactory } from './test-utils.js'; const test = testFactory({ root: './fixtures/css/', diff --git a/packages/astro/e2e/hydration-race.test.js b/packages/astro/e2e/hydration-race.test.js index ffa78125fe54..0ee578243060 100644 --- a/packages/astro/e2e/hydration-race.test.js +++ b/packages/astro/e2e/hydration-race.test.js @@ -19,8 +19,6 @@ test.describe('Hydration race', () => { test('Islands inside of slots hydrate', async ({ page, astro }) => { await page.goto(astro.resolveUrl('/slot')); - const html = await page.content(); - const one = page.locator('#one'); await expect(one, 'updated text').toHaveText('Hello One in the client'); diff --git a/packages/astro/e2e/test-utils.js b/packages/astro/e2e/test-utils.js index 72c6e8d5685f..0d0f18eb929d 100644 --- a/packages/astro/e2e/test-utils.js +++ b/packages/astro/e2e/test-utils.js @@ -18,8 +18,7 @@ for (let i = 0; i < testFiles.length; i++) { } export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/astro/src/assets/image-endpoint.ts b/packages/astro/src/assets/image-endpoint.ts index e3553edbc6ed..49fce8f05a33 100644 --- a/packages/astro/src/assets/image-endpoint.ts +++ b/packages/astro/src/assets/image-endpoint.ts @@ -35,7 +35,7 @@ export const get: APIRoute = async ({ request }) => { const url = new URL(request.url); const transform = await imageService.parseURL(url, imageServiceConfig); - if (!transform || !transform.src) { + if (!transform?.src) { throw new Error('Incorrect transform returned by `parseURL`'); } diff --git a/packages/astro/src/assets/services/squoosh.ts b/packages/astro/src/assets/services/squoosh.ts index 089fcbc81048..45933d6003d6 100644 --- a/packages/astro/src/assets/services/squoosh.ts +++ b/packages/astro/src/assets/services/squoosh.ts @@ -36,7 +36,7 @@ const service: LocalImageService = { async transform(inputBuffer, transformOptions) { const transform: BaseServiceTransform = transformOptions as BaseServiceTransform; - let format = transform.format!; + let format = transform.format; const operations: Operation[] = []; diff --git a/packages/astro/src/assets/services/vendor/squoosh/codecs.ts b/packages/astro/src/assets/services/vendor/squoosh/codecs.ts index d4065cee42c4..55b56d596389 100644 --- a/packages/astro/src/assets/services/vendor/squoosh/codecs.ts +++ b/packages/astro/src/assets/services/vendor/squoosh/codecs.ts @@ -291,7 +291,6 @@ export const codecs = { avif: { name: 'AVIF', extension: 'avif', - // eslint-disable-next-line no-control-regex detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/], dec: () => instantiateEmscriptenWasm(avifDec as DecodeModuleFactory, avifDecWasm), @@ -322,7 +321,6 @@ export const codecs = { oxipng: { name: 'OxiPNG', extension: 'png', - // eslint-disable-next-line no-control-regex detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/], dec: async () => { await pngEncDecInit() diff --git a/packages/astro/src/assets/services/vendor/squoosh/image.ts b/packages/astro/src/assets/services/vendor/squoosh/image.ts index 4a05d212c40c..694f994d24d9 100644 --- a/packages/astro/src/assets/services/vendor/squoosh/image.ts +++ b/packages/astro/src/assets/services/vendor/squoosh/image.ts @@ -29,14 +29,14 @@ export async function processBuffer( switch (encoding) { case 'avif': - return await impl.encodeAvif(imageData, { quality }) as Uint8Array; + return await impl.encodeAvif(imageData, { quality }); case 'jpeg': case 'jpg': - return await impl.encodeJpeg(imageData, { quality }) as Uint8Array; + return await impl.encodeJpeg(imageData, { quality }); case 'png': - return await impl.encodePng(imageData) as Uint8Array; + return await impl.encodePng(imageData); case 'webp': - return await impl.encodeWebp(imageData, { quality }) as Uint8Array; + return await impl.encodeWebp(imageData, { quality }); default: throw Error(`Unsupported encoding format`) } diff --git a/packages/astro/src/assets/vendor/image-size/types/jp2.ts b/packages/astro/src/assets/vendor/image-size/types/jp2.ts index e23e1aced0ba..127a96d608e3 100644 --- a/packages/astro/src/assets/vendor/image-size/types/jp2.ts +++ b/packages/astro/src/assets/vendor/image-size/types/jp2.ts @@ -49,7 +49,6 @@ export const JP2: IImage = { switch (nextBoxType) { case BoxTypes.rreq: // WHAT ARE THESE 4 BYTES????? - // eslint-disable-next-line no-case-declarations const MAGIC = 4 offset = offset + 4 + MAGIC + calculateRREQLength(buffer.slice(offset + 4)) return parseIHDR(buffer.slice(offset + 8, offset + 24)) diff --git a/packages/astro/src/assets/vendor/image-size/types/pnm.ts b/packages/astro/src/assets/vendor/image-size/types/pnm.ts index 687c6265e9f7..fa30a53d50a0 100644 --- a/packages/astro/src/assets/vendor/image-size/types/pnm.ts +++ b/packages/astro/src/assets/vendor/image-size/types/pnm.ts @@ -19,7 +19,7 @@ const handlers: { [type: string]: Handler} = { let dimensions: string[] = [] while (lines.length > 0) { - const line = lines.shift() as string + const line = lines.shift()! if (line[0] === '#') { continue } @@ -39,7 +39,7 @@ const handlers: { [type: string]: Handler} = { pam: (lines) => { const size: { [key: string]: number } = {} while (lines.length > 0) { - const line = lines.shift() as string + const line = lines.shift()! if (line.length > 16 || line.charCodeAt(0) > 128) { continue } diff --git a/packages/astro/src/assets/vendor/image-size/types/svg.ts b/packages/astro/src/assets/vendor/image-size/types/svg.ts index 7cb164679d89..945be962dd4a 100644 --- a/packages/astro/src/assets/vendor/image-size/types/svg.ts +++ b/packages/astro/src/assets/vendor/image-size/types/svg.ts @@ -41,8 +41,8 @@ function parseLength(len: string) { function parseViewbox(viewbox: string): IAttributes { const bounds = viewbox.split(' ') return { - height: parseLength(bounds[3]) as number, - width: parseLength(bounds[2]) as number + height: parseLength(bounds[3])!, + width: parseLength(bounds[2])! } } @@ -51,21 +51,21 @@ function parseAttributes(root: string): IAttributes { const height = root.match(extractorRegExps.height) const viewbox = root.match(extractorRegExps.viewbox) return { - height: height && parseLength(height[2]) as number, - viewbox: viewbox && parseViewbox(viewbox[2]) as IAttributes, - width: width && parseLength(width[2]) as number, + height: height && parseLength(height[2])!, + viewbox: viewbox && parseViewbox(viewbox[2])!, + width: width && parseLength(width[2])!, } } function calculateByDimensions(attrs: IAttributes): ISize { return { - height: attrs.height as number, - width: attrs.width as number, + height: attrs.height!, + width: attrs.width!, } } function calculateByViewbox(attrs: IAttributes, viewbox: IAttributes): ISize { - const ratio = (viewbox.width as number) / (viewbox.height as number) + const ratio = (viewbox.width!) / (viewbox.height!) if (attrs.width) { return { height: Math.floor(attrs.width / ratio), @@ -79,8 +79,8 @@ function calculateByViewbox(attrs: IAttributes, viewbox: IAttributes): ISize { } } return { - height: viewbox.height as number, - width: viewbox.width as number, + height: viewbox.height!, + width: viewbox.width!, } } diff --git a/packages/astro/src/assets/vendor/image-size/types/tiff.ts b/packages/astro/src/assets/vendor/image-size/types/tiff.ts index 1be697d29da4..dcbc9cf55174 100644 --- a/packages/astro/src/assets/vendor/image-size/types/tiff.ts +++ b/packages/astro/src/assets/vendor/image-size/types/tiff.ts @@ -44,7 +44,7 @@ function extractTags(buffer: Buffer, isBigEndian: boolean) { const tags: {[key: number]: number} = {} let temp: Buffer | undefined = buffer - while (temp && temp.length) { + while (temp?.length) { const code = readUInt(temp, 16, 0, isBigEndian) const type = readUInt(temp, 16, 2, isBigEndian) const length = readUInt(temp, 32, 4, isBigEndian) diff --git a/packages/astro/src/cli/check/index.ts b/packages/astro/src/cli/check/index.ts index 07648aabe0c3..cf0105461ce6 100644 --- a/packages/astro/src/cli/check/index.ts +++ b/packages/astro/src/cli/check/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import { AstroCheck, DiagnosticSeverity, diff --git a/packages/astro/src/content/error-map.ts b/packages/astro/src/content/error-map.ts index 9fbfaf34333b..706de3882373 100644 --- a/packages/astro/src/content/error-map.ts +++ b/packages/astro/src/content/error-map.ts @@ -14,7 +14,7 @@ export const errorMap: ZodErrorMap = (baseError, ctx) => { // raise a single error when `key` does not match: // > Did not match union. // > key: Expected `'tutorial' | 'blog'`, received 'foo' - let typeOrLiteralErrByPath: Map = new Map(); + let typeOrLiteralErrByPath = new Map(); for (const unionError of baseError.unionErrors.map((e) => e.errors).flat()) { if (unionError.code === 'invalid_type' || unionError.code === 'invalid_literal') { const flattenedErrorPath = flattenErrorPath(unionError.path); diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index 631f30e1f19f..d273dc105ec4 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -177,7 +177,7 @@ export function getDataEntryExts(settings: Pick export function getEntryConfigByExtMap( entryTypes: TEntryType[] ): Map { - const map: Map = new Map(); + const map = new Map(); for (const entryType of entryTypes) { for (const ext of entryType.extensions) { map.set(ext, entryType); @@ -310,7 +310,7 @@ function getYAMLErrorLine(rawData: string | undefined, objectKey: string) { return numNewlinesBeforeKey; } -export function parseFrontmatter(fileContents: string, filePath: string) { +export function parseFrontmatter(fileContents: string) { try { // `matter` is empty string on cache results // clear cache to prevent this diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 69f8f73c40ae..c69267b92a4b 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -203,7 +203,7 @@ export class App { ): Promise { const url = new URL(request.url); const pathname = prependForwardSlash(this.removeBase(url.pathname)); - const info = this.#routeDataToRouteInfo.get(routeData!)!; + const info = this.#routeDataToRouteInfo.get(routeData)!; const isCompressHTML = this.#manifest.compressHTML ?? false; // may be used in the future for handling rel=modulepreload, rel=icon, rel=manifest etc. const links = new Set(); diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index 40b7b4e7ce6e..3e620730959f 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -34,7 +34,7 @@ class NodeIncomingMessage extends IncomingMessage { /** * The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request. */ - body?: any | undefined; + body?: unknown; } export class NodeApp extends App { diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 1ab28ecc0854..72339a680b80 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -121,7 +121,7 @@ export function chunkIsPage( if (output.type !== 'chunk') { return false; } - const chunk = output as OutputChunk; + const chunk = output; if (chunk.facadeModuleId) { const facadeToEntryId = prependForwardSlash( rootRelativeFacadeId(chunk.facadeModuleId, settings) @@ -470,15 +470,7 @@ async function generatePath( onRequest?: MiddlewareHandler ) { const { settings, logging, origin, routeCache } = opts; - const { - mod, - internals, - linkIds, - scripts: hoistedScripts, - styles: _styles, - pageData, - renderers, - } = gopts; + const { mod, internals, scripts: hoistedScripts, styles: _styles, pageData, renderers } = gopts; // This adds the page name to the array so it can be shown as part of stats. if (pageData.route.type === 'page') { diff --git a/packages/astro/src/core/build/plugins/index.ts b/packages/astro/src/core/build/plugins/index.ts index 4563bb6964d7..160e18fdd8a6 100644 --- a/packages/astro/src/core/build/plugins/index.ts +++ b/packages/astro/src/core/build/plugins/index.ts @@ -18,11 +18,11 @@ export function registerAllPlugins({ internals, options, register }: AstroBuildP register(pluginAliasResolve(internals)); register(pluginAnalyzer(internals)); register(pluginInternals(internals)); - register(pluginRenderers(options, internals)); - register(pluginMiddleware(options, internals)); + register(pluginRenderers(options)); + register(pluginMiddleware(options)); register(pluginPages(options, internals)); register(pluginCSS(options, internals)); - register(astroHeadBuildPlugin(options, internals)); + register(astroHeadBuildPlugin(internals)); register(pluginPrerender(options, internals)); register(astroConfigBuildPlugin(options, internals)); register(pluginHoistedScripts(options, internals)); diff --git a/packages/astro/src/core/build/plugins/plugin-analyzer.ts b/packages/astro/src/core/build/plugins/plugin-analyzer.ts index e90063f284a8..b650e04f18ca 100644 --- a/packages/astro/src/core/build/plugins/plugin-analyzer.ts +++ b/packages/astro/src/core/build/plugins/plugin-analyzer.ts @@ -126,7 +126,7 @@ export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin { for (const id of ids) { const info = this.getModuleInfo(id); - if (!info || !info.meta?.astro) continue; + if (!info?.meta?.astro) continue; const astro = info.meta.astro as AstroPluginMetadata['astro']; diff --git a/packages/astro/src/core/build/plugins/plugin-component-entry.ts b/packages/astro/src/core/build/plugins/plugin-component-entry.ts index 444aa6a19f5e..01e480e2fdb4 100644 --- a/packages/astro/src/core/build/plugins/plugin-component-entry.ts +++ b/packages/astro/src/core/build/plugins/plugin-component-entry.ts @@ -10,7 +10,7 @@ export const astroEntryPrefix = '\0astro-entry:'; * entries to re-export only the names the user is using. */ export function vitePluginComponentEntry(internals: BuildInternals): VitePlugin { - const componentToExportNames: Map = new Map(); + const componentToExportNames = new Map(); mergeComponentExportNames(internals.discoveredHydratedComponents); mergeComponentExportNames(internals.discoveredClientOnlyComponents); diff --git a/packages/astro/src/core/build/plugins/plugin-css.ts b/packages/astro/src/core/build/plugins/plugin-css.ts index 1d2aa58ea06e..8971cf553340 100644 --- a/packages/astro/src/core/build/plugins/plugin-css.ts +++ b/packages/astro/src/core/build/plugins/plugin-css.ts @@ -107,7 +107,7 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { }, async generateBundle(_outputOptions, bundle) { - for (const [_, chunk] of Object.entries(bundle)) { + for (const [, chunk] of Object.entries(bundle)) { if (chunk.type !== 'chunk') continue; if ('viteMetadata' in chunk === false) continue; const meta = chunk.viteMetadata as ViteMetadata; diff --git a/packages/astro/src/core/build/plugins/plugin-middleware.ts b/packages/astro/src/core/build/plugins/plugin-middleware.ts index 7e3ea8cb9d9a..dee73d2f8b2e 100644 --- a/packages/astro/src/core/build/plugins/plugin-middleware.ts +++ b/packages/astro/src/core/build/plugins/plugin-middleware.ts @@ -1,7 +1,6 @@ import type { Plugin as VitePlugin } from 'vite'; import { MIDDLEWARE_PATH_SEGMENT_NAME } from '../../constants.js'; import { addRollupInput } from '../add-rollup-input.js'; -import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin'; import type { StaticBuildOptions } from '../types'; @@ -9,10 +8,7 @@ export const MIDDLEWARE_MODULE_ID = '@astro-middleware'; const EMPTY_MIDDLEWARE = '\0empty-middleware'; -export function vitePluginMiddleware( - opts: StaticBuildOptions, - _internals: BuildInternals -): VitePlugin { +export function vitePluginMiddleware(opts: StaticBuildOptions): VitePlugin { return { name: '@astro/plugin-middleware', @@ -44,16 +40,13 @@ export function vitePluginMiddleware( }; } -export function pluginMiddleware( - opts: StaticBuildOptions, - internals: BuildInternals -): AstroBuildPlugin { +export function pluginMiddleware(opts: StaticBuildOptions): AstroBuildPlugin { return { build: 'ssr', hooks: { 'build:before': () => { return { - vitePlugin: vitePluginMiddleware(opts, internals), + vitePlugin: vitePluginMiddleware(opts), }; }, }, diff --git a/packages/astro/src/core/build/plugins/plugin-pages.ts b/packages/astro/src/core/build/plugins/plugin-pages.ts index c40449a39e2e..cf078f0b5ba6 100644 --- a/packages/astro/src/core/build/plugins/plugin-pages.ts +++ b/packages/astro/src/core/build/plugins/plugin-pages.ts @@ -39,7 +39,7 @@ function vitePluginPages(opts: StaticBuildOptions, internals: BuildInternals): V options(options) { if (opts.settings.config.output === 'static') { - const inputs: Set = new Set(); + const inputs = new Set(); for (const [path, pageData] of Object.entries(opts.allPages)) { if (routeIsRedirect(pageData.route)) { diff --git a/packages/astro/src/core/build/plugins/plugin-renderers.ts b/packages/astro/src/core/build/plugins/plugin-renderers.ts index d18eb5a0270f..912df42418f0 100644 --- a/packages/astro/src/core/build/plugins/plugin-renderers.ts +++ b/packages/astro/src/core/build/plugins/plugin-renderers.ts @@ -1,17 +1,12 @@ import type { Plugin as VitePlugin } from 'vite'; import { addRollupInput } from '../add-rollup-input.js'; -import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin'; import type { StaticBuildOptions } from '../types'; export const RENDERERS_MODULE_ID = '@astro-renderers'; export const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`; -let inputs: Set = new Set(); -export function vitePluginRenderers( - opts: StaticBuildOptions, - _internals: BuildInternals -): VitePlugin { +export function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin { return { name: '@astro/plugin-renderers', @@ -49,16 +44,13 @@ export function vitePluginRenderers( }; } -export function pluginRenderers( - opts: StaticBuildOptions, - internals: BuildInternals -): AstroBuildPlugin { +export function pluginRenderers(opts: StaticBuildOptions): AstroBuildPlugin { return { build: 'ssr', hooks: { 'build:before': () => { return { - vitePlugin: vitePluginRenderers(opts, internals), + vitePlugin: vitePluginRenderers(opts), }; }, }, diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 254037e59509..41f38a8b251b 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -42,10 +42,7 @@ function vitePluginSSR( }, async load(id) { if (id === RESOLVED_SSR_VIRTUAL_MODULE_ID) { - const { - settings: { config }, - allPages, - } = options; + const { allPages } = options; const imports: string[] = []; const contents: string[] = []; const exports: string[] = []; @@ -82,7 +79,7 @@ function vitePluginSSR( }, async generateBundle(_opts, bundle) { // Add assets from this SSR chunk as well. - for (const [_chunkName, chunk] of Object.entries(bundle)) { + for (const [, chunk] of Object.entries(bundle)) { if (chunk.type === 'asset') { internals.staticFiles.add(chunk.fileName); } @@ -162,7 +159,7 @@ function vitePluginSSRSplit( enforce: 'post', options(opts) { if (options.settings.config.build.split) { - const inputs: Set = new Set(); + const inputs = new Set(); for (const path of Object.keys(options.allPages)) { inputs.add(getVirtualModulePageNameFromPath(SPLIT_MODULE_ID, path)); @@ -178,10 +175,6 @@ function vitePluginSSRSplit( }, async load(id) { if (id.startsWith(RESOLVED_SPLIT_MODULE_ID)) { - const { - settings: { config }, - allPages, - } = options; const imports: string[] = []; const contents: string[] = []; const exports: string[] = []; @@ -204,7 +197,7 @@ function vitePluginSSRSplit( }, async generateBundle(_opts, bundle) { // Add assets from this SSR chunk as well. - for (const [_chunkName, chunk] of Object.entries(bundle)) { + for (const [, chunk] of Object.entries(bundle)) { if (chunk.type === 'asset') { internals.staticFiles.add(chunk.fileName); } @@ -268,7 +261,7 @@ export function pluginSSRSplit( logging: options.logging, entryPoints: internals.entryPoints, }); - for (const [moduleName, chunk] of internals.ssrSplitEntryChunks) { + for (const [, chunk] of internals.ssrSplitEntryChunks) { const code = injectManifest(manifest, chunk); mutate(chunk, 'server', code); } @@ -413,8 +406,8 @@ function buildManifest( if (!route.prerender) continue; if (!route.pathname) continue; - const outFolder = getOutFolder(opts.settings.config, route.pathname!, route.type); - const outFile = getOutFile(opts.settings.config, outFolder, route.pathname!, route.type); + const outFolder = getOutFolder(opts.settings.config, route.pathname, route.type); + const outFile = getOutFile(opts.settings.config, outFolder, route.pathname, route.type); const file = outFile.toString().replace(opts.settings.config.build.client.toString(), ''); routes.push({ file, diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts index e78a761a4932..425677123dc8 100644 --- a/packages/astro/src/core/compile/compile.ts +++ b/packages/astro/src/core/compile/compile.ts @@ -78,6 +78,8 @@ export async function compile({ } function handleCompileResultErrors(result: TransformResult, cssTransformErrors: AstroError[]) { + // TODO: Export the DiagnosticSeverity enum from @astrojs/compiler? + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison const compilerError = result.diagnostics.find((diag) => diag.severity === 1); if (compilerError) { @@ -96,7 +98,6 @@ function handleCompileResultErrors(result: TransformResult, cssTransformErrors: case 0: break; case 1: { - const error = cssTransformErrors[0]; throw cssTransformErrors[0]; } default: { diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 99ef653d0788..7410df470e5b 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -8,7 +8,7 @@ import { BUNDLED_THEMES } from 'shiki'; import { z } from 'zod'; import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js'; -const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { +const ASTRO_CONFIG_DEFAULTS = { root: '.', srcDir: './src', publicDir: './public', @@ -30,7 +30,6 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { server: { host: false, port: 3000, - streaming: true, open: false, }, integrations: [], @@ -45,7 +44,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { assets: false, redirects: false, }, -}; +} satisfies AstroUserConfig & { server: { open: boolean } }; export const AstroConfigSchema = z.object({ root: z @@ -172,8 +171,8 @@ export const AstroConfigSchema = z.object({ theme: z .enum(BUNDLED_THEMES as [Theme, ...Theme[]]) .or(z.custom()) - .default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.theme), - wrap: z.boolean().or(z.null()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.wrap), + .default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.theme!), + wrap: z.boolean().or(z.null()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.wrap!), }) .default({}), remarkPlugins: z diff --git a/packages/astro/src/core/config/timer.ts b/packages/astro/src/core/config/timer.ts index 7360b55103ee..82860e0a7ca4 100644 --- a/packages/astro/src/core/config/timer.ts +++ b/packages/astro/src/core/config/timer.ts @@ -18,7 +18,7 @@ interface OngoingStat { */ export class AstroTimer { private enabled: boolean; - private ongoingTimers: Map = new Map(); + private ongoingTimers = new Map(); private stats: Record = {}; constructor() { diff --git a/packages/astro/src/core/cookies/cookies.ts b/packages/astro/src/core/cookies/cookies.ts index e997c772e1ef..013357f32845 100644 --- a/packages/astro/src/core/cookies/cookies.ts +++ b/packages/astro/src/core/cookies/cookies.ts @@ -99,7 +99,7 @@ class AstroCookies implements AstroCookiesInterface { */ get(key: string): AstroCookie { // Check for outgoing Set-Cookie values first - if (this.#outgoing !== null && this.#outgoing.has(key)) { + if (this.#outgoing?.has(key)) { let [serializedValue, , isSetValue] = this.#outgoing.get(key)!; if (isSetValue) { return new AstroCookie(serializedValue); @@ -120,7 +120,7 @@ class AstroCookies implements AstroCookiesInterface { * @returns */ has(key: string): boolean { - if (this.#outgoing !== null && this.#outgoing.has(key)) { + if (this.#outgoing?.has(key)) { let [, , isSetValue] = this.#outgoing.get(key)!; return isSetValue; } diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 89dec9d4b3af..60c8470455a5 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -121,10 +121,10 @@ export async function createVite( markdownVitePlugin({ settings, logging }), htmlVitePlugin(), jsxVitePlugin({ settings, logging }), - astroPostprocessVitePlugin({ settings }), + astroPostprocessVitePlugin(), mode === 'dev' && astroIntegrationsContainerPlugin({ settings, logging }), astroScriptsPageSSRPlugin({ settings }), - astroHeadPlugin({ settings }), + astroHeadPlugin(), astroScannerPlugin({ settings }), astroInjectEnvTsPlugin({ settings, logging, fs }), astroContentVirtualModPlugin({ settings }), @@ -315,12 +315,3 @@ function isCommonNotAstro(dep: string): boolean { ) ); } - -interface PkgJSON { - name: string; - dependencies?: Record; - devDependencies?: Record; - peerDependencies?: Record; - keywords?: string[]; - [key: string]: any; -} diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index 9c71b7aa3bb5..6e4c0b16f170 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -125,7 +125,7 @@ interface Restart { export async function createContainerWithAutomaticRestart({ flags, - handleConfigError = (_e: Error) => {}, + handleConfigError = () => {}, beforeRestart, params, }: CreateContainerWithAutomaticRestart): Promise { @@ -143,7 +143,6 @@ export async function createContainerWithAutomaticRestart({ }; async function handleServerRestart(logMsg: string) { - // eslint-disable-next-line @typescript-eslint/no-shadow const container = restart.container; const { container: newContainer, error } = await restartContainer({ beforeRestart, diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index 29468c7fd8d2..69026b6cd07b 100644 --- a/packages/astro/src/core/errors/dev/utils.ts +++ b/packages/astro/src/core/errors/dev/utils.ts @@ -20,11 +20,9 @@ type EsbuildMessage = ESBuildTransformResult['warnings'][number]; */ export function collectErrorMetadata(e: any, rootFolder?: URL | undefined): ErrorWithMetadata { const err = - AggregateError.is(e) || Array.isArray((e as any).errors) - ? (e.errors as SSRError[]) - : [e as SSRError]; + AggregateError.is(e) || Array.isArray(e.errors) ? (e.errors as SSRError[]) : [e as SSRError]; - err.forEach((error, idx) => { + err.forEach((error) => { if (e.stack) { const stackInfo = collectInfoFromStacktrace(e); error.stack = stackInfo.stack; @@ -73,7 +71,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL | undefined): Erro // If we received an array of errors and it's not from us, it's most likely from ESBuild, try to extract info for Vite to display // NOTE: We still need to be defensive here, because it might not necessarily be from ESBuild, it's just fairly likely. - if (!AggregateError.is(e) && Array.isArray((e as any).errors)) { + if (!AggregateError.is(e) && Array.isArray(e.errors)) { (e.errors as EsbuildMessage[]).forEach((buildError, i) => { const { location, pluginName, text } = buildError; @@ -226,7 +224,7 @@ export function renderErrorMarkdown(markdown: string, target: 'html' | 'cli') { } else { return markdown .replace(linkRegex, (fullMatch, m1, m2) => `${bold(m1)} ${underline(m2)}`) - .replace(urlRegex, (fullMatch, m1) => ` ${underline(fullMatch.trim())} `) + .replace(urlRegex, (fullMatch) => ` ${underline(fullMatch.trim())} `) .replace(boldRegex, (fullMatch, m1) => `${bold(m1)}`); } } diff --git a/packages/astro/src/core/errors/errors.ts b/packages/astro/src/core/errors/errors.ts index cda4f328af5a..a73728124baa 100644 --- a/packages/astro/src/core/errors/errors.ts +++ b/packages/astro/src/core/errors/errors.ts @@ -81,7 +81,7 @@ export class AstroError extends Error { this.frame = codeFrame(source, location); } - static is(err: Error | unknown): err is AstroError { + static is(err: unknown): err is AstroError { return (err as AstroError).type === 'AstroError'; } } @@ -95,7 +95,7 @@ export class CompilerError extends AstroError { this.name = 'CompilerError'; } - static is(err: Error | unknown): err is CompilerError { + static is(err: unknown): err is CompilerError { return (err as CompilerError).type === 'CompilerError'; } } @@ -103,7 +103,7 @@ export class CompilerError extends AstroError { export class CSSError extends AstroError { type: ErrorTypes = 'CSSError'; - static is(err: Error | unknown): err is CSSError { + static is(err: unknown): err is CSSError { return (err as CSSError).type === 'CSSError'; } } @@ -111,7 +111,7 @@ export class CSSError extends AstroError { export class MarkdownError extends AstroError { type: ErrorTypes = 'MarkdownError'; - static is(err: Error | unknown): err is MarkdownError { + static is(err: unknown): err is MarkdownError { return (err as MarkdownError).type === 'MarkdownError'; } } @@ -119,7 +119,7 @@ export class MarkdownError extends AstroError { export class InternalError extends AstroError { type: ErrorTypes = 'InternalError'; - static is(err: Error | unknown): err is InternalError { + static is(err: unknown): err is InternalError { return (err as InternalError).type === 'InternalError'; } } @@ -136,7 +136,7 @@ export class AggregateError extends AstroError { this.errors = props.errors; } - static is(err: Error | unknown): err is AggregateError { + static is(err: unknown): err is AggregateError { return (err as AggregateError).type === 'AggregateError'; } } diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts index 8f7e464f8c1f..5a24f898aab3 100644 --- a/packages/astro/src/core/errors/overlay.ts +++ b/packages/astro/src/core/errors/overlay.ts @@ -1,4 +1,3 @@ -import type { AstroConfig } from '../../@types/astro'; import type { AstroErrorPayload } from './dev/vite'; const style = /* css */ ` @@ -665,7 +664,7 @@ class ErrorOverlay extends HTMLElement { const errorLine = this.root.querySelector('.error-line'); if (errorLine) { - if (errorLine.parentElement && errorLine.parentElement.parentElement) { + if (errorLine.parentElement?.parentElement) { errorLine.parentElement.parentElement.scrollTop = errorLine.offsetTop - errorLine.parentElement.parentElement.offsetTop - 8; } @@ -745,6 +744,6 @@ function getOverlayCode() { `; } -export function patchOverlay(code: string, config: AstroConfig) { +export function patchOverlay(code: string) { return code.replace('class ErrorOverlay', getOverlayCode() + '\nclass ViteErrorOverlay'); } diff --git a/packages/astro/src/core/errors/utils.ts b/packages/astro/src/core/errors/utils.ts index 99cdde028e52..ea238d441414 100644 --- a/packages/astro/src/core/errors/utils.ts +++ b/packages/astro/src/core/errors/utils.ts @@ -89,7 +89,7 @@ export function formatYAMLException(e: YAMLException): ViteErrorPayload['err'] { /** Coalesce any throw variable to an Error instance. */ export function createSafeError(err: any): Error { - if (err instanceof Error || (err && err.name && err.message)) { + if (err instanceof Error || (err?.name && err.message)) { return err; } else { const error = new Error(JSON.stringify(err)); diff --git a/packages/astro/src/core/middleware/callMiddleware.ts b/packages/astro/src/core/middleware/callMiddleware.ts index f202a401ab34..afa0156c99b1 100644 --- a/packages/astro/src/core/middleware/callMiddleware.ts +++ b/packages/astro/src/core/middleware/callMiddleware.ts @@ -49,11 +49,6 @@ export async function callMiddleware( apiContext: APIContext, responseFunction: () => Promise ): Promise { - let resolveResolve: any; - new Promise((resolve) => { - resolveResolve = resolve; - }); - let nextCalled = false; let responseFunctionPromise: Promise | undefined = undefined; const next: MiddlewareNext = async () => { diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index 43c0d450fc94..3fd0203fc7ad 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -174,7 +174,7 @@ export async function renderPage(options: SSROptions): Promise { adapterName: options.env.adapterName, }); if (options.middleware) { - if (options.middleware && options.middleware.onRequest) { + if (options.middleware?.onRequest) { const onRequest = options.middleware.onRequest as MiddlewareResponseHandler; const response = await callMiddleware(env.logging, onRequest, apiContext, () => { return coreRenderPage({ diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index b5a6831643a5..7695ccaec28b 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -33,8 +33,8 @@ interface Item { function countOccurrences(needle: string, haystack: string) { let count = 0; - for (let i = 0; i < haystack.length; i += 1) { - if (haystack[i] === needle) count += 1; + for (const hay of haystack) { + if (hay === needle) count += 1; } return count; } @@ -61,10 +61,6 @@ function getParts(part: string, file: string) { return result; } -function areSamePart(a: RoutePart, b: RoutePart) { - return a.content === b.content && a.dynamic === b.dynamic && a.spread === b.spread; -} - function getPattern( segments: RoutePart[][], base: string, @@ -208,25 +204,6 @@ function injectedRouteToItem( }; } -// Seeings if the two routes are siblings of each other, with `b` being the route -// in focus. If it is in the same parent folder as `a`, they are siblings. -function areSiblings(a: RouteData, b: RouteData) { - if (a.segments.length < b.segments.length) return false; - for (let i = 0; i < b.segments.length - 1; i++) { - let segment = b.segments[i]; - if (segment.length === a.segments[i].length) { - for (let j = 0; j < segment.length; j++) { - if (!areSamePart(segment[j], a.segments[i][j])) { - return false; - } - } - } else { - return false; - } - } - return true; -} - export interface CreateRouteManifestParams { /** Astro Settings object */ settings: AstroSettings; @@ -243,16 +220,16 @@ export function createRouteManifest( ): ManifestData { const components: string[] = []; const routes: RouteData[] = []; - const validPageExtensions: Set = new Set([ + const validPageExtensions = new Set([ '.astro', ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS, ...settings.pageExtensions, ]); - const validEndpointExtensions: Set = new Set(['.js', '.ts']); + const validEndpointExtensions = new Set(['.js', '.ts']); const localFs = fsMod ?? nodeFs; const prerender = getPrerenderDefault(settings.config); - const foundInvalidFileExtensions: Set = new Set(); + const foundInvalidFileExtensions = new Set(); function walk( fs: typeof nodeFs, diff --git a/packages/astro/src/events/error.ts b/packages/astro/src/events/error.ts index 73ac2b5e410e..cc7279f3d107 100644 --- a/packages/astro/src/events/error.ts +++ b/packages/astro/src/events/error.ts @@ -29,7 +29,7 @@ interface ConfigErrorEventPayload extends ErrorEventPayload { const ANONYMIZE_MESSAGE_REGEX = /^(\w| )+/; function anonymizeErrorMessage(msg: string): string | undefined { const matchedMessage = msg.match(ANONYMIZE_MESSAGE_REGEX); - if (!matchedMessage || !matchedMessage[0]) { + if (!matchedMessage?.[0]) { return undefined; } return matchedMessage[0].trim().substring(0, 20); @@ -72,6 +72,8 @@ export function eventError({ cliCommand: cmd, isFatal: isFatal, anonymousMessageHint: + // https://github.com/typescript-eslint/typescript-eslint/issues/4820 + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- errorData may be false errorData && errorData.message ? getSafeErrorMessage(errorData.message) : anonymizeErrorMessage(err.message), diff --git a/packages/astro/src/runtime/client/visible.ts b/packages/astro/src/runtime/client/visible.ts index e42b0433996d..cc4f7777139c 100644 --- a/packages/astro/src/runtime/client/visible.ts +++ b/packages/astro/src/runtime/client/visible.ts @@ -21,8 +21,7 @@ const visibleDirective: ClientDirective = (load, _options, el) => { } }); - for (let i = 0; i < el.children.length; i++) { - const child = el.children[i]; + for (const child of el.children) { io.observe(child); } }; diff --git a/packages/astro/src/runtime/server/astro-global.ts b/packages/astro/src/runtime/server/astro-global.ts index da1f0e78488a..82855c669e77 100644 --- a/packages/astro/src/runtime/server/astro-global.ts +++ b/packages/astro/src/runtime/server/astro-global.ts @@ -4,7 +4,7 @@ import { AstroError, AstroErrorData } from '../../core/errors/index.js'; /** Create the Astro.glob() runtime function. */ function createAstroGlobFn() { - const globHandler = (importMetaGlobResult: Record, globValue: () => any) => { + const globHandler = (importMetaGlobResult: Record) => { if (typeof importMetaGlobResult === 'string') { throw new AstroError({ ...AstroErrorData.AstroGlobUsedOutside, diff --git a/packages/astro/src/runtime/server/astro-island.ts b/packages/astro/src/runtime/server/astro-island.ts index 3f93cd817500..5887f3149be5 100644 --- a/packages/astro/src/runtime/server/astro-island.ts +++ b/packages/astro/src/runtime/server/astro-island.ts @@ -118,13 +118,13 @@ declare const Astro: { const templates = this.querySelectorAll('template[data-astro-template]'); for (const template of templates) { const closest = template.closest(this.tagName); - if (!closest || !closest.isSameNode(this)) continue; + if (!closest?.isSameNode(this)) continue; slots[template.getAttribute('data-astro-template') || 'default'] = template.innerHTML; template.remove(); } for (const slot of slotted) { const closest = slot.closest(this.tagName); - if (!closest || !closest.isSameNode(this)) continue; + if (!closest?.isSameNode(this)) continue; slots[slot.getAttribute('name') || 'default'] = slot.innerHTML; } const props = this.hasAttribute('props') diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 8adc10c72c0c..c56ab764602c 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -19,7 +19,7 @@ function getHandlerFromModule(mod: EndpointHandler, method: string) { /** Renders an endpoint request to completion, returning the body. */ export async function renderEndpoint(mod: EndpointHandler, context: APIContext, ssr: boolean) { - const { request, params, locals } = context; + const { request, params } = context; const chosenMethod = request.method?.toLowerCase(); const handler = getHandlerFromModule(mod, chosenMethod); if (!ssr && ssr === false && chosenMethod && chosenMethod !== 'get') { diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts index c8da19eaf23a..6bea1bc71aac 100644 --- a/packages/astro/src/runtime/server/jsx.ts +++ b/packages/astro/src/runtime/server/jsx.ts @@ -85,10 +85,7 @@ Did you forget to import the component or is it possible there is a typo?`); let props: Record = {}; let slots: Record = {}; for (const [key, value] of Object.entries(vnode.props ?? {})) { - if ( - key === 'children' || - (value && typeof value === 'object' && (value as any)['$$slot']) - ) { + if (key === 'children' || (value && typeof value === 'object' && value['$$slot'])) { slots[key === 'children' ? 'default' : key] = () => renderJSX(result, value); } else { props[key] = value; @@ -117,7 +114,7 @@ Did you forget to import the component or is it possible there is a typo?`); try { const output = await vnode.type(vnode.props ?? {}); let renderResult: any; - if (output && output[AstroJSX]) { + if (output?.[AstroJSX]) { renderResult = await renderJSXVNode(result, output, skip); return renderResult; } else if (!output) { @@ -251,11 +248,9 @@ function useConsoleFilter() { consoleFilterRefs++; if (!originalConsoleError) { - // eslint-disable-next-line no-console originalConsoleError = console.error; try { - // eslint-disable-next-line no-console console.error = filteredConsoleError; } catch (error) { // If we're unable to hook `console.error`, just accept it diff --git a/packages/astro/src/runtime/server/render/head.ts b/packages/astro/src/runtime/server/render/head.ts index 52923c790644..8ac9df0e0695 100644 --- a/packages/astro/src/runtime/server/render/head.ts +++ b/packages/astro/src/runtime/server/render/head.ts @@ -25,7 +25,7 @@ export function renderAllHeadContent(result: SSRResult) { result.styles.clear(); const scripts = Array.from(result.scripts) .filter(uniqueElements) - .map((script, i) => { + .map((script) => { return renderElement('script', script, false); }); const links = Array.from(result.links) diff --git a/packages/astro/src/runtime/server/render/slot.ts b/packages/astro/src/runtime/server/render/slot.ts index 09a8ff39c44f..152230ba9a5c 100644 --- a/packages/astro/src/runtime/server/render/slot.ts +++ b/packages/astro/src/runtime/server/render/slot.ts @@ -51,7 +51,7 @@ export async function renderSlotToString( let instructions: null | RenderInstruction[] = null; let iterator = renderSlot(result, slotted, fallback); for await (const chunk of iterator) { - if (typeof (chunk as any).type === 'string') { + if (typeof chunk.type === 'string') { if (instructions === null) { instructions = []; } diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts index 96735f2cb194..be8ddb7b0687 100644 --- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts +++ b/packages/astro/src/vite-plugin-astro-postprocess/index.ts @@ -2,17 +2,12 @@ import { parse } from 'acorn'; import { walk } from 'estree-walker'; import MagicString from 'magic-string'; import type { Plugin } from 'vite'; -import type { AstroSettings } from '../@types/astro'; import { isMarkdownFile } from '../core/util.js'; // Check for `Astro.glob()`. Be very forgiving of whitespace. False positives are okay. const ASTRO_GLOB_REGEX = /Astro2?\s*\.\s*glob\s*\(/; -interface AstroPluginOptions { - settings: AstroSettings; -} - -export default function astro(_opts: AstroPluginOptions): Plugin { +export default function astro(): Plugin { return { name: 'astro:postprocess', async transform(code, id) { diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 29f83c85cdfa..72d6deb9573f 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -31,7 +31,7 @@ export default function createVitePluginAstroServer({ const serverController = createController({ loader }); /** rebuild the route cache + manifest, as needed. */ - function rebuildManifest(needsManifestRebuild: boolean, _file: string) { + function rebuildManifest(needsManifestRebuild: boolean) { env.routeCache.clearAll(); if (needsManifestRebuild) { manifest = createRouteManifest({ settings }, logging); @@ -66,7 +66,7 @@ export default function createVitePluginAstroServer({ if (!id.includes('vite/dist/client/client.mjs')) return; // Replace the Vite overlay with ours - return patchOverlay(code, settings.config); + return patchOverlay(code); }, }; } diff --git a/packages/astro/src/vite-plugin-astro-server/request.ts b/packages/astro/src/vite-plugin-astro-server/request.ts index 197033b048c9..21599064c7c2 100644 --- a/packages/astro/src/vite-plugin-astro-server/request.ts +++ b/packages/astro/src/vite-plugin-astro-server/request.ts @@ -84,7 +84,7 @@ export async function handleRequest( // This could be a runtime error from Vite's SSR module, so try to fix it here try { - env.loader.fixStacktrace(err as Error); + env.loader.fixStacktrace(err); } catch {} // This is our last line of defense regarding errors where we still might have some information about the request diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index ffa6e1da6cbe..aa3342a6c4c8 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -137,7 +137,7 @@ export async function handleRoute( const { config } = settings; const filePath: URL | undefined = matchedRoute.filePath; - const { route, preloadedComponent, mod } = matchedRoute; + const { route, preloadedComponent } = matchedRoute; const buildingToSSR = isServerLikeOutput(config); // Headers are only available when using SSR. diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts index 6bee4f672ae0..0013676157b5 100644 --- a/packages/astro/src/vite-plugin-astro/compile.ts +++ b/packages/astro/src/vite-plugin-astro/compile.ts @@ -93,8 +93,6 @@ async function enhanceCompileError({ err, id, source, - config, - logging, }: EnhanceCompilerErrorOptions): Promise { const lineText = (err as any).loc?.lineText; // Verify frontmatter: a common reason that this plugin fails is that @@ -122,7 +120,7 @@ async function enhanceCompileError({ } catch (frontmatterErr: any) { // Improve the error by replacing the phrase "unexpected end of file" // with "unexpected end of frontmatter" in the esbuild error message. - if (frontmatterErr && frontmatterErr.message) { + if (frontmatterErr?.message) { frontmatterErr.message = frontmatterErr.message.replace( 'end of file', 'end of frontmatter' diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 8c94cb646e4a..f123dba3ab96 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -15,7 +15,7 @@ import { isAstroScript } from './query.js'; const PKG_PREFIX = fileURLToPath(new URL('../../', import.meta.url)); const E2E_PREFIX = fileURLToPath(new URL('../../e2e', import.meta.url)); const isPkgFile = (id: string | null) => { - return id && id.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX); + return id?.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX); }; export interface HandleHotUpdateOptions { diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 70c4da61181d..c5523d71231c 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -88,7 +88,7 @@ export default function astro({ settings, logging }: AstroPluginOptions): vite.P } if (hoistedScript.type === 'external') { - const src = hoistedScript.src!; + const src = hoistedScript.src; if (src.startsWith('/') && !isBrowserPath(src)) { const publicDir = config.publicDir.pathname.replace(/\/$/, '').split('/').pop() + '/'; throw new Error( diff --git a/packages/astro/src/vite-plugin-head/index.ts b/packages/astro/src/vite-plugin-head/index.ts index 4f44aaf6e487..9cfdc739f0e6 100644 --- a/packages/astro/src/vite-plugin-head/index.ts +++ b/packages/astro/src/vite-plugin-head/index.ts @@ -1,8 +1,7 @@ import type { ModuleInfo } from 'rollup'; import type * as vite from 'vite'; -import type { AstroSettings, SSRComponentMetadata, SSRResult } from '../@types/astro'; +import type { SSRComponentMetadata, SSRResult } from '../@types/astro'; import type { AstroBuildPlugin } from '../core/build/plugin.js'; -import type { StaticBuildOptions } from '../core/build/types'; import type { PluginMetadata } from '../vite-plugin-astro/types'; import { getTopLevelPages, walkParentInfos } from '../core/build/graph.js'; @@ -12,11 +11,7 @@ import { getAstroMetadata } from '../vite-plugin-astro/index.js'; // Detect this in comments, both in .astro components and in js/ts files. const injectExp = /(^\/\/|\/\/!)\s*astro-head-inject/; -export default function configHeadVitePlugin({ - settings, -}: { - settings: AstroSettings; -}): vite.Plugin { +export default function configHeadVitePlugin(): vite.Plugin { let server: vite.ViteDevServer; function propagateMetadata< @@ -70,10 +65,7 @@ export default function configHeadVitePlugin({ }; } -export function astroHeadBuildPlugin( - options: StaticBuildOptions, - internals: BuildInternals -): AstroBuildPlugin { +export function astroHeadBuildPlugin(internals: BuildInternals): AstroBuildPlugin { return { build: 'ssr', hooks: { diff --git a/packages/astro/src/vite-plugin-html/transform/escape.ts b/packages/astro/src/vite-plugin-html/transform/escape.ts index 5f2ecf6d6374..1c250d43dc94 100644 --- a/packages/astro/src/vite-plugin-html/transform/escape.ts +++ b/packages/astro/src/vite-plugin-html/transform/escape.ts @@ -6,8 +6,8 @@ import { visit } from 'unist-util-visit'; import { escape, needsEscape, replaceAttribute } from './utils.js'; const rehypeEscape: Plugin<[{ s: MagicString }], Root> = ({ s }) => { - return (tree, file) => { - visit(tree, (node: Root | RootContent, index, parent) => { + return (tree) => { + visit(tree, (node: Root | RootContent) => { if (node.type === 'text' || node.type === 'comment') { if (needsEscape(node.value)) { s.overwrite(node.position!.start.offset!, node.position!.end.offset!, escape(node.value)); diff --git a/packages/astro/src/vite-plugin-html/transform/slots.ts b/packages/astro/src/vite-plugin-html/transform/slots.ts index e89cad42cf0b..a549a48c9121 100644 --- a/packages/astro/src/vite-plugin-html/transform/slots.ts +++ b/packages/astro/src/vite-plugin-html/transform/slots.ts @@ -7,7 +7,7 @@ import { escape } from './utils.js'; const rehypeSlots: Plugin<[{ s: MagicString }], Root> = ({ s }) => { return (tree, file) => { - visit(tree, (node: Root | RootContent, index, parent) => { + visit(tree, (node: Root | RootContent) => { if (node.type === 'element' && node.tagName === 'slot') { if (typeof node.properties?.['is:inline'] !== 'undefined') return; const name = node.properties?.['name'] ?? 'default'; diff --git a/packages/astro/src/vite-plugin-jsx/import-source.ts b/packages/astro/src/vite-plugin-jsx/import-source.ts index 35efcaedac8c..c1f9ea6dce9f 100644 --- a/packages/astro/src/vite-plugin-jsx/import-source.ts +++ b/packages/astro/src/vite-plugin-jsx/import-source.ts @@ -51,7 +51,7 @@ function detectImportSourceFromComments(code: string): string | undefined { // if no imports were found, look for @jsxImportSource comment const multiline = code.match(/\/\*\*?[\S\s]*\*\//gm) || []; for (const comment of multiline) { - const [_, lib] = comment.slice(0, -2).match(/@jsxImportSource\s*(\S+)/) || []; + const [, lib] = comment.slice(0, -2).match(/@jsxImportSource\s*(\S+)/) || []; if (lib) { return lib.trim(); } diff --git a/packages/astro/src/vite-plugin-jsx/tag.ts b/packages/astro/src/vite-plugin-jsx/tag.ts index eab920f63720..5efc4c41f6e7 100644 --- a/packages/astro/src/vite-plugin-jsx/tag.ts +++ b/packages/astro/src/vite-plugin-jsx/tag.ts @@ -11,7 +11,6 @@ import * as t from '@babel/types'; */ export default async function tagExportsWithRenderer({ rendererName, - root, }: { rendererName: string; root: URL; diff --git a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts index 92bb118d43a7..dc32969747da 100644 --- a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts +++ b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts @@ -1,11 +1,10 @@ -import { fileURLToPath } from 'node:url'; import type { ContentEntryType } from '../@types/astro.js'; import { parseFrontmatter } from '../content/utils.js'; export const markdownContentEntryType: ContentEntryType = { extensions: ['.md'], - async getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) { - const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl)); + async getEntryInfo({ contents }: { contents: string }) { + const parsed = parseFrontmatter(contents); return { data: parsed.data, body: parsed.content, diff --git a/packages/astro/src/vite-plugin-scanner/scan.ts b/packages/astro/src/vite-plugin-scanner/scan.ts index 7723c3fd6289..83ca3c5c5cde 100644 --- a/packages/astro/src/vite-plugin-scanner/scan.ts +++ b/packages/astro/src/vite-plugin-scanner/scan.ts @@ -41,7 +41,7 @@ export async function scan(code: string, id: string, isHybridOutput = false): Pr didInit = true; } - const [_, exports] = eslexer.parse(code, id); + const [, exports] = eslexer.parse(code, id); let pageOptions: PageOptions = {}; for (const _export of exports) { const { n: name, le: endOfLocalName } = _export; diff --git a/packages/astro/src/vite-plugin-scripts/index.ts b/packages/astro/src/vite-plugin-scripts/index.ts index 18f90b057967..d49d0e22f909 100644 --- a/packages/astro/src/vite-plugin-scripts/index.ts +++ b/packages/astro/src/vite-plugin-scripts/index.ts @@ -48,7 +48,7 @@ export default function astroScriptsPlugin({ settings }: { settings: AstroSettin } return null; }, - buildStart(options) { + buildStart() { const hasHydrationScripts = settings.scripts.some((s) => s.stage === 'before-hydration'); if (hasHydrationScripts && env?.command === 'build' && !env?.ssrBuild) { this.emitFile({ diff --git a/packages/astro/src/vite-plugin-ssr-manifest/index.ts b/packages/astro/src/vite-plugin-ssr-manifest/index.ts index 4ced3d032f30..05e1f54be82f 100644 --- a/packages/astro/src/vite-plugin-ssr-manifest/index.ts +++ b/packages/astro/src/vite-plugin-ssr-manifest/index.ts @@ -7,7 +7,7 @@ export function vitePluginSSRManifest(): VitePlugin { return { name: '@astrojs/vite-plugin-astro-ssr-manifest', enforce: 'post', - resolveId(id, parent) { + resolveId(id) { if (id === manifestVirtualModuleId) { return resolvedManifestVirtualModuleId; } diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js index 5ed34b8ba70b..5d91815ba5ce 100644 --- a/packages/astro/test/astro-dynamic.test.js +++ b/packages/astro/test/astro-dynamic.test.js @@ -20,7 +20,6 @@ describe('Dynamic components', () => { }); it('Loads pages using client:media hydrator', async () => { - const root = new URL('http://example.com/media/index.html'); const html = await fixture.readFile('/media/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-pagination.test.js b/packages/astro/test/astro-pagination.test.js index 994f8e0ac942..5fb3a8dbdea9 100644 --- a/packages/astro/test/astro-pagination.test.js +++ b/packages/astro/test/astro-pagination.test.js @@ -41,7 +41,7 @@ describe('Pagination', () => { { color: 'blue', p: '2' }, ]; await Promise.all( - params.map(async ({ color, p }, idx) => { + params.map(async ({ color, p }) => { const html = await fixture.readFile(`/posts/${color}/${p}/index.html`); const $ = cheerio.load(html); expect($('#page-param').text()).to.equal(p); diff --git a/packages/astro/test/astro-response.test.js b/packages/astro/test/astro-response.test.js index 050feaabbf4c..c77e7bad34ef 100644 --- a/packages/astro/test/astro-response.test.js +++ b/packages/astro/test/astro-response.test.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import { load as cheerioLoad } from 'cheerio'; import { loadFixture } from './test-utils.js'; // Asset bundling diff --git a/packages/astro/test/component-library.test.js b/packages/astro/test/component-library.test.js index bab16230b723..58c7fb6b80aa 100644 --- a/packages/astro/test/component-library.test.js +++ b/packages/astro/test/component-library.test.js @@ -21,7 +21,7 @@ describe('Component Libraries', () => { await fixture.build(); }); - function createFindEvidence(expected, prefix) { + function createFindEvidence(expected) { return async function findEvidence(pathname) { const html = await fixture.readFile(pathname); const $ = cheerioLoad(html); @@ -102,7 +102,7 @@ describe('Component Libraries', () => { await devServer.stop(); }); - function createFindEvidence(expected, prefix) { + function createFindEvidence(expected) { return async function findEvidence(pathname) { const html = await fixture.fetch(pathname).then((res) => res.text()); const $ = cheerioLoad(html); diff --git a/packages/astro/test/config-mode.test.js b/packages/astro/test/config-mode.test.js index 76c45ba4889d..84dafb81f723 100644 --- a/packages/astro/test/config-mode.test.js +++ b/packages/astro/test/config-mode.test.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import { load as cheerioLoad } from 'cheerio'; import { loadFixture } from './test-utils.js'; import testAdapter from './test-adapter.js'; diff --git a/packages/astro/test/error-bad-js.test.js b/packages/astro/test/error-bad-js.test.js index 9149d8ad5bdb..ba02c62ff88d 100644 --- a/packages/astro/test/error-bad-js.test.js +++ b/packages/astro/test/error-bad-js.test.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import * as cheerio from 'cheerio'; import { loadFixture, silentLogging } from './test-utils.js'; describe('Errors in JavaScript', () => { diff --git a/packages/astro/test/postcss.test.js b/packages/astro/test/postcss.test.js index b2d663533252..126fca95cad3 100644 --- a/packages/astro/test/postcss.test.js +++ b/packages/astro/test/postcss.test.js @@ -4,8 +4,6 @@ import eol from 'eol'; import { loadFixture } from './test-utils.js'; describe('PostCSS', function () { - const PREFIXED_CSS = `{-webkit-appearance:none;appearance:none`; - let fixture; let bundledCSS; before(async () => { diff --git a/packages/astro/test/public-base-404.test.js b/packages/astro/test/public-base-404.test.js index bf98967cbf77..c8d58471d0b1 100644 --- a/packages/astro/test/public-base-404.test.js +++ b/packages/astro/test/public-base-404.test.js @@ -5,8 +5,6 @@ import { loadFixture } from './test-utils.js'; describe('Public dev with base', () => { /** @type {import('./test-utils').Fixture} */ let fixture; - /** @type {import('./test-utils').DevServer} */ - let devServer; let $; before(async () => { @@ -15,7 +13,7 @@ describe('Public dev with base', () => { site: 'http://example.com/', base: '/blog', }); - devServer = await fixture.startDevServer(); + await fixture.startDevServer(); }); it('200 when loading /@vite/client', async () => { diff --git a/packages/astro/test/static-build-page-url-format.test.js b/packages/astro/test/static-build-page-url-format.test.js index 6d08e85e6aca..2f8660b63c6e 100644 --- a/packages/astro/test/static-build-page-url-format.test.js +++ b/packages/astro/test/static-build-page-url-format.test.js @@ -1,11 +1,6 @@ import { expect } from 'chai'; -import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -function addLeadingSlash(path) { - return path.startsWith('/') ? path : '/' + path; -} - describe("Static build - format: 'file'", () => { let fixture; diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js index db35ef991ab8..d4a687a5d85f 100644 --- a/packages/astro/test/static-build.test.js +++ b/packages/astro/test/static-build.test.js @@ -88,7 +88,7 @@ describe('Static build', () => { } }); - function createFindEvidence(expected, prefix) { + function createFindEvidence(expected) { return async function findEvidence(pathname) { const html = await fixture.readFile(pathname); const $ = cheerioLoad(html); diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index 953ebf6daeeb..1fa04d47a6c9 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -101,8 +101,7 @@ export const silentLogging = { * .clean() - Async. Removes the project’s dist folder. */ export async function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // load config let cwd = inlineConfig.root; @@ -235,7 +234,7 @@ export async function loadFixture(inlineConfig) { }, loadTestAdapterApp: async (streaming) => { const url = new URL(`./server/entry.mjs?id=${fixtureId}`, config.outDir); - const { createApp, manifest, middleware } = await import(url); + const { createApp, manifest } = await import(url); const app = createApp(streaming); app.manifest = manifest; return app; diff --git a/packages/astro/test/units/compile/invalid-css.test.js b/packages/astro/test/units/compile/invalid-css.test.js index 6be17620a580..52da94816fe0 100644 --- a/packages/astro/test/units/compile/invalid-css.test.js +++ b/packages/astro/test/units/compile/invalid-css.test.js @@ -9,7 +9,7 @@ describe('astro/src/core/compile', () => { it('throws an aggregate error with the errors', async () => { let error; try { - let r = await cachedCompilation({ + await cachedCompilation({ astroConfig: { root: pathToFileURL('/'), }, diff --git a/packages/astro/test/units/config/format.test.js b/packages/astro/test/units/config/format.test.js index 175ea9f042b3..602c19cc374c 100644 --- a/packages/astro/test/units/config/format.test.js +++ b/packages/astro/test/units/config/format.test.js @@ -1,6 +1,4 @@ import { expect } from 'chai'; -import * as cheerio from 'cheerio'; -import { fileURLToPath } from 'url'; import { runInContainer } from '../../../dist/core/dev/index.js'; import { openConfig, createSettings } from '../../../dist/core/config/index.js'; diff --git a/packages/astro/test/units/dev/hydration.test.js b/packages/astro/test/units/dev/hydration.test.js index 0fb10ffda9eb..0a176b4db0fe 100644 --- a/packages/astro/test/units/dev/hydration.test.js +++ b/packages/astro/test/units/dev/hydration.test.js @@ -48,7 +48,7 @@ describe('dev container', () => { url: '/', }); container.handle(req, res); - const html = await done; + await done; expect(res.statusCode).to.equal( 200, "We get a 200 because the error occurs in the template, but we didn't crash!" diff --git a/packages/astro/test/units/dev/styles.test.js b/packages/astro/test/units/dev/styles.test.js index 76af929beb08..45bb6e172475 100644 --- a/packages/astro/test/units/dev/styles.test.js +++ b/packages/astro/test/units/dev/styles.test.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import { fileURLToPath } from 'url'; import { getStylesForURL } from '../../../dist/core/render/dev/css.js'; import { viteID } from '../../../dist/core/util.js'; diff --git a/packages/astro/test/units/render/head.test.js b/packages/astro/test/units/render/head.test.js index 83fbc8b11875..480651fd1415 100644 --- a/packages/astro/test/units/render/head.test.js +++ b/packages/astro/test/units/render/head.test.js @@ -72,7 +72,7 @@ describe('core/render', () => { `; }); - const Page = createComponent((result, _props) => { + const Page = createComponent((result) => { return render`${renderComponent( result, 'PageLayout', @@ -158,7 +158,7 @@ describe('core/render', () => { `; }); - const Page = createComponent((result, _props) => { + const Page = createComponent((result) => { return render`${renderComponent( result, 'PageLayout', @@ -221,7 +221,7 @@ describe('core/render', () => { `; }); - const Page = createComponent((result, _props) => { + const Page = createComponent((result) => { return render`${renderComponent( result, 'PageLayout', diff --git a/packages/astro/test/units/render/jsx.test.js b/packages/astro/test/units/render/jsx.test.js index 09cf7923935d..e972213f1f3f 100644 --- a/packages/astro/test/units/render/jsx.test.js +++ b/packages/astro/test/units/render/jsx.test.js @@ -119,7 +119,7 @@ describe('core/render', () => { throw new Error('uh oh'); }); - const Page = createComponent((result, _props) => { + const Page = createComponent((result) => { return render`
${renderComponent(result, 'Component', Component, {})}
`; }); diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js index 68a86d47564c..78c7daca04cc 100644 --- a/packages/astro/test/units/test-utils.js +++ b/packages/astro/test/units/test-utils.js @@ -3,7 +3,7 @@ import { Volume } from 'memfs'; import httpMocks from 'node-mocks-http'; import realFS from 'node:fs'; import npath from 'path'; -import { fileURLToPath, pathToFileURL } from 'url'; +import { fileURLToPath } from 'url'; import { unixify } from './correct-path.js'; class VirtualVolume extends Volume { diff --git a/packages/astro/test/units/vite-plugin-scanner/scan.test.js b/packages/astro/test/units/vite-plugin-scanner/scan.test.js index 7b9c598bef6a..3d812a893cf1 100644 --- a/packages/astro/test/units/vite-plugin-scanner/scan.test.js +++ b/packages/astro/test/units/vite-plugin-scanner/scan.test.js @@ -49,7 +49,7 @@ describe('astro scan', () => { it('throws on let boolean literal', async () => { try { - const result = await scan(`export let prerender = true;`, '/src/components/index.astro'); + await scan(`export let prerender = true;`, '/src/components/index.astro'); expect(false).to.be.true; } catch (e) { expect(e.message).to.contain( @@ -60,7 +60,7 @@ describe('astro scan', () => { it('throws on var boolean literal', async () => { try { - const result = await scan(`export var prerender = true;`, '/src/components/index.astro'); + await scan(`export var prerender = true;`, '/src/components/index.astro'); expect(false).to.be.true; } catch (e) { expect(e.message).to.contain( @@ -71,7 +71,7 @@ describe('astro scan', () => { it('throws on unknown values I', async () => { try { - const result = await scan(`export const prerender = !!value;`, '/src/components/index.astro'); + await scan(`export const prerender = !!value;`, '/src/components/index.astro'); expect(false).to.be.true; } catch (e) { expect(e.message).to.contain( @@ -82,7 +82,7 @@ describe('astro scan', () => { it('throws on unknown values II', async () => { try { - const result = await scan(`export const prerender = value;`, '/src/components/index.astro'); + await scan(`export const prerender = value;`, '/src/components/index.astro'); expect(false).to.be.true; } catch (e) { expect(e.message).to.contain( @@ -93,7 +93,7 @@ describe('astro scan', () => { it('throws on unknown values III', async () => { try { - const result = await scan( + await scan( `export let prerender = undefined; prerender = true;`, '/src/components/index.astro' ); @@ -107,10 +107,7 @@ describe('astro scan', () => { it('throws on unknown values IV', async () => { try { - const result = await scan( - `let prerender = true; export { prerender }`, - '/src/components/index.astro' - ); + await scan(`let prerender = true; export { prerender }`, '/src/components/index.astro'); expect(false).to.be.true; } catch (e) { expect(e.message).to.contain( diff --git a/packages/astro/test/vue-with-multi-renderer.test.js b/packages/astro/test/vue-with-multi-renderer.test.js index 62ad96491884..78b243d78711 100644 --- a/packages/astro/test/vue-with-multi-renderer.test.js +++ b/packages/astro/test/vue-with-multi-renderer.test.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; describe('Vue with multi-renderer', () => { diff --git a/packages/create-astro/src/actions/context.ts b/packages/create-astro/src/actions/context.ts index 35e2e46880a6..172976b95e90 100644 --- a/packages/create-astro/src/actions/context.ts +++ b/packages/create-astro/src/actions/context.ts @@ -52,7 +52,7 @@ export async function getContext(argv: string[]): Promise { const pkgManager = detectPackageManager()?.name ?? 'npm'; const [username, version] = await Promise.all([getName(), getVersion()]); - let cwd = flags['_'][0] as string; + let cwd = flags['_'][0]; let { '--help': help = false, '--template': template, diff --git a/packages/create-astro/src/actions/git.ts b/packages/create-astro/src/actions/git.ts index 075c13330b6b..00c42dae5691 100644 --- a/packages/create-astro/src/actions/git.ts +++ b/packages/create-astro/src/actions/git.ts @@ -31,7 +31,6 @@ export async function git(ctx: Pick init({ cwd: ctx.cwd }).catch((e) => { - // eslint-disable-next-line no-console error('error', e); process.exit(1); }), diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index 85b7d6f27b31..f762b264f7c4 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -1,4 +1,3 @@ -/* eslint no-console: 'off' */ import type { Context } from './context'; import { color } from '@astrojs/cli-kit'; @@ -34,7 +33,6 @@ export async function template(ctx: Pick copyTemplate(ctx.template!, ctx as Context).catch((e) => { - // eslint-disable-next-line no-console if (e instanceof Error) { error('error', e.message); process.exit(1); diff --git a/packages/create-astro/src/actions/typescript.ts b/packages/create-astro/src/actions/typescript.ts index 5e118cb38f3a..8c0e2716ceae 100644 --- a/packages/create-astro/src/actions/typescript.ts +++ b/packages/create-astro/src/actions/typescript.ts @@ -63,7 +63,6 @@ export async function typescript( end: 'TypeScript customized', while: () => setupTypeScript(ts!, { cwd: ctx.cwd }).catch((e) => { - // eslint-disable-next-line no-console error('error', e); process.exit(1); }), diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index 40700a704d0d..a69c43ce8978 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -64,11 +64,11 @@ export const welcome = [ export const getName = () => new Promise((resolve) => { - exec('git config user.name', { encoding: 'utf-8' }, (_1, gitName, _2) => { + exec('git config user.name', { encoding: 'utf-8' }, (_1, gitName) => { if (gitName.trim()) { return resolve(gitName.split(' ')[0].trim()); } - exec('whoami', { encoding: 'utf-8' }, (_3, whoami, _4) => { + exec('whoami', { encoding: 'utf-8' }, (_3, whoami) => { if (whoami.trim()) { return resolve(whoami.split(' ')[0].trim()); } diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 298d798fb884..3dc237b7274d 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -93,7 +93,7 @@ export default function createIntegration(args?: Options): AstroIntegration { vite.ssr.target = 'webworker'; } }, - 'astro:build:ssr': ({ manifest, entryPoints }) => { + 'astro:build:ssr': ({ entryPoints }) => { _entryPoints = entryPoints; }, 'astro:build:done': async ({ pages, routes, dir }) => { @@ -138,7 +138,7 @@ export default function createIntegration(args?: Options): AstroIntegration { const fileName = entryPointsRouteData[index].component .replace('src/pages/', '') .replace('.astro', '.js') - .replace(/(\[\.\.\.)(\w+)(\])/g, (_match, _p1, p2, _p3) => { + .replace(/(\[\.\.\.)(\w+)(\])/g, (_match, _p1, p2) => { return `[[${p2}]]`; }); diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js index 6216e677c647..e0fc90a64e45 100644 --- a/packages/integrations/cloudflare/test/test-utils.js +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -37,7 +37,6 @@ export function runCLI(basePath, { silent, port = 8787 }) { (async function () { for (const msg of p.stderr) { if (!silent) { - // eslint-disable-next-line console.error(msg); } } @@ -45,7 +44,6 @@ export function runCLI(basePath, { silent, port = 8787 }) { for await (const msg of p.stdout) { if (!silent) { - // eslint-disable-next-line console.log(msg); } if (msg.includes(`Listening on`)) { diff --git a/packages/integrations/deno/src/index.ts b/packages/integrations/deno/src/index.ts index 8b1f38959fa9..93e51289bfb1 100644 --- a/packages/integrations/deno/src/index.ts +++ b/packages/integrations/deno/src/index.ts @@ -95,7 +95,7 @@ export function getAdapter(args?: Options): AstroAdapter { const denoImportsShimPlugin = { name: '@astrojs/deno:shim', setup(build: esbuild.PluginBuild) { - build.onLoad({ filter: /__deno_imports\.js$/ }, async (args) => { + build.onLoad({ filter: /__deno_imports\.js$/ }, async () => { return { contents: DENO_IMPORTS, loader: 'js', diff --git a/packages/integrations/deno/src/server.ts b/packages/integrations/deno/src/server.ts index 08d967065296..90a4a123795a 100644 --- a/packages/integrations/deno/src/server.ts +++ b/packages/integrations/deno/src/server.ts @@ -93,7 +93,6 @@ export function start(manifest: SSRManifest, options: Options) { }); _startPromise = Promise.resolve(_server.listenAndServe()); - // eslint-disable-next-line no-console console.error(`Server running on port ${port}`); } diff --git a/packages/integrations/deno/test/basics.test.ts b/packages/integrations/deno/test/basics.test.ts index 9e417450688a..5d3f116ddf1d 100644 --- a/packages/integrations/deno/test/basics.test.ts +++ b/packages/integrations/deno/test/basics.test.ts @@ -1,3 +1,5 @@ +/* Deno types consider DOM elements nullable */ +/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { DOMParser } from 'https://deno.land/x/deno_dom@v0.1.35-alpha/deno-dom-wasm.ts'; import { assert, assertEquals } from 'https://deno.land/std@0.158.0/testing/asserts.ts'; import { runBuildAndStartApp, defaultTestPermissions } from './helpers.ts'; diff --git a/packages/integrations/deno/test/dynamic-import.test.ts b/packages/integrations/deno/test/dynamic-import.test.ts index 987aac9ffdfe..aa9d44c6738d 100644 --- a/packages/integrations/deno/test/dynamic-import.test.ts +++ b/packages/integrations/deno/test/dynamic-import.test.ts @@ -1,3 +1,5 @@ +/* Deno types consider DOM elements nullable */ +/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { DOMParser } from 'https://deno.land/x/deno_dom@v0.1.35-alpha/deno-dom-wasm.ts'; import { assert, assertEquals } from 'https://deno.land/std@0.158.0/testing/asserts.ts'; import { runBuildAndStartAppFromSubprocess } from './helpers.ts'; diff --git a/packages/integrations/image/src/build/ssg.ts b/packages/integrations/image/src/build/ssg.ts index 2a6976d76adc..4a6d84d53936 100644 --- a/packages/integrations/image/src/build/ssg.ts +++ b/packages/integrations/image/src/build/ssg.ts @@ -162,7 +162,6 @@ export async function ssgBuild({ } if (!inputBuffer) { - // eslint-disable-next-line no-console warn({ level: logLevel, message: `"${src}" image could not be fetched` }); return; } diff --git a/packages/integrations/image/src/lib/get-image.ts b/packages/integrations/image/src/lib/get-image.ts index d6aae4665257..37f6a3bc4d73 100644 --- a/packages/integrations/image/src/lib/get-image.ts +++ b/packages/integrations/image/src/lib/get-image.ts @@ -1,10 +1,5 @@ /// -import type { - ColorDefinition, - ImageService, - OutputFormat, - TransformOptions, -} from '../loaders/index.js'; +import type { ImageService, OutputFormat, TransformOptions } from '../loaders/index.js'; import { isSSRService, parseAspectRatio } from '../loaders/index.js'; import { isRemoteImage } from '../utils/paths.js'; import type { ImageMetadata } from '../vite-plugin-astro-image.js'; @@ -91,7 +86,7 @@ async function resolveTransform(input: GetImageTransform): Promise instantiateEmscriptenWasm(avifDec as DecodeModuleFactory, avifDecWasm), @@ -318,7 +317,6 @@ export const codecs = { oxipng: { name: 'OxiPNG', extension: 'png', - // eslint-disable-next-line no-control-regex detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/], dec: async () => { await pngEncDecInit() diff --git a/packages/integrations/image/src/vendor/squoosh/image.ts b/packages/integrations/image/src/vendor/squoosh/image.ts index aad4fb598e45..c8862f0c4de8 100644 --- a/packages/integrations/image/src/vendor/squoosh/image.ts +++ b/packages/integrations/image/src/vendor/squoosh/image.ts @@ -29,14 +29,14 @@ export async function processBuffer( switch (encoding) { case 'avif': - return await impl.encodeAvif(imageData, { quality }) as Uint8Array; + return await impl.encodeAvif(imageData, { quality }); case 'jpeg': case 'jpg': - return await impl.encodeJpeg(imageData, { quality }) as Uint8Array; + return await impl.encodeJpeg(imageData, { quality }); case 'png': - return await impl.encodePng(imageData) as Uint8Array; + return await impl.encodePng(imageData); case 'webp': - return await impl.encodeWebp(imageData, { quality }) as Uint8Array; + return await impl.encodeWebp(imageData, { quality }); default: throw Error(`Unsupported encoding format`) } diff --git a/packages/integrations/image/test/background-color-image-ssg.test.js b/packages/integrations/image/test/background-color-image-ssg.test.js index 6c442361547e..ea55d7ae13dd 100644 --- a/packages/integrations/image/test/background-color-image-ssg.test.js +++ b/packages/integrations/image/test/background-color-image-ssg.test.js @@ -50,7 +50,7 @@ describe('SSG image with background - dev', function () { it(title, async () => { const image = $(id); const src = image.attr('src'); - const [_, params] = src.split('?'); + const [, params] = src.split('?'); const searchParams = new URLSearchParams(params); expect(searchParams.get('bg')).to.equal(bg); }); diff --git a/packages/integrations/image/test/background-color-image-ssr.test.js b/packages/integrations/image/test/background-color-image-ssr.test.js index 6bc5f333f303..66b512e304e6 100644 --- a/packages/integrations/image/test/background-color-image-ssr.test.js +++ b/packages/integrations/image/test/background-color-image-ssr.test.js @@ -104,7 +104,7 @@ describe('SSR image with background', function () { const image = $(id); const src = image.attr('src'); - const [_, params] = src.split('?'); + const [, params] = src.split('?'); const searchParams = new URLSearchParams(params); diff --git a/packages/integrations/image/test/test-utils.js b/packages/integrations/image/test/test-utils.js index e6c22e0ab877..122e901322db 100644 --- a/packages/integrations/image/test/test-utils.js +++ b/packages/integrations/image/test/test-utils.js @@ -1,8 +1,7 @@ import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js index a798dba4dabe..bf45dd9128d3 100644 --- a/packages/integrations/lit/client-shim.js +++ b/packages/integrations/lit/client-shim.js @@ -17,6 +17,6 @@ const polyfillCheckEl = new DOMParser() ) .querySelector('p'); -if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) { +if (!polyfillCheckEl?.shadowRoot) { polyfill(); } diff --git a/packages/integrations/lit/server.js b/packages/integrations/lit/server.js index d4ca4e08fcc7..d71ccee47b21 100644 --- a/packages/integrations/lit/server.js +++ b/packages/integrations/lit/server.js @@ -17,10 +17,10 @@ function getCustomElementConstructor(name) { async function isLitElement(Component) { const Ctr = getCustomElementConstructor(Component); - return !!(Ctr && Ctr._$litElement$); + return !!Ctr?._$litElement$; } -async function check(Component, _props, _children) { +async function check(Component) { // Lit doesn't support getting a tagName from a Constructor at this time. // So this must be a string at the moment. return !!(await isLitElement(Component)); diff --git a/packages/integrations/markdoc/src/content-entry-type.ts b/packages/integrations/markdoc/src/content-entry-type.ts index 097c5cfae95e..2bae5402cd4b 100644 --- a/packages/integrations/markdoc/src/content-entry-type.ts +++ b/packages/integrations/markdoc/src/content-entry-type.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import type { Config as MarkdocConfig, Node } from '@markdoc/markdoc'; import Markdoc from '@markdoc/markdoc'; import type { AstroConfig, ContentEntryType } from 'astro'; diff --git a/packages/integrations/markdoc/src/extensions/shiki.ts b/packages/integrations/markdoc/src/extensions/shiki.ts index 34f79779f27f..1229a09fb719 100644 --- a/packages/integrations/markdoc/src/extensions/shiki.ts +++ b/packages/integrations/markdoc/src/extensions/shiki.ts @@ -87,7 +87,6 @@ export default async function shiki({ if (langExists) { lang = attributes.language; } else { - // eslint-disable-next-line no-console console.warn( `[Shiki highlighter] The language "${attributes.language}" doesn't exist, falling back to plaintext.` ); diff --git a/packages/integrations/markdoc/src/index.ts b/packages/integrations/markdoc/src/index.ts index 60dd01843d02..f0d5a8a33684 100644 --- a/packages/integrations/markdoc/src/index.ts +++ b/packages/integrations/markdoc/src/index.ts @@ -1,8 +1,6 @@ /* eslint-disable no-console */ import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro'; import { bold, red } from 'kleur/colors'; -import { fileURLToPath } from 'node:url'; -import { normalizePath } from 'vite'; import { getContentEntryType } from './content-entry-type.js'; import { loadMarkdocConfig, @@ -26,7 +24,6 @@ export default function markdocIntegration(legacyConfig?: any): AstroIntegration process.exit(0); } let markdocConfigResult: MarkdocConfigResult | undefined; - let markdocConfigResultId = ''; let astroConfig: AstroConfig; return { name: '@astrojs/markdoc', @@ -36,9 +33,6 @@ export default function markdocIntegration(legacyConfig?: any): AstroIntegration astroConfig = params.config; markdocConfigResult = await loadMarkdocConfig(astroConfig); - if (markdocConfigResult) { - markdocConfigResultId = normalizePath(fileURLToPath(markdocConfigResult.fileUrl)); - } addContentEntryType(await getContentEntryType({ markdocConfigResult, astroConfig })); diff --git a/packages/integrations/markdoc/src/load-config.ts b/packages/integrations/markdoc/src/load-config.ts index 2077492517d3..23a397e47da9 100644 --- a/packages/integrations/markdoc/src/load-config.ts +++ b/packages/integrations/markdoc/src/load-config.ts @@ -30,7 +30,7 @@ export async function loadMarkdocConfig( } if (!markdocConfigUrl) return; - const { code, dependencies } = await bundleConfigFile({ + const { code } = await bundleConfigFile({ markdocConfigUrl, astroConfig, }); diff --git a/packages/integrations/markdoc/src/utils.ts b/packages/integrations/markdoc/src/utils.ts index 1fd896d5251c..3f2aed633ce9 100644 --- a/packages/integrations/markdoc/src/utils.ts +++ b/packages/integrations/markdoc/src/utils.ts @@ -15,7 +15,7 @@ export class MarkdocError extends Error { constructor(props: ErrorProperties, ...params: any) { super(...params); - const { name, title = 'MarkdocError', message, stack, location, hint, frame } = props; + const { title = 'MarkdocError', message, stack, location, hint, frame } = props; this.title = title; if (message) this.message = message; diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index 94c3c10ba00f..ed03f4b2b82b 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -33,7 +33,7 @@ export function recmaInjectImportMetaEnvPlugin({ estreeVisit(tree, (node) => { if (node.type === 'MemberExpression') { // attempt to get "import.meta.env" variable name - const envVarName = getImportMetaEnvVariableName(node as MemberExpression); + const envVarName = getImportMetaEnvVariableName(node); if (typeof envVarName === 'string') { // clear object keys to replace with envVarLiteral for (const key in node) { diff --git a/packages/integrations/mdx/src/remark-shiki.ts b/packages/integrations/mdx/src/remark-shiki.ts index 3f3310de7158..83625051e39a 100644 --- a/packages/integrations/mdx/src/remark-shiki.ts +++ b/packages/integrations/mdx/src/remark-shiki.ts @@ -69,7 +69,6 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: if (langExists) { lang = node.lang; } else { - // eslint-disable-next-line no-console console.warn(`The language "${node.lang}" doesn't exist, falling back to plaintext.`); lang = 'plaintext'; } @@ -77,7 +76,7 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: lang = 'plaintext'; } - let html = highlighter!.codeToHtml(node.value, { lang }); + let html = highlighter.codeToHtml(node.value, { lang }); // Q: Couldn't these regexes match on a user's inputted code blocks? // A: Nope! All rendered HTML is properly escaped. diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index 80f8c3e20246..3425c50e3484 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -32,7 +32,7 @@ export function getFileInfo(id: string, config: AstroConfig): FileInfo { const isPage = fileId.includes('/pages/'); if (isPage) { fileUrl = fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(\/index)?\.mdx$/, ''); - } else if (url && url.pathname.startsWith(config.root.pathname)) { + } else if (url?.pathname.startsWith(config.root.pathname)) { fileUrl = url.pathname.slice(config.root.pathname.length); } else { fileUrl = fileId; diff --git a/packages/integrations/mdx/test/mdx-get-headings.test.js b/packages/integrations/mdx/test/mdx-get-headings.test.js index 1b1987e77998..5b415c70f064 100644 --- a/packages/integrations/mdx/test/mdx-get-headings.test.js +++ b/packages/integrations/mdx/test/mdx-get-headings.test.js @@ -72,7 +72,7 @@ describe('MDX heading IDs can be customized by user plugins', () => { rehypePlugins: [ () => (tree) => { let count = 0; - visit(tree, 'element', (node, index, parent) => { + visit(tree, 'element', (node) => { if (!/^h\d$/.test(node.tagName)) return; if (!node.properties?.id) { node.properties = { ...node.properties, id: String(count++) }; @@ -125,7 +125,7 @@ describe('MDX heading IDs can be injected before user plugins', () => { rehypePlugins: [ rehypeHeadingIds, () => (tree) => { - visit(tree, 'element', (node, index, parent) => { + visit(tree, 'element', (node) => { if (!/^h\d$/.test(node.tagName)) return; if (node.properties?.id) { node.children.push({ type: 'text', value: ' ' + node.properties.id }); diff --git a/packages/integrations/mdx/test/mdx-page.test.js b/packages/integrations/mdx/test/mdx-page.test.js index 726f091c9023..52d10bce38e3 100644 --- a/packages/integrations/mdx/test/mdx-page.test.js +++ b/packages/integrations/mdx/test/mdx-page.test.js @@ -1,5 +1,3 @@ -import mdx from '@astrojs/mdx'; - import { expect } from 'chai'; import { parseHTML } from 'linkedom'; import { loadFixture } from '../../../astro/test/test-utils.js'; diff --git a/packages/integrations/mdx/test/mdx-plus-react.test.js b/packages/integrations/mdx/test/mdx-plus-react.test.js index 49c25d558dde..22d7ca0e721b 100644 --- a/packages/integrations/mdx/test/mdx-plus-react.test.js +++ b/packages/integrations/mdx/test/mdx-plus-react.test.js @@ -1,5 +1,3 @@ -import mdx from '@astrojs/mdx'; - import { expect } from 'chai'; import { parseHTML } from 'linkedom'; import { loadFixture } from '../../../astro/test/test-utils.js'; diff --git a/packages/integrations/netlify/test/edge-functions/dynamic-import.test.js b/packages/integrations/netlify/test/edge-functions/dynamic-import.test.js index febd689b6921..bfa895290d5e 100644 --- a/packages/integrations/netlify/test/edge-functions/dynamic-import.test.js +++ b/packages/integrations/netlify/test/edge-functions/dynamic-import.test.js @@ -17,7 +17,6 @@ Deno.test({ const div = doc.querySelector('#thing'); assert(div, 'div exists'); } catch (err) { - // eslint-disable-next-line no-console console.error(err); } finally { await stop(); diff --git a/packages/integrations/netlify/test/edge-functions/root-dynamic.test.ts b/packages/integrations/netlify/test/edge-functions/root-dynamic.test.ts index 0e38bc46ed6e..3fc2012c3de7 100644 --- a/packages/integrations/netlify/test/edge-functions/root-dynamic.test.ts +++ b/packages/integrations/netlify/test/edge-functions/root-dynamic.test.ts @@ -1,5 +1,5 @@ import { loadFixture } from './test-utils.ts'; -import { assertEquals, assert, DOMParser } from './deps.ts'; +import { assertEquals } from './deps.ts'; Deno.test({ // TODO: debug why build cannot be found in "await import" diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js index bc1771512c58..f15695235242 100644 --- a/packages/integrations/netlify/test/functions/cookies.test.js +++ b/packages/integrations/netlify/test/functions/cookies.test.js @@ -1,8 +1,6 @@ import { expect } from 'chai'; -import { load as cheerioLoad } from 'cheerio'; import { loadFixture, testIntegration } from './test-utils.js'; import netlifyAdapter from '../../dist/index.js'; -import { fileURLToPath } from 'url'; describe('Cookies', () => { /** @type {import('../../../astro/test/test-utils').Fixture} */ diff --git a/packages/integrations/netlify/test/functions/redirects.test.js b/packages/integrations/netlify/test/functions/redirects.test.js index 767e5b13b8a3..1e20d41a09f7 100644 --- a/packages/integrations/netlify/test/functions/redirects.test.js +++ b/packages/integrations/netlify/test/functions/redirects.test.js @@ -1,8 +1,6 @@ import { expect } from 'chai'; -import { load as cheerioLoad } from 'cheerio'; import { loadFixture, testIntegration } from './test-utils.js'; import netlifyAdapter from '../../dist/index.js'; -import { fileURLToPath } from 'url'; describe('SSG - Redirects', () => { /** @type {import('../../../astro/test/test-utils').Fixture} */ diff --git a/packages/integrations/node/src/http-server.ts b/packages/integrations/node/src/http-server.ts index 8d463ba6ffea..2b0252c6e870 100644 --- a/packages/integrations/node/src/http-server.ts +++ b/packages/integrations/node/src/http-server.ts @@ -46,7 +46,6 @@ export function createServer( stream.on('error', (err) => { if (forwardError) { - // eslint-disable-next-line no-console console.error(err.toString()); res.writeHead(500); res.end('Internal server error'); diff --git a/packages/integrations/node/src/response-iterator.ts b/packages/integrations/node/src/response-iterator.ts index f8941460b7dc..01624d81deb9 100644 --- a/packages/integrations/node/src/response-iterator.ts +++ b/packages/integrations/node/src/response-iterator.ts @@ -29,8 +29,7 @@ const canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator; function isBuffer(value: any): value is Buffer { return ( - value != null && - value.constructor != null && + value?.constructor != null && typeof value.constructor.isBuffer === 'function' && value.constructor.isBuffer(value) ); diff --git a/packages/integrations/node/test/node-middleware.test.js b/packages/integrations/node/test/node-middleware.test.js index e96d29ed480f..a658f93ef841 100644 --- a/packages/integrations/node/test/node-middleware.test.js +++ b/packages/integrations/node/test/node-middleware.test.js @@ -1,5 +1,5 @@ import nodejs from '../dist/index.js'; -import { loadFixture, createRequestAndResponse } from './test-utils.js'; +import { loadFixture } from './test-utils.js'; import { expect } from 'chai'; import * as cheerio from 'cheerio'; diff --git a/packages/integrations/node/test/test-utils.js b/packages/integrations/node/test/test-utils.js index 13e32a5e89c2..741564914076 100644 --- a/packages/integrations/node/test/test-utils.js +++ b/packages/integrations/node/test/test-utils.js @@ -7,8 +7,7 @@ import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.j */ export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index 97badee1b560..758756a31bca 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -1,7 +1,7 @@ import type { PartytownConfig } from '@builder.io/partytown/integration'; import { partytownSnippet } from '@builder.io/partytown/integration'; import { copyLibFiles, libDirPath } from '@builder.io/partytown/utils'; -import type { AstroConfig, AstroIntegration } from 'astro'; +import type { AstroIntegration } from 'astro'; import * as fs from 'fs'; import { createRequire } from 'module'; import path from 'path'; @@ -18,7 +18,6 @@ function appendForwardSlash(str: string) { } export default function createPlugin(options?: PartytownOptions): AstroIntegration { - let config: AstroConfig; let partytownSnippetHtml: string; const partytownEntrypoint = resolve('@builder.io/partytown/package.json'); const partytownLibDirectory = path.resolve(partytownEntrypoint, '../lib'); @@ -35,9 +34,6 @@ export default function createPlugin(options?: PartytownOptions): AstroIntegrati partytownSnippetHtml = partytownSnippet(partytownConfig); injectScript('head-inline', partytownSnippetHtml); }, - 'astro:config:done': ({ config: _config }) => { - config = _config; - }, 'astro:server:setup': ({ server }) => { const lib = `/~partytown/`; server.middlewares.use( diff --git a/packages/integrations/partytown/src/sirv.ts b/packages/integrations/partytown/src/sirv.ts index 78489d2ac52f..8e04fc85c3b5 100644 --- a/packages/integrations/partytown/src/sirv.ts +++ b/packages/integrations/partytown/src/sirv.ts @@ -40,8 +40,8 @@ import { URL } from 'url'; const noop = () => {}; function isMatch(uri, arr) { - for (let i = 0; i < arr.length; i++) { - if (arr[i].test(uri)) return true; + for (const candidate of arr) { + if (candidate.test(uri)) return true; } } diff --git a/packages/integrations/preact/src/client.ts b/packages/integrations/preact/src/client.ts index 9ef6b2caf174..f90614398886 100644 --- a/packages/integrations/preact/src/client.ts +++ b/packages/integrations/preact/src/client.ts @@ -2,7 +2,7 @@ import { h, render, type JSX } from 'preact'; import StaticHtml from './static-html.js'; import type { SignalLike } from './types'; -const sharedSignalMap: Map = new Map(); +const sharedSignalMap = new Map(); export default (element: HTMLElement) => async ( @@ -17,7 +17,7 @@ export default (element: HTMLElement) => let signalsRaw = element.dataset.preactSignals; if (signalsRaw) { const { signal } = await import('@preact/signals'); - let signals: Record = JSON.parse(element.dataset.preactSignals as string); + let signals: Record = JSON.parse(element.dataset.preactSignals!); for (const [propName, signalId] of Object.entries(signals)) { if (!sharedSignalMap.has(signalId)) { const signalValue = signal(props[propName]); diff --git a/packages/integrations/preact/src/server.ts b/packages/integrations/preact/src/server.ts index 9efd6017f727..6a2ceb612c98 100644 --- a/packages/integrations/preact/src/server.ts +++ b/packages/integrations/preact/src/server.ts @@ -101,11 +101,9 @@ function useConsoleFilter() { consoleFilterRefs++; if (!originalConsoleError) { - // eslint-disable-next-line no-console originalConsoleError = console.error; try { - // eslint-disable-next-line no-console console.error = filteredConsoleError; } catch (error) { // If we're unable to hook `console.error`, just accept it diff --git a/packages/integrations/prefetch/test/test-utils.js b/packages/integrations/prefetch/test/test-utils.js index 198ecaafa967..0b5de1f9db73 100644 --- a/packages/integrations/prefetch/test/test-utils.js +++ b/packages/integrations/prefetch/test/test-utils.js @@ -2,8 +2,7 @@ import { test as testBase } from '@playwright/test'; import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js index 522837a16dd5..5638c6fb776e 100644 --- a/packages/integrations/react/server-v17.js +++ b/packages/integrations/react/server-v17.js @@ -17,8 +17,7 @@ function check(Component, props, children) { // Note: there are packages that do some unholy things to create "components". // Checking the $$typeof property catches most of these patterns. if (typeof Component === 'object') { - const $$typeof = Component['$$typeof']; - return $$typeof && $$typeof.toString().slice('Symbol('.length).startsWith('react'); + return Component['$$typeof']?.toString().slice('Symbol('.length).startsWith('react'); } if (typeof Component !== 'function') return false; @@ -73,7 +72,7 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted } const vnode = React.createElement(Component, newProps); let html; - if (metadata && metadata.hydrate) { + if (metadata?.hydrate) { html = ReactDOM.renderToString(vnode); } else { html = ReactDOM.renderToStaticMarkup(vnode); diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index b6829e33877c..8c02c4b26b38 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -18,8 +18,7 @@ async function check(Component, props, children) { // Note: there are packages that do some unholy things to create "components". // Checking the $$typeof property catches most of these patterns. if (typeof Component === 'object') { - const $$typeof = Component['$$typeof']; - return $$typeof && $$typeof.toString().slice('Symbol('.length).startsWith('react'); + return Component['$$typeof'].toString().slice('Symbol('.length).startsWith('react'); } if (typeof Component !== 'function') return false; @@ -97,7 +96,7 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl identifierPrefix: prefix, }; let html; - if (metadata && metadata.hydrate) { + if (metadata?.hydrate) { if ('renderToReadableStream' in ReactDOM) { html = await renderToReadableStreamAsync(vnode, renderOptions); } else { diff --git a/packages/integrations/sitemap/src/config-defaults.ts b/packages/integrations/sitemap/src/config-defaults.ts index fbcd6263d28c..3d56483e196b 100644 --- a/packages/integrations/sitemap/src/config-defaults.ts +++ b/packages/integrations/sitemap/src/config-defaults.ts @@ -1,5 +1,5 @@ import type { SitemapOptions } from './index.js'; -export const SITEMAP_CONFIG_DEFAULTS: SitemapOptions & any = { +export const SITEMAP_CONFIG_DEFAULTS = { entryLimit: 45000, -}; +} satisfies SitemapOptions; diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index 13df4d1ae981..950646247467 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -79,7 +79,6 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { if (config.site) { finalSiteUrl = new URL(config.base, config.site); } else { - // eslint-disable-next-line no-console console.warn( 'The Sitemap integration requires the `site` astro.config option. Skipping.' ); diff --git a/packages/integrations/sitemap/test/test-utils.js b/packages/integrations/sitemap/test/test-utils.js index 31d40de9ef99..bf101e40503e 100644 --- a/packages/integrations/sitemap/test/test-utils.js +++ b/packages/integrations/sitemap/test/test-utils.js @@ -6,8 +6,7 @@ import * as xml2js from 'xml2js'; */ export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/integrations/solid/src/dependencies.ts b/packages/integrations/solid/src/dependencies.ts index ebe5e2a0a481..6b98aeb3ad4b 100644 --- a/packages/integrations/solid/src/dependencies.ts +++ b/packages/integrations/solid/src/dependencies.ts @@ -18,8 +18,7 @@ export async function getSolidPkgsConfig(isBuild: boolean, astroConfig: AstroCon // License: MIT (https://github.com/solidjs/vite-plugin-solid/blob/5558486b0c63788e1275244256918f80294a8338/package.json#L38) function containsSolidField(fields: Record) { const keys = Object.keys(fields); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; + for (const key of keys) { if (key === 'solid') return true; if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key])) return true; diff --git a/packages/integrations/vercel/src/image/build-service.ts b/packages/integrations/vercel/src/image/build-service.ts index 23cd664a2cbe..973ceb22a7aa 100644 --- a/packages/integrations/vercel/src/image/build-service.ts +++ b/packages/integrations/vercel/src/image/build-service.ts @@ -4,7 +4,7 @@ import { isESMImportedImage, sharedValidateOptions } from './shared'; const service: ExternalImageService = { validateOptions: (options, serviceOptions) => sharedValidateOptions(options, serviceOptions, 'production'), - getHTMLAttributes(options, serviceOptions) { + getHTMLAttributes(options) { const { inputtedWidth, ...props } = options; // If `validateOptions` returned a different width than the one of the image, use it for attributes @@ -39,7 +39,7 @@ const service: ExternalImageService = { decoding: attributes.decoding ?? 'async', }; }, - getURL(options, serviceOptions) { + getURL(options) { const fileSrc = typeof options.src === 'string' ? options.src : removeLeadingForwardSlash(options.src.src); diff --git a/packages/integrations/vercel/src/serverless/request-transform.ts b/packages/integrations/vercel/src/serverless/request-transform.ts index 819b8e8fecf6..31aa377af6cc 100644 --- a/packages/integrations/vercel/src/serverless/request-transform.ts +++ b/packages/integrations/vercel/src/serverless/request-transform.ts @@ -103,7 +103,7 @@ export async function getRequest( ): Promise { let headers = req.headers as Record; let request = new Request(base + req.url, { - // @ts-expect-error + // @ts-expect-error -- duplex does exist in Vercel requests duplex: 'half', method: req.method, headers, diff --git a/packages/integrations/vue/test/test-utils.js b/packages/integrations/vue/test/test-utils.js index 2475944bebb8..512fe28dcba8 100644 --- a/packages/integrations/vue/test/test-utils.js +++ b/packages/integrations/vue/test/test-utils.js @@ -5,8 +5,7 @@ import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.j */ export function loadFixture(inlineConfig) { - if (!inlineConfig || !inlineConfig.root) - throw new Error("Must provide { root: './fixtures/...' }"); + if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath // without this, the main `loadFixture` helper will resolve relative to `packages/astro/test` diff --git a/packages/markdown/component/test/astro-markdown.test.js b/packages/markdown/component/test/astro-markdown.test.js index 21c839b34f87..72546802f235 100644 --- a/packages/markdown/component/test/astro-markdown.test.js +++ b/packages/markdown/component/test/astro-markdown.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as cheerio from 'cheerio'; -import { loadFixture, fixLineEndings } from './test-utils.js'; +import { loadFixture } from './test-utils.js'; describe('Astro Markdown', () => { let fixture; diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 0a21e1c98f19..aa02f8ea90eb 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -147,7 +147,7 @@ export async function renderMarkdown( function prefixError(err: any, prefix: string) { // If the error is an object with a `message` property, attempt to prefix the message - if (err && err.message) { + if (err?.message) { try { err.message = `${prefix}:\n${err.message}`; return err; @@ -160,9 +160,8 @@ function prefixError(err: any, prefix: string) { const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ''}`); try { wrappedError.stack = err.stack; - // @ts-expect-error wrappedError.cause = err; - } catch (error) { + } catch { // It's ok if we could not set the stack or cause - the message is the most important part } diff --git a/packages/markdown/remark/src/rehype-collect-headings.ts b/packages/markdown/remark/src/rehype-collect-headings.ts index 9e3c8005ebf5..8624005450ad 100644 --- a/packages/markdown/remark/src/rehype-collect-headings.ts +++ b/packages/markdown/remark/src/rehype-collect-headings.ts @@ -20,7 +20,7 @@ export function rehypeHeadingIds(): ReturnType { if (node.type !== 'element') return; const { tagName } = node; if (tagName[0] !== 'h') return; - const [_, level] = tagName.match(/h([0-6])/) ?? []; + const [, level] = tagName.match(/h([0-6])/) ?? []; if (!level) return; const depth = Number.parseInt(level); diff --git a/packages/markdown/remark/src/remark-prism.ts b/packages/markdown/remark/src/remark-prism.ts index 80037a3e3737..6147d9ee9cf4 100644 --- a/packages/markdown/remark/src/remark-prism.ts +++ b/packages/markdown/remark/src/remark-prism.ts @@ -1,6 +1,5 @@ import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter'; import { visit } from 'unist-util-visit'; -const noVisit = new Set(['root', 'html', 'text']); type MaybeString = string | null | undefined; diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts index 8035635f9d78..28e362e3419b 100644 --- a/packages/markdown/remark/src/remark-shiki.ts +++ b/packages/markdown/remark/src/remark-shiki.ts @@ -80,7 +80,7 @@ const remarkShiki = async ( lang = 'plaintext'; } - let html = highlighter!.codeToHtml(node.value, { lang }); + let html = highlighter.codeToHtml(node.value, { lang }); // Q: Couldn't these regexes match on a user's inputted code blocks? // A: Nope! All rendered HTML is properly escaped. diff --git a/packages/markdown/remark/tsconfig.json b/packages/markdown/remark/tsconfig.json index dcf815105c91..9a8c6d8cb545 100644 --- a/packages/markdown/remark/tsconfig.json +++ b/packages/markdown/remark/tsconfig.json @@ -3,7 +3,7 @@ "include": ["src"], "compilerOptions": { "allowJs": true, - "target": "ES2021", + "target": "ES2022", "module": "ES2022", "outDir": "./dist" } diff --git a/packages/telemetry/src/project-info.ts b/packages/telemetry/src/project-info.ts index 5f95d1b4b281..f5f755bc13c0 100644 --- a/packages/telemetry/src/project-info.ts +++ b/packages/telemetry/src/project-info.ts @@ -80,7 +80,7 @@ function getProjectIdFromGit(): string | null { } } -function getProjectId(isCI: boolean): Pick { +function getProjectId(isCI: boolean): Pick { const projectIdFromGit = getProjectIdFromGit(); if (projectIdFromGit) { return { diff --git a/packages/telemetry/src/system-info.ts b/packages/telemetry/src/system-info.ts index 77c73594177b..f92a0e276d2b 100644 --- a/packages/telemetry/src/system-info.ts +++ b/packages/telemetry/src/system-info.ts @@ -52,6 +52,7 @@ export function getSystemInfo(versions: { viteVersion: string; astroVersion: str } const cpus = os.cpus() || []; + meta = { // Version information nodeVersion: process.version.replace(/^v?/, ''), @@ -73,5 +74,5 @@ export function getSystemInfo(versions: { viteVersion: string; astroVersion: str ciName, }; - return meta!; + return meta; } diff --git a/packages/underscore-redirects/src/astro.ts b/packages/underscore-redirects/src/astro.ts index fb28b048cc23..1464cb492411 100644 --- a/packages/underscore-redirects/src/astro.ts +++ b/packages/underscore-redirects/src/astro.ts @@ -12,7 +12,7 @@ function getRedirectStatus(route: RouteData): ValidRedirectStatus { } interface CreateRedirectsFromAstroRoutesParams { - config: Pick; + config: Pick; routes: RouteData[]; dir: URL; dynamicTarget?: string; @@ -139,5 +139,5 @@ function generateDynamicPattern(route: RouteData) { } function prependForwardSlash(str: string) { - return str[0] === '/' ? str : '/' + str; + return str.startsWith('/') ? str : '/' + str; } diff --git a/packages/underscore-redirects/src/print.ts b/packages/underscore-redirects/src/print.ts index b407dc7eb644..5d7bd238785a 100644 --- a/packages/underscore-redirects/src/print.ts +++ b/packages/underscore-redirects/src/print.ts @@ -18,11 +18,11 @@ export function print( // Loop over the definitions for (let i = 0; i < definitions.length; i++) { - let definition = definitions[i]; + const definition = definitions[i]; // Figure out the number of spaces to add. We want at least 4 spaces // after the input. This ensure that all targets line up together. - let inputSpaces = minInputLength - definition.input.length + 4; - let targetSpaces = minTargetLength - definition.target.length + 4; + const inputSpaces = minInputLength - definition.input.length + 4; + const targetSpaces = minTargetLength - definition.target.length + 4; _redirects += (i === 0 ? '' : '\n') + definition.input + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 47b44a06677c..f4b2b72fcfb3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,11 +30,11 @@ importers: specifier: ^18.16.18 version: 18.16.18 '@typescript-eslint/eslint-plugin': - specifier: ^5.60.0 - version: 5.60.0(@typescript-eslint/parser@5.60.0)(eslint@8.43.0)(typescript@5.0.2) + specifier: 6.0.0-alpha.158 + version: 6.0.0-alpha.158(@typescript-eslint/parser@6.0.0-alpha.158)(eslint@8.43.0)(typescript@5.0.2) '@typescript-eslint/parser': - specifier: ^5.60.0 - version: 5.60.0(eslint@8.43.0)(typescript@5.0.2) + specifier: 6.0.0-alpha.158 + version: 6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2) esbuild: specifier: ^0.17.19 version: 0.17.19 @@ -8842,47 +8842,48 @@ packages: /@types/yargs-parser@21.0.0: resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} - /@typescript-eslint/eslint-plugin@5.60.0(@typescript-eslint/parser@5.60.0)(eslint@8.43.0)(typescript@5.0.2): - resolution: {integrity: sha512-78B+anHLF1TI8Jn/cD0Q00TBYdMgjdOn980JfAVa9yw5sop8nyTfVOQAv6LWywkOGLclDBtv5z3oxN4w7jxyNg==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/eslint-plugin@6.0.0-alpha.158(@typescript-eslint/parser@6.0.0-alpha.158)(eslint@8.43.0)(typescript@5.0.2): + resolution: {integrity: sha512-fzcdANIIKtQxen+IdXue1u4EHY8h84M8L+eSSYgQQUxJy7tTN4EfBK4jlAAVxGCE+TkmTzBMe52hMAV0PwNLiQ==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: - '@typescript-eslint/parser': ^5.0.0 - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: '@eslint-community/regexpp': 4.5.1 - '@typescript-eslint/parser': 5.60.0(eslint@8.43.0)(typescript@5.0.2) - '@typescript-eslint/scope-manager': 5.60.0 - '@typescript-eslint/type-utils': 5.60.0(eslint@8.43.0)(typescript@5.0.2) - '@typescript-eslint/utils': 5.60.0(eslint@8.43.0)(typescript@5.0.2) + '@typescript-eslint/parser': 6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2) + '@typescript-eslint/scope-manager': 6.0.0-alpha.158 + '@typescript-eslint/type-utils': 6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2) + '@typescript-eslint/utils': 6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2) debug: 4.3.4 eslint: 8.43.0 grapheme-splitter: 1.0.4 ignore: 5.2.4 - natural-compare-lite: 1.4.0 + natural-compare: 1.4.0 semver: 7.5.3 - tsutils: 3.21.0(typescript@5.0.2) + ts-api-utils: 1.0.1(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.60.0(eslint@8.43.0)(typescript@5.0.2): - resolution: {integrity: sha512-jBONcBsDJ9UoTWrARkRRCgDz6wUggmH5RpQVlt7BimSwaTkTjwypGzKORXbR4/2Hqjk9hgwlon2rVQAjWNpkyQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/parser@6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2): + resolution: {integrity: sha512-LJ7qo0yfk4bxYw2A2OCwUeiGumsU4YCebu29dIxC2lK/aT398KazALqMzPC4z6544OS6zYVM2WI9uyCZ8wgj+Q==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + eslint: ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.60.0 - '@typescript-eslint/types': 5.60.0 - '@typescript-eslint/typescript-estree': 5.60.0(typescript@5.0.2) + '@typescript-eslint/scope-manager': 6.0.0-alpha.158 + '@typescript-eslint/types': 6.0.0-alpha.158 + '@typescript-eslint/typescript-estree': 6.0.0-alpha.158(typescript@5.0.2) + '@typescript-eslint/visitor-keys': 6.0.0-alpha.158 debug: 4.3.4 eslint: 8.43.0 typescript: 5.0.2 @@ -8890,72 +8891,72 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager@5.60.0: - resolution: {integrity: sha512-hakuzcxPwXi2ihf9WQu1BbRj1e/Pd8ZZwVTG9kfbxAMZstKz8/9OoexIwnmLzShtsdap5U/CoQGRCWlSuPbYxQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/scope-manager@6.0.0-alpha.158: + resolution: {integrity: sha512-59HcplMM9ZcdtfVe6pgFzereN49OKeVc/FZsymAaxe9QqGXby665pr2/IHcmFh3cnpgNdRQu+DaD5N538AprjA==} + engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 5.60.0 - '@typescript-eslint/visitor-keys': 5.60.0 + '@typescript-eslint/types': 6.0.0-alpha.158 + '@typescript-eslint/visitor-keys': 6.0.0-alpha.158 dev: true - /@typescript-eslint/type-utils@5.60.0(eslint@8.43.0)(typescript@5.0.2): - resolution: {integrity: sha512-X7NsRQddORMYRFH7FWo6sA9Y/zbJ8s1x1RIAtnlj6YprbToTiQnM6vxcMu7iYhdunmoC0rUWlca13D5DVHkK2g==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/type-utils@6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2): + resolution: {integrity: sha512-fjUFPY92+0RzyRKs185Rpoaw4z4vt5qoxd6kHLLHjqKxO7xNsOF4nPPjRXlKfbVAUHecPqbFBRmElWCuaEjMdg==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: - eslint: '*' + eslint: ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.60.0(typescript@5.0.2) - '@typescript-eslint/utils': 5.60.0(eslint@8.43.0)(typescript@5.0.2) + '@typescript-eslint/typescript-estree': 6.0.0-alpha.158(typescript@5.0.2) + '@typescript-eslint/utils': 6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2) debug: 4.3.4 eslint: 8.43.0 - tsutils: 3.21.0(typescript@5.0.2) + ts-api-utils: 1.0.1(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types@5.60.0: - resolution: {integrity: sha512-ascOuoCpNZBccFVNJRSC6rPq4EmJ2NkuoKnd6LDNyAQmdDnziAtxbCGWCbefG1CNzmDvd05zO36AmB7H8RzKPA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/types@6.0.0-alpha.158: + resolution: {integrity: sha512-xfJnAaGKN1b/cz37T4FtQfCBKwA7fn1qxa/5UZmKT1FwI/J+lybk+dHdhU2KvNGJ/53/vGf0OObUzejf7oByLg==} + engines: {node: ^16.0.0 || >=18.0.0} dev: true - /@typescript-eslint/typescript-estree@5.60.0(typescript@5.0.2): - resolution: {integrity: sha512-R43thAuwarC99SnvrBmh26tc7F6sPa2B3evkXp/8q954kYL6Ro56AwASYWtEEi+4j09GbiNAHqYwNNZuNlARGQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/typescript-estree@6.0.0-alpha.158(typescript@5.0.2): + resolution: {integrity: sha512-1hskAlZ2pliy1DQ1VM3Tu+JUQMtaWaLmMGOOmmI9H7yfudsopV7AOCk+NO1FWIATWIeUvPI33T09WKRdZGO4yg==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.60.0 - '@typescript-eslint/visitor-keys': 5.60.0 + '@typescript-eslint/types': 6.0.0-alpha.158 + '@typescript-eslint/visitor-keys': 6.0.0-alpha.158 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.3 - tsutils: 3.21.0(typescript@5.0.2) + ts-api-utils: 1.0.1(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.60.0(eslint@8.43.0)(typescript@5.0.2): - resolution: {integrity: sha512-ba51uMqDtfLQ5+xHtwlO84vkdjrqNzOnqrnwbMHMRY8Tqeme8C2Q8Fc7LajfGR+e3/4LoYiWXUM6BpIIbHJ4hQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/utils@6.0.0-alpha.158(eslint@8.43.0)(typescript@5.0.2): + resolution: {integrity: sha512-HDpGNQnbE09Kun4+IjnaWoARmhAdSbR6MTeaA0K12vzCg9M3rL2z72jzP0z4n7bGRJsNAoH+0SKSgcJ9NL8Bhw==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + eslint: ^7.0.0 || ^8.0.0 dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.43.0) '@types/json-schema': 7.0.11 '@types/semver': 7.5.0 - '@typescript-eslint/scope-manager': 5.60.0 - '@typescript-eslint/types': 5.60.0 - '@typescript-eslint/typescript-estree': 5.60.0(typescript@5.0.2) + '@typescript-eslint/scope-manager': 6.0.0-alpha.158 + '@typescript-eslint/types': 6.0.0-alpha.158 + '@typescript-eslint/typescript-estree': 6.0.0-alpha.158(typescript@5.0.2) eslint: 8.43.0 eslint-scope: 5.1.1 semver: 7.5.3 @@ -8964,11 +8965,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys@5.60.0: - resolution: {integrity: sha512-wm9Uz71SbCyhUKgcaPRauBdTegUyY/ZWl8gLwD/i/ybJqscrrdVSFImpvUz16BLPChIeKBK5Fa9s6KDQjsjyWw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/visitor-keys@6.0.0-alpha.158: + resolution: {integrity: sha512-/1xiY3B2Du3a8YaKpF3MtNZRlzDRChJAb8kbt4mQ6h3XGLd8ZGRN8l971nbX632p78kETaJ+JgCGtrgJpQZO+g==} + engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 5.60.0 + '@typescript-eslint/types': 6.0.0-alpha.158 eslint-visitor-keys: 3.4.1 dev: true @@ -14110,10 +14111,6 @@ packages: /napi-build-utils@1.0.2: resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} - /natural-compare-lite@1.4.0: - resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} - dev: true - /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true @@ -16779,6 +16776,15 @@ packages: /trough@2.1.0: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} + /ts-api-utils@1.0.1(typescript@5.0.2): + resolution: {integrity: sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==} + engines: {node: '>=16.13.0'} + peerDependencies: + typescript: '>=4.2.0' + dependencies: + typescript: 5.0.2 + dev: true + /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -16808,10 +16814,6 @@ packages: strip-json-comments: 2.0.1 dev: true - /tslib@1.14.1: - resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} - dev: true - /tslib@2.1.0: resolution: {integrity: sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==} dev: true @@ -16819,16 +16821,6 @@ packages: /tslib@2.5.3: resolution: {integrity: sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==} - /tsutils@3.21.0(typescript@5.0.2): - resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} - engines: {node: '>= 6'} - peerDependencies: - typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' - dependencies: - tslib: 1.14.1 - typescript: 5.0.2 - dev: true - /tty-table@4.2.1: resolution: {integrity: sha512-xz0uKo+KakCQ+Dxj1D/tKn2FSyreSYWzdkL/BYhgN6oMW808g8QRMuh1atAV9fjTPbWBjfbkKQpI/5rEcnAc7g==} engines: {node: '>=8.0.0'} @@ -18139,25 +18131,21 @@ packages: file:packages/astro/test/fixtures/css-assets/packages/font-awesome: resolution: {directory: packages/astro/test/fixtures/css-assets/packages/font-awesome, type: directory} name: '@test/astro-font-awesome-package' - version: 0.0.1 dev: false file:packages/astro/test/fixtures/multiple-renderers/renderers/one: resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/one, type: directory} name: '@test/astro-renderer-one' - version: 1.0.0 dev: false file:packages/astro/test/fixtures/multiple-renderers/renderers/two: resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/two, type: directory} name: '@test/astro-renderer-two' - version: 1.0.0 dev: false file:packages/astro/test/fixtures/solid-component/deps/solid-jsx-component: resolution: {directory: packages/astro/test/fixtures/solid-component/deps/solid-jsx-component, type: directory} name: '@test/solid-jsx-component' - version: 0.0.0 dependencies: solid-js: 1.7.6 dev: false diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 000000000000..678a223c90a8 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "allowJs": true + }, + "extends": "./tsconfig.base.json" +}