Skip to content

Commit 546a85c

Browse files
committed
chore: upgrade to ESLint v9
1 parent cf6c66a commit 546a85c

File tree

59 files changed

+762
-671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+762
-671
lines changed

.eslintrc.json

Lines changed: 0 additions & 166 deletions
This file was deleted.

.releaserc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ const homepageUrlWithoutTrailingSlash = homepageUrl.endsWith("/")
2626
? homepageUrl.slice(0, -1)
2727
: homepageUrl;
2828

29+
/* eslint-disable @stylistic/max-len */
2930
const newFooterTemplate = defaultFooterTemplate + "\n---\n\n" +
3031
`Shipped with \`llama.cpp\` release [\`${binariesSourceRelease.split("`").join("")}\`](https://github.com/${defaultLlamaCppGitHubRepo}/releases/tag/${encodeURIComponent(binariesSourceRelease)})\n\n` +
3132
`> To use the latest \`llama.cpp\` release available, run \`npx -n ${cliBinName} source download --release latest\`. ([learn more](${homepageUrlWithoutTrailingSlash}/guide/building-from-source#download-new-release))\n`;
33+
/* eslint-enable @stylistic/max-len */
3234

3335
const githubPluginConfig = {
3436
discussionCategoryName: "Releases" as string | boolean

.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function getElectronExampleAppDownloadLink() {
3535

3636
const isMacOs = platformInfo?.platform != null
3737
? platformInfo.platform === "macOS"
38-
: (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh"))
38+
: (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh"));
3939
const isWindows = platformInfo?.platform != null
4040
? platformInfo.platform === "Windows"
4141
: navigator.userAgent.includes("Windows");
@@ -73,17 +73,17 @@ export async function getElectronExampleAppDownloadLink() {
7373
relevantAssets = assets
7474
.filter((asset) => asset.name.includes(".macOS."))
7575
.filter(filterByArchitecture)
76-
.filter((asset) => asset.name.endsWith(".dmg"))
76+
.filter((asset) => asset.name.endsWith(".dmg"));
7777
} else if (isWindows) {
7878
relevantAssets = assets
7979
.filter((asset) => asset.name.includes(".Windows."))
8080
.filter(filterByArchitecture)
81-
.filter((asset) => asset.name.endsWith(".exe"))
81+
.filter((asset) => asset.name.endsWith(".exe"));
8282
} else if (isLinux) {
8383
relevantAssets = assets
8484
.filter((asset) => asset.name.includes(".Linux."))
8585
.filter(filterByArchitecture)
86-
.filter((asset) => asset.name.endsWith(".AppImage"))
86+
.filter((asset) => asset.name.endsWith(".AppImage"));
8787
}
8888

8989
if (relevantAssets.length > 0 && relevantAssets[0]!.browser_download_url != null)

.vitepress/config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import {createContentLoader, defineConfig, HeadConfig} from "vitepress";
21
import path from "path";
32
import {createRequire} from "node:module";
43
import process from "process";
5-
import fs from "fs-extra";
64
import {fileURLToPath} from "url";
5+
import fs from "fs-extra";
6+
import {createContentLoader, defineConfig, HeadConfig} from "vitepress";
77
import {transformerTwoslash} from "@shikijs/vitepress-twoslash";
88
import ts from "typescript";
99
import envVar from "env-var";
1010
import {Feed} from "feed";
1111
import {rehype} from "rehype";
12-
import {Element as HastElement, Parent} from "hast";
1312
import sharp from "sharp";
1413
import {GitChangelog, GitChangelogMarkdownSection} from "@nolebase/vitepress-plugin-git-changelog/vite";
1514
import {buildEndGenerateOpenGraphImages} from "@nolebase/vitepress-plugin-og-image/vitepress";
16-
import {Resvg, initWasm as initResvgWasm, ResvgRenderOptions} from "@resvg/resvg-wasm";
15+
import {Resvg, initWasm as initResvgWasm, type ResvgRenderOptions} from "@resvg/resvg-wasm";
1716
import {BlogPageInfoPlugin} from "./config/BlogPageInfoPlugin.js";
1817
import {getApiReferenceSidebar} from "./config/apiReferenceSidebar.js";
1918
import {ensureLocalImage} from "./utils/ensureLocalImage.js";
19+
import type {Element as HastElement, Parent} from "hast";
2020

2121
import type {Node as UnistNode} from "unist";
2222
import type {ShikiTransformer} from "shiki";
@@ -34,7 +34,7 @@ const packageVersion = env.get("DOCS_PACKAGE_VERSION")
3434
.default(packageJson.version)
3535
.asString();
3636

37-
const hostname = "https://node-llama-cpp.withcat.ai/"
37+
const hostname = "https://node-llama-cpp.withcat.ai/";
3838
const buildDate = new Date();
3939

4040
const socialPosterLink = hostname + "social.poster.jpg";
@@ -178,7 +178,7 @@ export default defineConfig({
178178
"window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());" +
179179
"gtag('config','G-Q2SWE5Z1ST');"
180180
],
181-
["style", {}],
181+
["style", {}]
182182
],
183183
async transformHead({pageData, head}) {
184184
if (pageData.filePath === "index.md") {
@@ -263,7 +263,7 @@ export default defineConfig({
263263
pageData.frontmatter.editLink = false;
264264
pageData.frontmatter.lastUpdated = false;
265265
pageData.frontmatter.aside = false;
266-
pageData.frontmatter.outline = false
266+
pageData.frontmatter.outline = false;
267267
pageData.frontmatter.nolebase = {
268268
gitChangelog: false
269269
};
@@ -507,7 +507,7 @@ export default defineConfig({
507507
"inter-latin-ext-400-normal.woff2",
508508
"inter-latin-ext-500-normal.woff2",
509509
"inter-latin-ext-600-normal.woff2",
510-
"inter-latin-ext-700-normal.woff2",
510+
"inter-latin-ext-700-normal.woff2"
511511
];
512512

513513
return await Promise.all(
@@ -532,7 +532,7 @@ export default defineConfig({
532532
const innerSvgImages = loadInnerSvgImages();
533533

534534
async function renderSvg(svgPath: string, destPngPath: string, options: ResvgRenderOptions) {
535-
console.info(`Rendering "${svgPath}" to "${destPngPath}"`)
535+
console.info(`Rendering "${svgPath}" to "${destPngPath}"`);
536536

537537
const svgContent = await fs.readFile(svgPath, "utf8");
538538
const svgImages = await innerSvgImages;
@@ -665,7 +665,7 @@ export default defineConfig({
665665
author: {
666666
name: typeof packageJson.author === "string"
667667
? packageJson.author
668-
: (packageJson.author as undefined | { name?: string })?.name
668+
: (packageJson.author as undefined | {name?: string})?.name
669669
},
670670
hub: "https://pubsubhubbub.appspot.com/"
671671
});

.vitepress/config/BlogPageInfoPlugin.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import {MarkdownEnv, Plugin} from "vitepress";
21
import path from "path";
3-
import {htmlEscape} from "../utils/htmlEscape.js";
2+
import {MarkdownEnv, Plugin} from "vitepress";
43
import {getMarkdownRenderer} from "../utils/getMarkdownRenderer.js";
54
import {renderHtmlTag} from "../utils/renderHtmlTag.js";
65
import {ensureLocalImage, resolveImageBuffers, relativeToAbsoluteImageUrls} from "../utils/ensureLocalImage.js";
76

87
export function BlogPageInfoPlugin({
98
include
109
}: {
11-
include(id: string): boolean,
10+
include(id: string): boolean
1211
}): Plugin {
1312
const refIdToUrlPath = new Map<string, string>();
1413
let root = "";
@@ -84,12 +83,13 @@ export function BlogPageInfoPlugin({
8483
const frontmatterCode = code.slice(0, frontmatterEndIndex);
8584
const markdownCode = code.slice(frontmatterEndIndex);
8685

86+
const frontmatterDate = new Date(frontmatter.date);
8787
let newCode = frontmatterCode + (
8888
"# " + frontmatter.title + "\n\n" +
8989
[
9090
"",
9191
'<script setup lang="ts">',
92-
`const articleDate = new Date(${JSON.stringify(new Date(frontmatter.date).toISOString())}).toLocaleDateString("en-US", {`,
92+
`const articleDate = new Date(${JSON.stringify(frontmatterDate.toISOString())}).toLocaleDateString("en-US", {`,
9393
' year: "numeric",',
9494
' month: "long",',
9595
' day: "numeric"',
@@ -118,10 +118,9 @@ export function BlogPageInfoPlugin({
118118
alt: frontmatter.title,
119119
width: width,
120120
height: height,
121-
style: 'background-image: url(' + JSON.stringify(previewUrlPath.absolute) + ');'
121+
style: "background-image: url(" + JSON.stringify(previewUrlPath.absolute) + ");"
122122
});
123-
}
124-
else if (typeof (frontmatter.image as any).url === "string") {
123+
} else if (typeof (frontmatter.image as any).url === "string") {
125124
const {
126125
urlPath, previewUrlPath, width, height
127126
} = await ensureLocalImage((frontmatter.image as any).url, "cover", {
@@ -133,7 +132,7 @@ export function BlogPageInfoPlugin({
133132
alt: (frontmatter.image as any).alt ?? frontmatter.title,
134133
width: width ?? (frontmatter.image as any).width,
135134
height: height ?? (frontmatter.image as any).height,
136-
style: 'background-image: url(' + JSON.stringify(previewUrlPath.absolute) + ');'
135+
style: "background-image: url(" + JSON.stringify(previewUrlPath.absolute) + ");"
137136
});
138137
}
139138
}
@@ -143,7 +142,7 @@ export function BlogPageInfoPlugin({
143142

144143
return newCode;
145144
}
146-
}
145+
};
147146
}
148147

149148
function findFrontmatterEndIndex(mdCode: string): number {

.vitepress/config/apiReferenceSidebar.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import typedocSidebar from "../../docs/api/typedoc-sidebar.json";
2-
import {DefaultTheme} from "vitepress"; // if this import fails, run `npm run docs:generateTypedoc`
1+
import {DefaultTheme} from "vitepress";
2+
import typedocSidebar from "../../docs/api/typedoc-sidebar.json"; // if this import fails, run `npm run docs:generateTypedoc`
33

44
const categoryOrder = [
55
"Functions",
@@ -85,7 +85,7 @@ function getSidebar() {
8585

8686
if (item.items instanceof Array)
8787
item.items = item.items.map((subItem) => {
88-
if ((subItem as { collapsed?: boolean }).collapsed)
88+
if ((subItem as {collapsed?: boolean}).collapsed)
8989
// @ts-ignore
9090
delete subItem.collapsed;
9191

@@ -129,7 +129,7 @@ function applyOverrides(sidebar: typeof typedocSidebar) {
129129

130130
const llamaTextFunction = functions?.items?.find((item) => item.text === "LlamaText");
131131
if (llamaTextFunction != null) {
132-
delete (llamaTextFunction as { link?: string }).link;
132+
delete (llamaTextFunction as {link?: string}).link;
133133
}
134134

135135
const classes = sidebar.find((item) => item.text === "Classes");
@@ -372,7 +372,7 @@ function groupItems(
372372
items: DefaultTheme.SidebarItem[] | undefined,
373373
findParent: (item: DefaultTheme.SidebarItem) => boolean | undefined,
374374
findChildren: (item: DefaultTheme.SidebarItem) => boolean | undefined,
375-
{collapsed = true, moveToEndIfGrouped = true}: { collapsed?: boolean, moveToEndIfGrouped?: boolean } = {}
375+
{collapsed = true, moveToEndIfGrouped = true}: {collapsed?: boolean, moveToEndIfGrouped?: boolean} = {}
376376
) {
377377
const children: DefaultTheme.SidebarItem[] = [];
378378

@@ -412,7 +412,7 @@ function ensureParentAndGroupItems(
412412
items: DefaultTheme.SidebarItem[] | undefined,
413413
parentText: string,
414414
findChildren: (item: DefaultTheme.SidebarItem) => boolean | undefined,
415-
{collapsed = true, moveToEndIfGrouped = true}: { collapsed?: boolean, moveToEndIfGrouped?: boolean } = {}
415+
{collapsed = true, moveToEndIfGrouped = true}: {collapsed?: boolean, moveToEndIfGrouped?: boolean} = {}
416416
) {
417417
if (items == null || !(items instanceof Array))
418418
return;

0 commit comments

Comments
 (0)