From 7c7989891cb87959d90c82ce18c7a5bb650ee46b Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Sun, 10 Dec 2023 21:10:46 +0800 Subject: [PATCH] build: set up lint and format scripts (#4) Co-authored-by: Xinyu Liu --- .github/workflows/check-docs.yml | 3 ++ .prettierignore | 2 - README.md | 4 +- docs/.vuepress/public/new.html | 4 +- docs/advanced/architecture.md | 2 +- .../advanced/cookbook/markdown-and-vue-sfc.md | 30 +++++++------- .../cookbook/passing-data-to-client-code.md | 5 ++- .../cookbook/usage-of-client-config.md | 6 +-- docs/advanced/plugin.md | 12 +++--- docs/advanced/theme.md | 8 ++-- docs/guide/assets.md | 3 +- docs/guide/deployment.md | 4 ++ docs/guide/markdown.md | 30 +++++++++++--- docs/guide/page.md | 2 +- docs/guide/plugin.md | 6 +-- docs/reference/cli.md | 40 +++++++++--------- docs/reference/components.md | 1 + docs/reference/default-theme/components.md | 2 + docs/reference/default-theme/config.md | 5 ++- docs/reference/default-theme/extending.md | 10 ++++- docs/reference/default-theme/markdown.md | 29 +++++++++---- docs/reference/frontmatter.md | 22 +++++----- docs/reference/node-api.md | 2 +- docs/reference/plugin-api.md | 19 ++++----- docs/reference/plugin/back-to-top.md | 4 +- docs/reference/plugin/container.md | 6 ++- docs/reference/plugin/docsearch.md | 2 +- docs/reference/plugin/medium-zoom.md | 2 +- docs/reference/plugin/nprogress.md | 4 +- docs/reference/plugin/palette.md | 9 ++-- docs/reference/plugin/pwa.md | 9 ++-- docs/reference/plugin/register-components.md | 6 +-- docs/reference/plugin/shiki.md | 4 +- docs/reference/plugin/theme-data.md | 2 +- docs/reference/plugin/toc.md | 5 ++- docs/zh/README.md | 2 +- .../advanced/cookbook/markdown-and-vue-sfc.md | 15 +++---- .../cookbook/passing-data-to-client-code.md | 6 ++- .../cookbook/usage-of-client-config.md | 4 +- docs/zh/advanced/plugin.md | 12 +++--- docs/zh/advanced/theme.md | 8 ++-- docs/zh/guide/README.md | 2 +- docs/zh/guide/assets.md | 3 +- docs/zh/guide/bundler.md | 2 +- docs/zh/guide/deployment.md | 14 ++++--- docs/zh/guide/markdown.md | 34 +++++++++++---- docs/zh/guide/page.md | 4 +- docs/zh/guide/plugin.md | 6 +-- docs/zh/reference/cli.md | 40 +++++++++--------- docs/zh/reference/components.md | 3 +- docs/zh/reference/default-theme/components.md | 2 + docs/zh/reference/default-theme/config.md | 5 ++- docs/zh/reference/default-theme/extending.md | 10 ++++- docs/zh/reference/default-theme/markdown.md | 29 +++++++++---- docs/zh/reference/frontmatter.md | 22 +++++----- docs/zh/reference/node-api.md | 41 ++++++++++--------- docs/zh/reference/plugin-api.md | 17 ++++---- docs/zh/reference/plugin/back-to-top.md | 4 +- docs/zh/reference/plugin/container.md | 6 ++- docs/zh/reference/plugin/git.md | 1 - docs/zh/reference/plugin/google-analytics.md | 2 +- docs/zh/reference/plugin/nprogress.md | 4 +- docs/zh/reference/plugin/palette.md | 9 ++-- docs/zh/reference/plugin/pwa.md | 11 ++--- .../reference/plugin/register-components.md | 6 +-- docs/zh/reference/plugin/theme-data.md | 2 +- docs/zh/reference/plugin/toc.md | 5 ++- package.json | 4 +- 68 files changed, 372 insertions(+), 267 deletions(-) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index 7714df9f..aba61fae 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -35,6 +35,9 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm lint + - name: Build docs with ${{ matrix.bundler }} run: pnpm docs:build env: diff --git a/.prettierignore b/.prettierignore index 94c9f11d..bd5535a6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1 @@ pnpm-lock.yaml -*.html -*.md diff --git a/README.md b/README.md index cb86b27e..b3d0249b 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ VuePress documentation repository. ## Deployments -- Release deployment: https://v2.vuepress.vuejs.org -- Developer deployment: https://vuepress.github.io +- Release deployment: +- Developer deployment: ## License diff --git a/docs/.vuepress/public/new.html b/docs/.vuepress/public/new.html index 911989fe..b83ab7cb 100644 --- a/docs/.vuepress/public/new.html +++ b/docs/.vuepress/public/new.html @@ -1 +1,3 @@ - + diff --git a/docs/advanced/architecture.md b/docs/advanced/architecture.md index b80f495a..4fe32a04 100644 --- a/docs/advanced/architecture.md +++ b/docs/advanced/architecture.md @@ -33,4 +33,4 @@ The above figure shows the core process of VuePress Node App and the hooks of [P - In the **dev / build** stage: - Bundler will be resolved: - [extendsBundlerOptions](../reference/plugin-api.md#extendsbundleroptions) hook will be processed to create bundler configuration. - - [alias](../reference/plugin-api.md#alias) hook and [define](../reference/plugin-api.md#define) hook would be used in bundler configuration, so they will be processed here. \ No newline at end of file + - [alias](../reference/plugin-api.md#alias) hook and [define](../reference/plugin-api.md#define) hook would be used in bundler configuration, so they will be processed here. diff --git a/docs/advanced/cookbook/markdown-and-vue-sfc.md b/docs/advanced/cookbook/markdown-and-vue-sfc.md index cdbc1771..66f1a57f 100644 --- a/docs/advanced/cookbook/markdown-and-vue-sfc.md +++ b/docs/advanced/cookbook/markdown-and-vue-sfc.md @@ -27,13 +27,14 @@ _Current count is: {{ count }}_ @@ -60,13 +61,14 @@ _Current count is: {{ count }}_ diff --git a/docs/advanced/cookbook/passing-data-to-client-code.md b/docs/advanced/cookbook/passing-data-to-client-code.md index 28407066..39b919b4 100644 --- a/docs/advanced/cookbook/passing-data-to-client-code.md +++ b/docs/advanced/cookbook/passing-data-to-client-code.md @@ -43,7 +43,10 @@ First, write a temp file `foo.js`, which will be generated in the [temp](../../r export default (options) => ({ async onPrepared(app) { // write temp file - await app.writeTemp('foo.js', `export const foo = ${JSON.stringify(options.foo)}`) + await app.writeTemp( + 'foo.js', + `export const foo = ${JSON.stringify(options.foo)}`, + ) }, }) ``` diff --git a/docs/advanced/cookbook/usage-of-client-config.md b/docs/advanced/cookbook/usage-of-client-config.md index 8dd27dce..542f48cb 100644 --- a/docs/advanced/cookbook/usage-of-client-config.md +++ b/docs/advanced/cookbook/usage-of-client-config.md @@ -12,7 +12,7 @@ const pluginOrTheme = { } ``` -Inside the client config file, `@vuepress/client` package provides a helper function [defineClientConfig](../../reference/client-api.md#defineclientconfig) to help you define the client config: +Inside the client config file, `@vuepress/client` package provides a helper function [defineClientConfig](../../reference/client-api.md#defineclientconfig) to help you define the client config: ```ts import { defineClientConfig } from '@vuepress/client' @@ -119,7 +119,7 @@ export default defineClientConfig({ // provide a value that can be injected by layouts, pages and other components const count = ref(0) provide('count', count) - } + }, }) ``` @@ -139,7 +139,7 @@ export default defineClientConfig({ // use DOM API after mounted document.querySelector('#app') }) - } + }, }) ``` diff --git a/docs/advanced/plugin.md b/docs/advanced/plugin.md index e0be81ba..c7e3538f 100644 --- a/docs/advanced/plugin.md +++ b/docs/advanced/plugin.md @@ -6,7 +6,7 @@ Before reading this guide, you'd better learn the VuePress [architecture](./arch ## Create a Plugin -A plugin should be a plain JavaScript object that satisfies the [Plugin API](../reference/plugin-api.md), which is called a *Plugin Object*: +A plugin should be a plain JavaScript object that satisfies the [Plugin API](../reference/plugin-api.md), which is called a _Plugin Object_: ```ts const fooPlugin = { @@ -15,7 +15,7 @@ const fooPlugin = { } ``` -A plugin could also be a function that receives the [app instance](../reference/node-api.md#app) as the param and returns a *Plugin Object*, which is called a *Plugin Function*: +A plugin could also be a function that receives the [app instance](../reference/node-api.md#app) as the param and returns a _Plugin Object_, which is called a _Plugin Function_: ```ts const barPlugin = (app) => { @@ -26,7 +26,7 @@ const barPlugin = (app) => { } ``` -A plugin usually needs to allow user options, so we typically provide users with a function to receive options, and returns a *Plugin Object* or a *Plugin Function*. Then your plugin should be converted like this: +A plugin usually needs to allow user options, so we typically provide users with a function to receive options, and returns a _Plugin Object_ or a _Plugin Function_. Then your plugin should be converted like this: ```ts const fooPlugin = (options) => { @@ -53,11 +53,9 @@ After creating a plugin, you should follow some conventions in the [package.json ```json { "name": "vuepress-plugin-foo", - "keywords": [ - "vuepress-plugin" - ] + "keywords": ["vuepress-plugin"] } ``` -- Set `name` to follow the naming convention, i.e. `vuepress-plugin-xxx` or `@org/vuepress-plugin-xxx`, which should be consistent with the [name](../reference/plugin-api.md#name) field of the *Plugin Object*. +- Set `name` to follow the naming convention, i.e. `vuepress-plugin-xxx` or `@org/vuepress-plugin-xxx`, which should be consistent with the [name](../reference/plugin-api.md#name) field of the _Plugin Object_. - Set `keywords` to include `vuepress-plugin`, so that users can search your plugin on NPM. diff --git a/docs/advanced/theme.md b/docs/advanced/theme.md index bb83bf16..8bfc27aa 100644 --- a/docs/advanced/theme.md +++ b/docs/advanced/theme.md @@ -6,7 +6,7 @@ Before reading this guide, you'd better learn the guide of [Writing a Plugin](./ ## Create a Theme -A VuePress theme is a special plugin, which should satisfy the [Theme API](../reference/theme-api.md). Like plugins, a theme should also be a *Theme Object* or a *Theme Function*, and could be wrapped with a function to receive options: +A VuePress theme is a special plugin, which should satisfy the [Theme API](../reference/theme-api.md). Like plugins, a theme should also be a _Theme Object_ or a _Theme Function_, and could be wrapped with a function to receive options: ```ts import { getDirname, path } from '@vuepress/utils' @@ -90,11 +90,9 @@ Also, there are some conventions for theme in [package.json](https://docs.npmjs. ```json { "name": "vuepress-theme-foo", - "keywords": [ - "vuepress-theme" - ] + "keywords": ["vuepress-theme"] } ``` -- Set `name` to follow the naming convention: `vuepress-theme-xxx` or `@org/vuepress-theme-xxx`, which should be consistent with the [name](../reference/theme-api.md#name) field of the *Theme Object*. +- Set `name` to follow the naming convention: `vuepress-theme-xxx` or `@org/vuepress-theme-xxx`, which should be consistent with the [name](../reference/theme-api.md#name) field of the _Theme Object_. - Set `keywords` to include `vuepress-theme`, so that users can search your theme on NPM. diff --git a/docs/guide/assets.md b/docs/guide/assets.md index 7d3abb7f..7d9411fe 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -60,6 +60,7 @@ In most cases, you don't need to worry about the reference path of those public ```md + ![VuePress Logo](/images/hero.png) ``` @@ -67,7 +68,7 @@ However, sometimes you may have some dynamical links referencing public files, e ```vue diff --git a/docs/zh/advanced/cookbook/passing-data-to-client-code.md b/docs/zh/advanced/cookbook/passing-data-to-client-code.md index e4b84c67..d22dfa47 100644 --- a/docs/zh/advanced/cookbook/passing-data-to-client-code.md +++ b/docs/zh/advanced/cookbook/passing-data-to-client-code.md @@ -21,7 +21,6 @@ export default (options) => ({ 然后,在客户端代码中直接使用它们: - ```ts const foo = __FOO__ const obj = __OBJ__ @@ -44,7 +43,10 @@ declare const __OBJ__: { bar: number } export default (options) => ({ async onPrepared(app) { // 写入临时文件 - await app.writeTemp('foo.js', `export const foo = ${JSON.stringify(options.foo)}`) + await app.writeTemp( + 'foo.js', + `export const foo = ${JSON.stringify(options.foo)}`, + ) }, }) ``` diff --git a/docs/zh/advanced/cookbook/usage-of-client-config.md b/docs/zh/advanced/cookbook/usage-of-client-config.md index 98938cd6..035045e3 100644 --- a/docs/zh/advanced/cookbook/usage-of-client-config.md +++ b/docs/zh/advanced/cookbook/usage-of-client-config.md @@ -119,7 +119,7 @@ export default defineClientConfig({ // 供给一个值,可以被布局、页面和其他组件注入 const count = ref(0) provide('count', count) - } + }, }) ``` @@ -139,7 +139,7 @@ export default defineClientConfig({ // 在 mounted 之后使用 DOM API document.querySelector('#app') }) - } + }, }) ``` diff --git a/docs/zh/advanced/plugin.md b/docs/zh/advanced/plugin.md index 5cae7723..8f53a186 100644 --- a/docs/zh/advanced/plugin.md +++ b/docs/zh/advanced/plugin.md @@ -6,7 +6,7 @@ ## 创建一个插件 -插件是一个符合 [插件 API](../reference/plugin-api.md) 的普通 JavaScript 对象,称之为 *插件对象* : +插件是一个符合 [插件 API](../reference/plugin-api.md) 的普通 JavaScript 对象,称之为 _插件对象_ : ```ts const fooPlugin = { @@ -15,7 +15,7 @@ const fooPlugin = { } ``` -插件还可以是一个接收 [App 实例](../reference/node-api.md#app) 作为参数,且返回值为 *插件对象* 的函数,称之为 *插件函数* : +插件还可以是一个接收 [App 实例](../reference/node-api.md#app) 作为参数,且返回值为 _插件对象_ 的函数,称之为 _插件函数_ : ```ts const barPlugin = (app) => { @@ -26,7 +26,7 @@ const barPlugin = (app) => { } ``` -插件通常需要允许用户传入配置,因此我们一般都会提供给用户一个函数来接收配置,然后将 *插件对象* 或者 *插件函数* 作为返回值。于是,你的插件应该转换成这样的形式: +插件通常需要允许用户传入配置,因此我们一般都会提供给用户一个函数来接收配置,然后将 _插件对象_ 或者 _插件函数_ 作为返回值。于是,你的插件应该转换成这样的形式: ```ts const fooPlugin = (options) => { @@ -53,11 +53,9 @@ const barPlugin = (options) => { ```json { "name": "vuepress-plugin-foo", - "keywords": [ - "vuepress-plugin" - ] + "keywords": ["vuepress-plugin"] } ``` -- 将 `name` 按照约定命名,即 `vuepress-plugin-xxx` 或 `@org/vuepress-plugin-xxx` ,它应该和 *插件对象* 的 [name](../reference/plugin-api.md#name) 字段保持一致。 +- 将 `name` 按照约定命名,即 `vuepress-plugin-xxx` 或 `@org/vuepress-plugin-xxx` ,它应该和 _插件对象_ 的 [name](../reference/plugin-api.md#name) 字段保持一致。 - 在 `keywords` 中包含 `vuepress-plugin` ,这样用户可以在 NPM 上搜索到你的插件。 diff --git a/docs/zh/advanced/theme.md b/docs/zh/advanced/theme.md index deba1404..08e33ba5 100644 --- a/docs/zh/advanced/theme.md +++ b/docs/zh/advanced/theme.md @@ -6,7 +6,7 @@ ## 创建一个主题 -VuePress 主题是一个特殊的插件,它应该符合 [主题 API](../reference/theme-api.md) 。和插件一样,主题可以是一个 *主题对象* 或一个 *主题函数* ,并且通常通过一个函数来接收配置项: +VuePress 主题是一个特殊的插件,它应该符合 [主题 API](../reference/theme-api.md) 。和插件一样,主题可以是一个 _主题对象_ 或一个 _主题函数_ ,并且通常通过一个函数来接收配置项: ```ts import { getDirname, path } from '@vuepress/utils' @@ -90,11 +90,9 @@ export default defineClientConfig({ ```json { "name": "vuepress-theme-foo", - "keywords": [ - "vuepress-theme" - ] + "keywords": ["vuepress-theme"] } ``` -- 将 `name` 按照约定命名: `vuepress-theme-xxx` 或 `@org/vuepress-theme-xxx` ,它应该和 *主题对象* 的 [name](../reference/theme-api.md#name) 字段保持一致。 +- 将 `name` 按照约定命名: `vuepress-theme-xxx` 或 `@org/vuepress-theme-xxx` ,它应该和 _主题对象_ 的 [name](../reference/theme-api.md#name) 字段保持一致。 - 在 `keywords` 中包含 `vuepress-theme` ,这样用户可以在 NPM 上搜索到你的主题。 diff --git a/docs/zh/guide/README.md b/docs/zh/guide/README.md index baf7d5a4..1848728c 100644 --- a/docs/zh/guide/README.md +++ b/docs/zh/guide/README.md @@ -12,7 +12,7 @@ VuePress 诞生的初衷是为了支持 Vue.js 及其子项目的文档需求, 在开发过程中,我们启动一个常规的开发服务器 (dev-server) ,并将 VuePress 站点作为一个常规的 SPA。如果你以前使用过 Vue 的话,你在使用时会感受到非常熟悉的开发体验。 -在构建过程中,我们会为 VuePress 站点创建一个服务端渲染 (SSR) 的版本,然后通过虚拟访问每一条路径来渲染对应的 HTML 。这种做法的灵感来源于 [Nuxt](https://nuxtjs.org/) 的 `nuxt generate` 命令,以及其他的一些项目,比如 [Gatsby](https://www.gatsbyjs.org/)。 +在构建过程中,我们会为 VuePress 站点创建一个服务端渲染 (SSR) 的版本,然后通过虚拟访问每一条路径来渲染对应的 HTML 。这种做法的灵感来源于 [Nuxt](https://nuxtjs.org/) 的 `nuxt generate` 命令,以及其他的一些项目,比如 [Gatsby](https://www.gatsbyjs.org/)。 ## 为什么不是 ...? diff --git a/docs/zh/guide/assets.md b/docs/zh/guide/assets.md index 80df50b7..0fe58afd 100644 --- a/docs/zh/guide/assets.md +++ b/docs/zh/guide/assets.md @@ -60,6 +60,7 @@ ```md + ![VuePress Logo](/images/hero.png) ``` @@ -67,7 +68,7 @@ ```vue