mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-27 05:25:14 +00:00
chore: update eslint, enable more rules and fix their findings (#39438)
Update eslint and its plugins, enable more rules and fix their findings: 1. `unicorn/no-unsafe-string-replacement` found that uploading a file whose name contains `$&` inserted a broken markdown link, because `String#replace` expands such patterns in the replacement string 2. `@typescript-eslint/require-await` removes `async` from functions that never await 3. Plugin rules not covered by a preset are now listed explicitly --------- Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type {Promisable} from '../types.ts';
|
||||
|
||||
// there are 2 kinds of plugins:
|
||||
// * "inplace" plugins: render file content in-place, e.g. PDF viewer
|
||||
// * "frontend" plugins: render file content in a separate iframe by a huge frontend library (need to protect from XSS risks)
|
||||
@@ -18,4 +20,4 @@ export type FrontendRenderOptions = {
|
||||
contentBytes(): Uint8Array<ArrayBuffer>;
|
||||
};
|
||||
|
||||
export type FrontendRenderFunc = (opts: FrontendRenderOptions) => Promise<boolean>;
|
||||
export type FrontendRenderFunc = (opts: FrontendRenderOptions) => Promisable<boolean>;
|
||||
|
||||
@@ -4,9 +4,9 @@ import {initSwaggerUI} from '../swagger.ts';
|
||||
// HINT: SWAGGER-CSS-IMPORT: these styles are for the render only.
|
||||
import '../../../css/swagger-render.css';
|
||||
|
||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||
export const frontendRender: FrontendRenderFunc = (opts) => {
|
||||
try {
|
||||
await initSwaggerUI(opts.container, {specText: opts.contentString()});
|
||||
initSwaggerUI(opts.container, {specText: opts.contentString()});
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -15,7 +15,7 @@ solid SimpleTriangle
|
||||
endsolid SimpleTriangle
|
||||
*/
|
||||
|
||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||
export const frontendRender: FrontendRenderFunc = (opts) => {
|
||||
try {
|
||||
opts.container.style.height = `${window.innerHeight}px`;
|
||||
const bgColor = colord(getComputedStyle(document.body).backgroundColor).toRgb();
|
||||
|
||||
@@ -15,7 +15,7 @@ function syncDarkModeClass(): void {
|
||||
document.documentElement.classList.toggle('dark-mode', isDark);
|
||||
}
|
||||
|
||||
export async function initSwaggerUI(container: HTMLElement, opts: {specText: string}): Promise<void> {
|
||||
export function initSwaggerUI(container: HTMLElement, opts: {specText: string}): void {
|
||||
// swagger-ui has built-in dark mode triggered by html.dark-mode class
|
||||
syncDarkModeClass();
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', syncDarkModeClass);
|
||||
|
||||
Reference in New Issue
Block a user