From 0d591a39453acfb9df0a318406ace02b66864c2d Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Fri, 8 Dec 2023 19:07:04 +0800 Subject: [PATCH] feat: use prettier to lint docs --- .prettierignore | 11 ++++- docs/.vuepress/public/new.html | 4 +- .../advanced/cookbook/markdown-and-vue-sfc.md | 15 +++---- .../cookbook/passing-data-to-client-code.md | 5 ++- docs/advanced/plugin.md | 12 +++--- docs/advanced/theme.md | 8 ++-- docs/guide/assets.md | 3 +- docs/guide/deployment.md | 4 ++ docs/guide/markdown.md | 28 ++++++++++--- docs/guide/page.md | 2 +- docs/guide/plugin.md | 4 +- docs/reference/cli.md | 40 +++++++++---------- docs/reference/components.md | 1 + docs/reference/default-theme/components.md | 2 + docs/reference/default-theme/extending.md | 10 ++++- docs/reference/default-theme/markdown.md | 12 ++++++ docs/reference/frontmatter.md | 22 +++++----- docs/reference/plugin-api.md | 17 ++++---- docs/reference/plugin/back-to-top.md | 4 +- docs/reference/plugin/container.md | 4 +- 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 | 2 +- docs/reference/plugin/theme-data.md | 2 +- docs/reference/plugin/toc.md | 5 ++- .../cookbook/passing-data-to-client-code.md | 5 ++- docs/zh/advanced/plugin.md | 12 +++--- docs/zh/advanced/theme.md | 8 ++-- docs/zh/guide/assets.md | 3 +- docs/zh/guide/deployment.md | 4 ++ docs/zh/guide/markdown.md | 31 ++++++++++---- docs/zh/guide/page.md | 4 +- docs/zh/guide/plugin.md | 4 +- docs/zh/reference/cli.md | 40 +++++++++---------- docs/zh/reference/components.md | 1 + docs/zh/reference/default-theme/components.md | 2 + docs/zh/reference/default-theme/extending.md | 10 ++++- docs/zh/reference/default-theme/markdown.md | 12 ++++++ docs/zh/reference/frontmatter.md | 22 +++++----- docs/zh/reference/node-api.md | 33 ++++++++------- docs/zh/reference/plugin-api.md | 12 +++--- docs/zh/reference/plugin/back-to-top.md | 4 +- docs/zh/reference/plugin/container.md | 4 +- docs/zh/reference/plugin/nprogress.md | 4 +- docs/zh/reference/plugin/palette.md | 9 +++-- docs/zh/reference/plugin/pwa.md | 6 +-- docs/zh/reference/plugin/theme-data.md | 2 +- docs/zh/reference/plugin/toc.md | 5 ++- package.json | 1 + 51 files changed, 285 insertions(+), 187 deletions(-) diff --git a/.prettierignore b/.prettierignore index 94c9f11d..3c6d5686 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,10 @@ +# VuePress files +docs/.vuepress/.temp/ +docs/.vuepress/.cache/ +docs/.vuepress/dist/ + +# Node modules +node_modules/ + +# pnpm lockfile pnpm-lock.yaml -*.html -*.md 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/cookbook/markdown-and-vue-sfc.md b/docs/advanced/cookbook/markdown-and-vue-sfc.md index ed4c940f..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 }}_ 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/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