Upgrade to ESLint 9

This commit is contained in:
Alex
2024-10-16 00:29:26 -04:00
parent 0138cabb27
commit 00d0dfa107
53 changed files with 3813 additions and 2207 deletions

View File

@ -1,31 +1,10 @@
import type { ESLintConfig, KnownExtends, Settings } from '@aet/eslint-define-config';
import type { Merge, SetRequired } from 'type-fest';
import type { Linter } from 'eslint';
import type { RuleOptions } from './index';
type MiddlewareResult = Linter.Config | Linter.Config[];
type OptionalObjectKey<T> = Exclude<
{
[Key in keyof T]: undefined | any[] extends T[Key]
? Key
: undefined | Record<any, any> extends T[Key]
? Key
: never;
}[keyof T],
undefined
>;
export type Middleware =
| (() => Promise<MiddlewareResult>)
| (() => Promise<{ default: MiddlewareResult }>);
export type MiddlewareConfig = Merge<
SetRequired<ESLintConfig, OptionalObjectKey<ESLintConfig>>,
{ extends: KnownExtends[] }
>;
export interface MiddlewareFunctions {
addRules(rules: Partial<RuleOptions>): void;
addSettings(settings: Partial<Settings>): void;
}
export type Middleware = (config: MiddlewareConfig, helpers: MiddlewareFunctions) => void;
export function defineMiddleware(middleware: Middleware): Middleware {
return middleware;
}
// eslint-disable-next-line unicorn/prevent-abbreviations
export const def = <T>(module: { default: T }): T => module.default;