mirror of
https://github.com/go-gitea/gitea
synced 2025-09-15 21:28:15 +00:00
Update eslint to v9 (#35485)
Update eslint and all plugins. Many plugins still do not ship type definitions so I had to add stubs. Also, I had to put a few typescript error expectations because if some unknown error in the types. `eslint-plugin-no-jquery` is disabled because it's not compatible with eslint 9 flat config (https://github.com/wikimedia/eslint-plugin-no-jquery/issues/311).
This commit is contained in:
@@ -7,7 +7,7 @@ type ArrayLikeIterable<T> = ArrayLike<T> & Iterable<T>; // for NodeListOf and Ar
|
||||
type ElementArg = Element | string | ArrayLikeIterable<Element> | ReturnType<typeof $>;
|
||||
type ElementsCallback<T extends Element> = (el: T) => Promisable<any>;
|
||||
type ElementsCallbackWithArgs = (el: Element, ...args: any[]) => Promisable<any>;
|
||||
export type DOMEvent<E extends Event, T extends Element = HTMLElement> = E & { target: Partial<T>; };
|
||||
export type DOMEvent<E extends Event, T extends Element = HTMLElement> = E & {target: Partial<T>;};
|
||||
|
||||
function elementsCall(el: ElementArg, func: ElementsCallbackWithArgs, ...args: any[]): ArrayLikeIterable<Element> {
|
||||
if (typeof el === 'string' || el instanceof String) {
|
||||
@@ -322,7 +322,7 @@ export function createElementFromHTML<T extends HTMLElement>(htmlString: string)
|
||||
return div.firstChild as T;
|
||||
}
|
||||
|
||||
export function createElementFromAttrs(tagName: string, attrs: Record<string, any>, ...children: (Node|string)[]): HTMLElement {
|
||||
export function createElementFromAttrs(tagName: string, attrs: Record<string, any>, ...children: (Node | string)[]): HTMLElement {
|
||||
const el = document.createElement(tagName);
|
||||
for (const [key, value] of Object.entries(attrs || {})) {
|
||||
if (value === undefined || value === null) continue;
|
||||
|
@@ -117,7 +117,7 @@ test('GlobCompiler', async () => {
|
||||
for (const c of golangCases) {
|
||||
const compiled = globCompile(c.pattern, c.separators);
|
||||
const msg = `pattern: ${c.pattern}, input: ${c.input}, separators: ${c.separators || '(none)'}, compiled: ${compiled.regexpPattern}`;
|
||||
// eslint-disable-next-line @vitest/valid-expect -- Unlike Jest, Vitest supports a message as the second argument
|
||||
// eslint-disable-next-line vitest/valid-expect -- Unlike Jest, Vitest supports a message as the second argument
|
||||
expect(compiled.regexp.test(c.input), msg).toBe(c.matched);
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ export function html(tmpl: TemplateStringsArray, ...parts: Array<any>): string {
|
||||
return output;
|
||||
}
|
||||
|
||||
export function htmlRaw(s: string|TemplateStringsArray, ...tmplParts: Array<any>): rawObject {
|
||||
export function htmlRaw(s: string | TemplateStringsArray, ...tmplParts: Array<any>): rawObject {
|
||||
if (typeof s === 'string') {
|
||||
if (tmplParts.length !== 0) throw new Error("either htmlRaw('str') or htmlRaw`tmpl`");
|
||||
return new rawObject(s);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
type PngChunk = {
|
||||
name: string,
|
||||
data: Uint8Array,
|
||||
}
|
||||
};
|
||||
|
||||
export async function pngChunks(blob: Blob): Promise<PngChunk[]> {
|
||||
const uint8arr = new Uint8Array(await blob.arrayBuffer());
|
||||
@@ -27,7 +27,7 @@ export async function pngChunks(blob: Blob): Promise<PngChunk[]> {
|
||||
type ImageInfo = {
|
||||
width?: number,
|
||||
dppx?: number,
|
||||
}
|
||||
};
|
||||
|
||||
/** decode a image and try to obtain width and dppx. It will never throw but instead
|
||||
* return default values. */
|
||||
|
@@ -47,11 +47,11 @@ export type DayData = {
|
||||
additions: number,
|
||||
deletions: number,
|
||||
commits: number,
|
||||
}
|
||||
};
|
||||
|
||||
export type DayDataObject = {
|
||||
[timestamp: string]: DayData,
|
||||
}
|
||||
};
|
||||
|
||||
export function fillEmptyStartDaysWithZeroes(startDays: number[], data: DayDataObject): DayData[] {
|
||||
const result: Record<string, any> = {};
|
||||
|
Reference in New Issue
Block a user