Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinhuish committed Oct 17, 2024
1 parent dde5255 commit 20abef8
Show file tree
Hide file tree
Showing 39 changed files with 1,600 additions and 1,846 deletions.
9 changes: 4 additions & 5 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
'*.md': 'markdownlint --fix --ignore-path=.gitignore',
'./src/*.{js,cjs,mjs,ts,cts,mts}': () => [
'tsc --noEmit',
'eslint --fix --cache',
'publint',
'*.{js,cjs,mjs,ts,cts,mts,md}': () => [
'pnpm check:types',
'pnpm lint:eslint',
'pnpm lint:publint',
],
};
11 changes: 0 additions & 11 deletions .markdownlint.json

This file was deleted.

236 changes: 119 additions & 117 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,141 +2,143 @@ import { dirname, join } from 'node:path';
import fg from 'fast-glob';
import { defineConfig } from 'vitepress';

const files = await fg('**/*.md', {
cwd: join(__dirname, '..', 'src'),
});

const dirs = [...new Set(files.map(f => dirname(f)).filter(d => d !== '.' && d !== '..'))];

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'UniUse',
description: 'uni-app (vue3) 组合式工具集。',
lang: 'zh-CN',
srcDir: '.',
srcExclude: ['!(docs|src)/**'],
rewrites: {
'docs/:name.md': ':name.md',
'docs/:doc/:name.md': ':doc/:name.md',
'src/index.md': 'apis.md',
'src/:pkg/:name.md': ':pkg/:name.md',
},
export default async () => {
const files = await fg('**/*.md', {
cwd: join(__dirname, '..', 'src'),
});

themeConfig: {
logo: '/logo.png',
const dirs = [...new Set(files.map(f => dirname(f)).filter(d => d !== '.' && d !== '..'))];

nav: [
{ text: '指南', link: '/guide/' },
{ text: 'API', link: '/apis/' },
{ text: 'ChangeLog', link: 'https://github.com/uni-helper/uni-use/blob/main/CHANGELOG.md' },
],
return defineConfig({
title: 'UniUse',
description: 'uni-app (vue3) 组合式工具集。',
lang: 'zh-CN',
srcDir: '.',
srcExclude: ['!(docs|src)/**'],
rewrites: {
'docs/:name.md': ':name.md',
'docs/:doc/:name.md': ':doc/:name.md',
'src/index.md': 'apis.md',
'src/:pkg/:name.md': ':pkg/:name.md',
},

sidebar: {
'/guide/': [
{
text: '指南',
items: [
{
text: '开始',
link: '/guide/',
},
{
text: '注意事项',
link: '/guide/notice',
},
{
text: '更新日志',
link: 'https://github.com/uni-helper/uni-use/blob/main/CHANGELOG.md',
},
{
text: '所有函数',
link: '/apis/',
},
],
},
],
'/': [
{
text: 'All Functions',
items: [
{
text: '函数列表',
link: '/apis/',
},
],
},
{
text: 'API',
items: dirs.map(dir => ({
text: dir,
link: `/${dir}/`,
})),
},
themeConfig: {
logo: '/logo.png',

nav: [
{ text: '指南', link: '/guide/' },
{ text: 'API', link: '/apis/' },
{ text: 'ChangeLog', link: 'https://github.com/uni-helper/uni-use/blob/main/CHANGELOG.md' },
],
},

editLink: {
pattern: 'https://github.com/uni-helper/uni-use/tree/main/src/:path',
text: '为这个页面提供建议',
},
sidebar: {
'/guide/': [
{
text: '指南',
items: [
{
text: '开始',
link: '/guide/',
},
{
text: '注意事项',
link: '/guide/notice',
},
{
text: '更新日志',
link: 'https://github.com/uni-helper/uni-use/blob/main/CHANGELOG.md',
},
{
text: '所有函数',
link: '/apis/',
},
],
},
],
'/': [
{
text: 'All Functions',
items: [
{
text: '函数列表',
link: '/apis/',
},
],
},
{
text: 'API',
items: dirs.map(dir => ({
text: dir,
link: `/${dir}/`,
})),
},
],
},

footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2022-PRESENT uni-helper and uni-helper contributors',
},
editLink: {
pattern: 'https://github.com/uni-helper/uni-use/tree/main/src/:path',
text: '为这个页面提供建议',
},

docFooter: {
prev: '上一页',
next: '下一页',
},
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2022-PRESENT uni-helper and uni-helper contributors',
},

outline: {
label: '页面导航',
},
docFooter: {
prev: '上一页',
next: '下一页',
},

search: {
provider: 'local',
options: {
locales: {
'zh-CN': {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
outline: {
label: '页面导航',
},

search: {
provider: 'local',
options: {
locales: {
'zh-CN': {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
},
},
},
},
},
},
},
},

lastUpdated: {
text: '最后更新于',
formatOptions: {
dateStyle: 'short',
timeStyle: 'medium',
lastUpdated: {
text: '最后更新于',
formatOptions: {
dateStyle: 'short',
timeStyle: 'medium',
},
},
},

langMenuLabel: '多语言',
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '菜单',
darkModeSwitchLabel: '主题',
lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到深色模式',
langMenuLabel: '多语言',
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '菜单',
darkModeSwitchLabel: '主题',
lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到深色模式',

socialLinks: [
{ icon: 'github', link: 'https://github.com/uni-helper/uni-use' },
],
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/uni-helper/uni-use' },
],
},

});
});
};
79 changes: 38 additions & 41 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
{
"files.associations": {
"manifest.json": "jsonc",
"pages.json": "jsonc",
"pages.json": "jsonc"
},
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
]
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
]
}
Loading

0 comments on commit 20abef8

Please sign in to comment.