chore: ESLint Flat Config (#834)

* chore: eslint flat config

* chore: format

* update according to review

* chore: remove prettier config and format

* fix: move handler to script to bypass eslint

* chore: config eslint for lang=js block

* docs: add surrounding empty lines for code block

* chore: also minify css in csp build

* chore: publint
This commit is contained in:
Yue JIN
2025-05-26 11:11:23 +08:00
committed by Justineo
parent 077bd3ec40
commit 522dd7cc5c
50 changed files with 1020 additions and 1061 deletions

View File

@ -1,5 +1,5 @@
import { readFileSync, writeFileSync } from "node:fs";
import commentMark from "comment-mark";
import { commentMark } from "comment-mark";
import { getPackageMeta, resolvePath } from "./utils.mjs";
const { name, version } = getPackageMeta();
@ -9,13 +9,13 @@ const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
const DEP_VERSIONS = {
vue: "3.5.13",
echarts: "5.5.1",
[name]: version
[name]: version,
};
function getScripts() {
const deps = ["vue", "echarts", name];
return deps
.map(dep => {
.map((dep) => {
const [, name] = dep.match(/^(.+?)(?:@.+)?$/) || [];
return `<script src="${CDN_PREFIX}${name}@${DEP_VERSIONS[dep]}"></script>`;
})
@ -23,22 +23,22 @@ function getScripts() {
}
function getCodeBlock(code) {
return "```html\n" + code + "\n```";
return "\n```html\n" + code + "\n```\n";
}
const README_FILES = ["README.md", "README.zh-Hans.md"].map(name =>
resolvePath(import.meta.url, "..", name)
const README_FILES = ["README.md", "README.zh-Hans.md"].map((name) =>
resolvePath(import.meta.url, "..", name),
);
README_FILES.forEach(file => {
README_FILES.forEach((file) => {
const content = readFileSync(file, "utf8");
writeFileSync(
file,
commentMark(content, {
vue3Scripts: getCodeBlock(getScripts())
vue3Scripts: getCodeBlock(getScripts()),
}),
"utf8"
"utf8",
);
});