Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump typescript-eslint to v8 #11649

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ export default [
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prettier-plugin-astro": "^0.14.1",
"turbo": "^1.13.4",
"typescript": "~5.5.4",
"typescript-eslint": "^7.18.0"
"typescript-eslint": "^8.0.1"
},
"pnpm": {
"packageExtensions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-rss/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function isValidURL(url: string): boolean {
try {
new URL(url);
return true;
} catch (e) {}
} catch {}
return false;
}

Expand Down
1 change: 0 additions & 1 deletion packages/astro/astro-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ declare namespace astroHTML.JSX {
export type Children = Child | Child[];

interface ElementChildrenAttribute {
// eslint-disable-next-line @typescript-eslint/ban-types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what a dream it is to be able to remove these, thank you eslint team 🙏

children: {};
}

Expand Down
1 change: 1 addition & 0 deletions packages/astro/astro.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function errorNodeUnsupported() {
Node.js v${process.versions.node} is not supported by Astro!
Please upgrade Node.js to a supported version: "${engines}"\n`);

// eslint-disable-next-line @typescript-eslint/no-require-imports
const ci = typeof require !== 'undefined' ? require('ci-info') : await import('ci-info');

// Special instructions for CI environments, which may have special steps needed.
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export type TransitionAnimationValue =
| TransitionDirectionalAnimations;

// Allow users to extend this for astro-jsx.d.ts
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface AstroClientDirectives {}

export interface AstroBuiltinAttributes {
Expand Down Expand Up @@ -459,7 +459,6 @@ export interface ViteUserConfig extends vite.UserConfig {
}

export interface ImageServiceConfig<T extends Record<string, any> = Record<string, any>> {
// eslint-disable-next-line @typescript-eslint/ban-types
entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
config?: T;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function generateImagesForPath(
);
await fs.promises.unlink(getFullImagePath(originalFilePath, env));
}
} catch (e) {
} catch {
/* No-op, it's okay if we fail to delete one of the file, we're not too picky. */
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/endpoint/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function loadRemoteImage(src: URL, headers: Headers) {
}

return await res.arrayBuffer();
} catch (err: unknown) {
} catch {
return undefined;
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/assets/endpoint/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function loadLocalImage(src: string, url: URL) {
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
return undefined;
}
} catch (err: unknown) {
} catch{
return undefined;
}
}
Expand All @@ -39,7 +39,7 @@ async function loadLocalImage(src: string, url: URL) {

try {
buffer = await readFile(fileUrl);
} catch (e) {
} catch {
// Fallback to try to load the file using `fetch`
try {
const sourceUrl = new URL(src, url.origin);
Expand All @@ -62,7 +62,7 @@ async function loadRemoteImage(src: URL) {
}

return Buffer.from(await res.arrayBuffer());
} catch (err: unknown) {
} catch {
return undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/services/sharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function loadSharp() {
let sharpImport: typeof import('sharp');
try {
sharpImport = (await import('sharp')).default;
} catch (e) {
} catch {
throw new AstroError(AstroErrorData.MissingSharp);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint-disable ban-types */
import { parentPort, Worker } from 'worker_threads';

function uuid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ var Module = (function () {
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16)
updateGlobalBufferAndViews(wasmMemory.buffer)
return 1
} catch (e) {}
} catch {}
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/assets/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { WithRequired } from '../type-utils.js';
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
import type { ImageService } from './services/service.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function imageMetadata(
format: type as ImageInputFormat,
orientation,
};
} catch (e) {
} catch {
throw new AstroError({
...AstroErrorData.NoImageMetadata,
message: AstroErrorData.NoImageMetadata.message(src),
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/node/emitAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function emitESMImage(
let fileData: Buffer;
try {
fileData = await fs.readFile(url);
} catch (err) {
} catch {
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/remoteProbe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function inferRemoteSize(url: string): Promise<Omit<ImageMetadata,

return dimensions;
}
} catch (error) {
} catch {
// This catch block is specifically for `imageMetadata` errors
// which might occur if the accumulated data isn't yet sufficient.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function lookup(input: Uint8Array): ISizeCalculationResult {
const type = detector(input)

if (typeof type !== 'undefined') {
if (globalOptions.disabledTypes.indexOf(type) > -1) {
if (globalOptions.disabledTypes.includes(type)) {
throw new TypeError('disabled file type: ' + type)
}

Expand Down
10 changes: 5 additions & 5 deletions packages/astro/src/assets/utils/vendor/image-size/types/svg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/non-nullable-type-assertion-style */
/* eslint-disable regexp/prefer-regexp-exec */
import type { IImage, ISize } from './interface.ts'
import { toUTF8String } from './utils.js'

Expand Down Expand Up @@ -52,9 +52,9 @@ function parseViewbox(viewbox: string): IAttributes {
}

function parseAttributes(root: string): IAttributes {
const width = root.match(extractorRegExps.width)
const height = root.match(extractorRegExps.height)
const viewbox = root.match(extractorRegExps.viewbox)
const width = extractorRegExps.width.exec(root)
const height = extractorRegExps.height.exec(root)
const viewbox = extractorRegExps.viewbox.exec(root)
return {
height: height && (parseLength(height[2]) as number),
viewbox: viewbox && (parseViewbox(viewbox[2]) as IAttributes),
Expand Down Expand Up @@ -94,7 +94,7 @@ export const SVG: IImage = {
validate: (input) => svgReg.test(toUTF8String(input, 0, 1000)),

calculate(input) {
const root = toUTF8String(input).match(extractorRegExps.root)
const root = extractorRegExps.root.exec(toUTF8String(input))
if (root) {
const attrs = parseAttributes(root[0])
if (attrs.width && attrs.height) {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/cli/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function copyToClipboard(text: string) {
return;
}
command = 'xclip -sel clipboard -l 1';
} catch (e) {
} catch {
// Did not find xclip, bail out!
return;
}
Expand All @@ -91,7 +91,7 @@ async function copyToClipboard(text: string) {
input: text.trim(),
encoding: 'utf8',
});
} catch (e) {
} catch {
console.error(
colors.red(`\nSorry, something went wrong!`) + ` Please copy the text above manually.`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/cli/install-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getPackage<T>(
require.resolve(packageName, { paths: [options.cwd ?? process.cwd()] });
const packageImport = await import(packageName);
return packageImport as T;
} catch (e) {
} catch {
if (options.optional) return undefined;
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
packageName
Expand Down Expand Up @@ -207,7 +207,7 @@ async function getRegistry(): Promise<string> {
_registry = stdout?.trim()?.replace(/\/$/, '') || fallback;
// Detect cases where the shell command returned a non-URL (e.g. a warning)
if (!new URL(_registry).host) _registry = fallback;
} catch (e) {
} catch {
_registry = fallback;
}
return _registry;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/base-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ export abstract class Pipeline {
abstract getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface HeadElements extends Pick<SSRResult, 'scripts' | 'styles' | 'links'> {}
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { BuildOptions, Rollup, Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from '../internal.js';
import type { PageBuildData } from '../types.js';

// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
type OutputOptionsHook = Extract<VitePlugin['outputOptions'], Function>;
type OutputOptions = Parameters<OutputOptionsHook>[0];

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } f
// Also, make sure to not index the complexified type, as it would return a simplified value type, which goes
// back to the issue again. The complexified type should be the base representation that we want to expose.

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ComplexifyUnionObj {}

type ComplexifyWithUnion<T> = T & ComplexifyUnionObj;
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/config/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export const presets = new Map<frameworkWithTSSettings, TSConfig>([
],
]);

// eslint-disable-next-line @typescript-eslint/ban-types
type TSConfigResult<T = {}> = Promise<
type TSConfigResult<T = object> = Promise<
(TSConfckParseResult & T) | 'invalid-config' | 'missing-config' | 'unknown-error'
>;

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS
}
})
.catch(() => {});
} catch (e) {
} catch {
// Just ignore the error, we don't want to block the dev server from starting and this is just a nice-to-have feature
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/errors/dev/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function enhanceViteSSRError({
if (
fileId &&
!renderers?.find((r) => r.name === '@astrojs/mdx') &&
/Syntax error/.test(safeError.message) &&
safeError.message.includes('Syntax error') &&
/.mdx$/.test(fileId)
) {
safeError = new AstroError({
Expand All @@ -78,7 +78,7 @@ export function enhanceViteSSRError({
}

// Since Astro.glob is a wrapper around Vite's import.meta.glob, errors don't show accurate information, let's fix that
if (/Invalid glob/.test(safeError.message)) {
if (safeError.message.includes('Invalid glob')) {
const globPattern = /glob: "(.+)" \(/.exec(safeError.message)?.[1];

if (globPattern) {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function getParts(part: string, file: string) {
export function validateSegment(segment: string, file = '') {
if (!file) file = segment;

if (/\]\[/.test(segment)) {
if (segment.includes('][')) {
throw new Error(`Invalid route ${file} \u2014 parameters must be separated`);
}
if (countOccurrences('[', segment) !== countOccurrences(']', segment)) {
Expand Down Expand Up @@ -293,7 +293,7 @@ function createInjectedRoutes({ settings, cwd }: CreateRouteManifestParams): Pri
let resolved: string;
try {
resolved = require.resolve(entrypoint, { paths: [cwd || fileURLToPath(config.root)] });
} catch (e) {
} catch {
resolved = fileURLToPath(new URL(entrypoint, config.root));
}
const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved));
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/env/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export const EnvSchema = z.record(EnvSchemaKey, z.intersection(EnvFieldMetadata,
// https://www.totaltypescript.com/concepts/the-prettify-helper
type Prettify<T> = {
[K in keyof T]: T[K];
// eslint-disable-next-line @typescript-eslint/ban-types
} & {};

export type EnvSchema = z.infer<typeof EnvSchema>;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/events/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function eventError({
/**
* Safely get the error message from an error, even if it's a function.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
function getSafeErrorMessage(message: string | Function): string {
if (typeof message === 'string') {
return message;
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/events/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ interface AppToggledEventPayload {
}

export function eventAppToggled(options: {
// eslint-disable-next-line @typescript-eslint/ban-types
appName: 'other' | (string & {});
}): { eventName: string; payload: AppToggledEventPayload }[] {
const payload: AppToggledEventPayload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type Audit = {
try {
customElements.define('astro-dev-toolbar-audit-window', DevToolbarAuditListWindow);
customElements.define('astro-dev-toolbar-audit-list-item', DevToolbarAuditListItem);
} catch (e) {}
} catch {}

let showState = false;

Expand Down
Loading
Loading