Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Jul 11, 2023
1 parent a63667b commit 7d80137
Show file tree
Hide file tree
Showing 202 changed files with 443 additions and 435 deletions.
15 changes: 8 additions & 7 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
const fs = require('fs')
const path = require('path')

const getSubDirectories = (dir) => fs.readdirSync(dir).filter(item => fs.statSync(path.join(dir, item)).isDirectory())
const getSubDirectories = (dir) =>
fs
.readdirSync(dir)
.filter((item) => fs.statSync(path.join(dir, item)).isDirectory())
const corePackages = getSubDirectories(path.resolve(__dirname, 'packages'))
const ecosystemPackages = getSubDirectories(path.resolve(__dirname, 'ecosystem'))
const ecosystemPackages = getSubDirectories(
path.resolve(__dirname, 'ecosystem'),
)

module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [
2,
'always',
[...corePackages, ...ecosystemPackages],
],
'scope-enum': [2, 'always', [...corePackages, ...ecosystemPackages]],
'footer-max-line-length': [0],
},
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pnpm-lock.yaml
*.html
*.md
4 changes: 2 additions & 2 deletions docs/.vuepress/components/NpmBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const props = defineProps({
})
const badgeLink = computed(
() => `https://www.npmjs.com/package/${props.package}`
() => `https://www.npmjs.com/package/${props.package}`,
)
const badgeLabel = computed(() => {
if (props.distTag) {
Expand All @@ -26,7 +26,7 @@ const badgeImg = computed(
() =>
`https://badgen.net/npm/v/${props.package}/${
props.distTag
}?label=${encodeURIComponent(badgeLabel.value)}`
}?label=${encodeURIComponent(badgeLabel.value)}`,
)
</script>

Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { fs } from '@vuepress/utils'
const require = createRequire(import.meta.url)

export const version = fs.readJsonSync(
require.resolve('@vuepress/core/package.json')
require.resolve('@vuepress/core/package.json'),
).version
4 changes: 2 additions & 2 deletions docs/advanced/cookbook/usage-of-client-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Inside the client config file, `@vuepress/client` package provides a helper func
import { defineClientConfig } from '@vuepress/client'

export default defineClientConfig({
enhance({ app, router, siteData }){},
setup(){},
enhance({ app, router, siteData }) {},
setup() {},
layouts: {},
rootComponents: [],
})
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ But if you have too many things to do in your config file, you can consider to e
```ts
import myPlugin from './path/to/my-plugin.js'

export default {
export default {
plugins: [
myPlugin(),
],
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To configure the default theme, you need to import and use it in your config fil
```ts
import { defaultTheme } from 'vuepress'

export default {
export default {
theme: defaultTheme({
// default theme config
navbar: [
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/advanced/cookbook/usage-of-client-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const pluginOrTheme = {
import { defineClientConfig } from '@vuepress/client'

export default defineClientConfig({
enhance({ app, router, siteData }){},
setup(){},
enhance({ app, router, siteData }) {},
setup() {},
layouts: {},
rootComponents: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useActiveHeaderLinks = ({
const scrollTop = Math.max(
window.scrollY,
document.documentElement.scrollTop,
document.body.scrollTop
document.body.scrollTop,
)
// check if we are at page top
const isAtPageTop = Math.abs(scrollTop - 0) < offset
Expand All @@ -39,23 +39,23 @@ export const useActiveHeaderLinks = ({
// get the total scroll length of current page
const scrollHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
document.body.scrollHeight,
)
// check if we have reached page bottom
// notice the `scrollBottom` might not be exactly equal to `scrollHeight`, so we add offset here
const isAtPageBottom = Math.abs(scrollHeight - scrollBottom) < offset

// get all header links
const headerLinks: HTMLAnchorElement[] = Array.from(
document.querySelectorAll(headerLinkSelector)
document.querySelectorAll(headerLinkSelector),
)
// get all header anchors
const headerAnchors: HTMLAnchorElement[] = Array.from(
document.querySelectorAll(headerAnchorSelector)
document.querySelectorAll(headerAnchorSelector),
)
// filter anchors that do not have corresponding links
const existedHeaderAnchors = headerAnchors.filter((anchor) =>
headerLinks.some((link) => link.hash === anchor.hash)
headerLinks.some((link) => link.hash === anchor.hash),
)

for (let i = 0; i < existedHeaderAnchors.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const BackToTop = defineComponent({
{
name: 'back-to-top',
},
() => (show.value ? backToTopEl : null)
() => (show.value ? backToTopEl : null),
)
},
})
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/plugin-container/src/node/containerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type MarkdownItContainerRenderFunction = (
index: number,
options: any,
env: MarkdownEnv,
self: Renderer
self: Renderer,
) => string

export type RenderPlaceFunction = (info: string) => string
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/plugin-docsearch/src/client/components/Docsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Docsearch = defineComponent({
...options.value.searchParameters,
facetFilters: getFacetFilters(
options.value.searchParameters?.facetFilters,
lang.value
lang.value,
),
},
})
Expand Down Expand Up @@ -111,7 +111,7 @@ export const Docsearch = defineComponent({
: h('div', {
onClick: trigger,
innerHTML: getSearchButtonTemplate(
options.value.translations?.button
options.value.translations?.button,
),
}),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const useDocsearchShim = (): Partial<DocSearchProps> => {
}
event.preventDefault()
router.push(
resolveRoutePathFromUrl(hit.url, __DOCSEARCH_INDEX_BASE__)
resolveRoutePathFromUrl(hit.url, __DOCSEARCH_INDEX_BASE__),
)
},
children,
},
__v: null,
} as unknown),
}) as unknown,

// navigation behavior triggered by `onKeyDown` internally
navigator: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type FacetFilters =
*/
export const getFacetFilters = (
rawFacetFilters: FacetFilters = [],
lang: string
lang: string,
): FacetFilters => [
`lang:${lang}`,
...((isArray(rawFacetFilters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const svg = h(
points:
'45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9',
}),
]
],
)

export const ExternalLinkIcon = defineComponent({
Expand All @@ -49,7 +49,7 @@ export const ExternalLinkIcon = defineComponent({
() =>
props.locales[routeLocale.value] ?? {
openInNewWindow: 'open in new window',
}
},
)
return () =>
h('span', [
Expand All @@ -59,7 +59,7 @@ export const ExternalLinkIcon = defineComponent({
{
class: 'external-link-icon-sr-only',
},
locale.value.openInNewWindow
locale.value.openInNewWindow,
),
])
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const externalLinkIconPlugin = ({
idx,
options,
env: MarkdownEnv,
self
self,
) => {
const result = rawLinkOpenRule(tokens, idx, options, env, self)
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('@vuepress/plugin-external-link-icon > node > externalLinkIconPlugin',
'<RouterLink to="foo.html">foo</RouterLink>',
]
.map((a) => `<p>${a}</p>`)
.join('\n') + '\n'
.join('\n') + '\n',
)
})

Expand All @@ -69,7 +69,7 @@ describe('@vuepress/plugin-external-link-icon > node > externalLinkIconPlugin',
'<RouterLink to="foo.html">foo</RouterLink>',
]
.map((a) => `<p>${a}</p>`)
.join('\n') + '\n'
.join('\n') + '\n',
)
})

Expand All @@ -90,7 +90,7 @@ describe('@vuepress/plugin-external-link-icon > node > externalLinkIconPlugin',
'<RouterLink to="foo.html">foo</RouterLink>',
]
.map((a) => `<p>${a}</p>`)
.join('\n') + '\n'
.join('\n') + '\n',
)
})
})
4 changes: 2 additions & 2 deletions ecosystem/plugin-git/src/node/gitPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const gitPlugin =
name: '@vuepress/plugin-git',

extendsPage: async (
page: Page<GitPluginPageData, GitPluginFrontmatter>
page: Page<GitPluginPageData, GitPluginFrontmatter>,
) => {
page.data.git = {}

Expand All @@ -49,7 +49,7 @@ export const gitPlugin =
const filePaths = [
page.filePathRelative,
...(page.frontmatter.gitInclude ?? []).map((item) =>
path.join(page.filePathRelative, '..', item)
path.join(page.filePathRelative, '..', item),
),
]

Expand Down
4 changes: 2 additions & 2 deletions ecosystem/plugin-git/src/node/utils/getContributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type { GitContributor } from '../types.js'

export const getContributors = async (
filePaths: string[],
cwd: string
cwd: string,
): Promise<GitContributor[]> => {
const { stdout } = await execa(
'git',
['--no-pager', 'shortlog', '-nes', 'HEAD', '--', ...filePaths],
{
cwd,
stdin: 'inherit',
}
},
)

return stdout
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/plugin-git/src/node/utils/getCreatedTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { execa } from 'execa'
*/
export const getCreatedTime = async (
filePaths: string[],
cwd: string
cwd: string,
): Promise<number> => {
const { stdout } = await execa(
'git',
['--no-pager', 'log', '--diff-filter=A', '--format=%at', ...filePaths],
{
cwd,
}
},
)

return (
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/plugin-git/src/node/utils/getUpdatedTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { execa } from 'execa'
*/
export const getUpdatedTime = async (
filePaths: string[],
cwd: string
cwd: string,
): Promise<number> => {
const { stdout } = await execa(
'git',
Expand All @@ -19,7 +19,7 @@ export const getUpdatedTime = async (
],
{
cwd,
}
},
)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare global {
* @see https://support.google.com/analytics/answer/9216061
*/
export const useGoogleAnalytics = (
options: GoogleAnalyticsPluginOptions
options: GoogleAnalyticsPluginOptions,
): void => {
// avoid duplicated import
if (window.dataLayer && window.gtag) {
Expand Down
8 changes: 4 additions & 4 deletions ecosystem/plugin-nprogress/src/client/nprogress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const nprogress: NProgress = {
nprogress.status = n === 1 ? null : n
const progress = nprogress.render(!started)
const bar = progress.querySelector<HTMLElement>(
nprogress.settings.barSelector
nprogress.settings.barSelector,
)!
const speed = nprogress.settings.speed
const ease = nprogress.settings.easing
Expand Down Expand Up @@ -145,11 +145,11 @@ export const nprogress: NProgress = {
progress.innerHTML = nprogress.settings.template

const bar = progress.querySelector<HTMLElement>(
nprogress.settings.barSelector
nprogress.settings.barSelector,
)!
const perc = fromStart ? '-100' : toBarPerc(nprogress.status || 0)
const parent = document.querySelector<HTMLElement>(
nprogress.settings.parent
nprogress.settings.parent,
)!

css(bar, {
Expand All @@ -169,7 +169,7 @@ export const nprogress: NProgress = {
removeClass(document.documentElement, 'nprogress-busy')
removeClass(
document.querySelector(nprogress.settings.parent)!,
'nprogress-custom-parent'
'nprogress-custom-parent',
)
const progress = document.getElementById('nprogress')
progress && removeElement(progress)
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/plugin-palette/src/node/preparePaletteFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const preparePaletteFile = async (
}: Pick<
Required<PalettePluginOptions>,
'userPaletteFile' | 'tempPaletteFile' | 'importCode'
>
>,
): Promise<string> => {
const userPalette = app.dir.source(userPaletteFile)

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/plugin-palette/src/node/prepareStyleFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const prepareStyleFile = async (
}: Pick<
Required<PalettePluginOptions>,
'userStyleFile' | 'tempStyleFile' | 'importCode'
>
>,
): Promise<string> => {
const userStyle = app.dir.source(userStyleFile)

Expand Down
Loading

0 comments on commit 7d80137

Please sign in to comment.