From d06687867acab28a8d66dc6d3979008b3f84647b Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 1 Dec 2023 16:41:12 +0800 Subject: [PATCH] init eslint --- .eslintignore | 4 ++++ .eslintrc.yaml | 5 +++++ docs/.vitepress/config.ts | 22 +++++++++++----------- docs/.vitepress/env.d.ts | 2 +- docs/.vitepress/nav.ts | 26 +++++++++++++------------- docs/.vitepress/theme/index.ts | 15 +++++++-------- package.json | 6 +++++- 7 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.yaml diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..07bb826 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +!.vitepress +node_modules +dist +cache diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 0000000..1de8c5f --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,5 @@ +extends: +- '@hydrooj/eslint-config' +rules: + '@typescript-eslint/semi': [error, never] + '@typescript-eslint/indent': [error, 2] diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 927b5bf..4db1864 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,19 +1,19 @@ +import footnote from 'markdown-it-footnote' +import katex from 'markdown-it-katex' +import mdPangu from 'markdown-it-pangu' import { defineConfig } from 'vitepress' -import nav from './nav' -import mdPangu from "markdown-it-pangu"; -import katex from 'markdown-it-katex'; -import footnote from 'markdown-it-footnote'; import { getSidebar } from 'vitepress-plugin-auto-sidebar' +import nav from './nav' // https://vitepress.dev/reference/site-config export default defineConfig({ - title: "RLE.wiki", - description: "一份RLE指北", + title: 'RLE.wiki', + description: '一份RLE指北', markdown: { config(md) { - md.use(mdPangu); - md.use(footnote); - md.use(katex); + md.use(mdPangu) + md.use(footnote) + md.use(katex) }, }, dir: 'docs', @@ -30,7 +30,7 @@ export default defineConfig({ }), socialLinks: [ - { icon: 'github', link: 'https://github.com/project-trans/RLE-wiki' } + { icon: 'github', link: 'https://github.com/project-trans/RLE-wiki' }, ], editLink: { @@ -48,5 +48,5 @@ export default defineConfig({ prev: '上一页', next: '下一页', }, - } + }, }) diff --git a/docs/.vitepress/env.d.ts b/docs/.vitepress/env.d.ts index c390b34..e27de33 100644 --- a/docs/.vitepress/env.d.ts +++ b/docs/.vitepress/env.d.ts @@ -2,4 +2,4 @@ declare module 'markdown-it-pangu' { import { PluginSimple } from 'markdown-it' const pangu: PluginSimple export default pangu -} \ No newline at end of file +} diff --git a/docs/.vitepress/nav.ts b/docs/.vitepress/nav.ts index 5fdd842..b0139db 100644 --- a/docs/.vitepress/nav.ts +++ b/docs/.vitepress/nav.ts @@ -2,25 +2,25 @@ import { DefaultTheme } from 'vitepress' const nav = [ { - text: "大学指南", - link: "/campus/", + text: '大学指南', + link: '/campus/', }, { - text: "Fashion", - link: "/fashion/", + text: 'Fashion', + link: '/fashion/', }, { - text: "贡献指南", + text: '贡献指南', items: [{ - text: "校园版块投稿指南", - link: "/contributor-guide/campus.md", + text: '校园版块投稿指南', + link: '/contributor-guide/campus.md', }, { - text: "其他投稿指南", - link: "/contributor-guide/other.md", + text: '其他投稿指南', + link: '/contributor-guide/other.md', }, { - text: "校园版块贡献模板", - link: "/contributor-guide/CampusTemplate.md", + text: '校园版块贡献模板', + link: '/contributor-guide/CampusTemplate.md', }], }, -] satisfies DefaultTheme.Config['nav']; -export default nav; +] satisfies DefaultTheme.Config['nav'] +export default nav diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index def4cfc..1c6b7c0 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,17 +1,16 @@ // https://vitepress.dev/guide/custom-theme -import { h } from 'vue' +import './style.css' + import type { Theme } from 'vitepress' import DefaultTheme from 'vitepress/theme' -import './style.css' +import { h } from 'vue' export default { extends: DefaultTheme, - Layout: () => { - return h(DefaultTheme.Layout, null, { - // https://vitepress.dev/guide/extending-default-theme#layout-slots - }) - }, + Layout: () => h(DefaultTheme.Layout, null, { + // https://vitepress.dev/guide/extending-default-theme#layout-slots + }), enhanceApp({ app, router, siteData }) { // ... - } + }, } satisfies Theme diff --git a/package.json b/package.json index 732e733..a1eddba 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,18 @@ "build:old": "vuepress build docs", "clean-dev:old": "vuepress dev docs --clean-cache", "dev:old": "vuepress dev docs", - "update-package": "pnpm dlx vp-update" + "update-package": "pnpm dlx vp-update", + "lint": "eslint docs --ext .ts,.vue,.md" }, "devDependencies": { + "@hydrooj/eslint-config": "^1.0.6", "@types/markdown-it": "^13.0.7", "@types/markdown-it-footnote": "^3.0.3", + "eslint": "^8.54.0", "markdown-it-footnote": "^3.0.3", "markdown-it-katex": "^2.0.3", "markdown-it-pangu": "^1.0.2", + "typescript": "^5.3.2", "vitepress": "^1.0.0-rc.31", "vitepress-plugin-auto-sidebar": "^1.1.0", "vue": "^3.3.8",