chore: normalize tooling configurations
This commit is contained in:
@@ -4,6 +4,7 @@ root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
17
.lintstagedrc.mjs
vendored
17
.lintstagedrc.mjs
vendored
@@ -1,18 +1,16 @@
|
||||
import path from 'node:path'
|
||||
|
||||
function createCommand(prefix, join) {
|
||||
return (filenames) => `${prefix} ${filenames.map((f) => path.relative(process.cwd(), f)).join(` ${join} `)}`
|
||||
function createCommand(prefix) {
|
||||
return (filenames) => `${prefix} ${filenames.map((f) => path.relative(process.cwd(), f)).join(' ')}`
|
||||
}
|
||||
|
||||
export default {
|
||||
// JavaScript/TypeScript 文件使用 Biome (排除 .d.ts 文件和tauri-plugin-hula目录)
|
||||
'*.{js,jsx,ts,tsx,json}': [
|
||||
(filenames) => {
|
||||
const filteredFiles = filenames.filter((f) =>
|
||||
!f.includes('src-tauri/') &&
|
||||
!f.includes('tauri-plugin-hula/') &&
|
||||
!f.includes('public/') &&
|
||||
!f.endsWith('.d.ts')
|
||||
const filteredFiles = filenames.filter(
|
||||
(f) =>
|
||||
!f.includes('src-tauri/') && !f.includes('tauri-plugin-hula/') && !f.includes('public/') && !f.endsWith('.d.ts')
|
||||
)
|
||||
return filteredFiles.length > 0
|
||||
? `biome check --write --unsafe ${filteredFiles.map((f) => path.relative(process.cwd(), f)).join(' ')}`
|
||||
@@ -20,10 +18,7 @@ export default {
|
||||
}
|
||||
],
|
||||
// Vue 文件:使用 Biome 检查和修复,然后用 Prettier 格式化
|
||||
'*.vue': [
|
||||
createCommand('biome check --write --unsafe', ''),
|
||||
createCommand('prettier --write', '')
|
||||
],
|
||||
'*.vue': [createCommand('biome check --write --unsafe'), createCommand('prettier --write')],
|
||||
// Rust 代码:使用 manifest-path 指定 workspace,避免切换目录
|
||||
'src-tauri/**/*.rs': () => 'cargo fmt --manifest-path src-tauri/Cargo.toml'
|
||||
}
|
||||
|
||||
2
biome.json
vendored
2
biome.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/latest/schema.json",
|
||||
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
|
||||
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"includes": [
|
||||
|
||||
20
build/config/getPath.ts
vendored
20
build/config/getPath.ts
vendored
@@ -1,20 +0,0 @@
|
||||
//使用path需要按照@types/node依赖
|
||||
import path from 'node:path'
|
||||
|
||||
/**
|
||||
* 获取项目根路径
|
||||
* @descrition 末尾不带斜杠
|
||||
*/
|
||||
export const getRootPath = () => {
|
||||
return path.resolve(__dirname, process.cwd())
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目主路径 如(src)
|
||||
* @param mainName - src目录名称(默认: "src")
|
||||
* @descrition 末尾不带斜杠
|
||||
*/
|
||||
export const getSrcPath = (mainName = 'src') => {
|
||||
const rootPath = getRootPath()
|
||||
return `${rootPath}/${mainName}`
|
||||
}
|
||||
2
package.json
vendored
2
package.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/jsconfig",
|
||||
"$schema": "https://json.schemastore.org/package",
|
||||
"name": "hula",
|
||||
"type": "module",
|
||||
"version": "3.0.7",
|
||||
|
||||
18
src/typings/postcss-pxtorem.d.ts
vendored
Normal file
18
src/typings/postcss-pxtorem.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
declare module 'postcss-pxtorem' {
|
||||
import type { PluginCreator } from 'postcss'
|
||||
|
||||
interface Options {
|
||||
rootValue?: number
|
||||
unitPrecision?: number
|
||||
propList?: string[]
|
||||
selectorBlackList?: (string | RegExp)[]
|
||||
replace?: boolean
|
||||
mediaQuery?: boolean
|
||||
minPixelValue?: number
|
||||
exclude?: string | RegExp | ((file: string) => boolean)
|
||||
}
|
||||
|
||||
const pxtorem: PluginCreator<Options>
|
||||
export default pxtorem
|
||||
}
|
||||
|
||||
7
tsconfig.node.json
vendored
7
tsconfig.node.json
vendored
@@ -5,7 +5,10 @@
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["vite.config.ts", "build/config/**/*"]
|
||||
"include": ["vite.config.ts", "build/config/**/*", "src/typings/postcss-pxtorem.d.ts"]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import UnoCSS from '@unocss/vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
@@ -14,7 +13,6 @@ import VueSetupExtend from 'vite-plugin-vue-setup-extend'
|
||||
import { getComponentsDirs, getComponentsDtsPath } from './build/config/components'
|
||||
import { createManualChunks } from './build/config/chunks'
|
||||
import { atStartup } from './build/config/console'
|
||||
import { getRootPath, getSrcPath } from './build/config/getPath'
|
||||
import packageJson from './package.json'
|
||||
|
||||
function getLocalIP() {
|
||||
@@ -61,7 +59,7 @@ export default defineConfig(({ mode }: ConfigEnv) => {
|
||||
|
||||
// 无效IP或特殊地址的情况
|
||||
return config.TAURI_ENV_PLATFORM === 'ios'
|
||||
? rawIP
|
||||
? (rawIP ?? '127.0.0.1')
|
||||
: config.TAURI_ENV_PLATFORM === 'android'
|
||||
? '0.0.0.0'
|
||||
: '127.0.0.1'
|
||||
@@ -74,11 +72,11 @@ export default defineConfig(({ mode }: ConfigEnv) => {
|
||||
resolve: {
|
||||
alias: {
|
||||
// 配置主路径别名@
|
||||
'@': getSrcPath(),
|
||||
// 配置移动端路径别名@
|
||||
'#': getSrcPath('src/mobile'),
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
// 配置移动端路径别名#
|
||||
'#': fileURLToPath(new URL('./src/mobile', import.meta.url)),
|
||||
// 配置路径别名~(根路径)
|
||||
'~': getRootPath()
|
||||
'~': fileURLToPath(new URL('.', import.meta.url))
|
||||
}
|
||||
},
|
||||
css: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
@@ -7,7 +8,6 @@ import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import { getComponentsDirs, getComponentsDtsPath } from './build/config/components'
|
||||
import { getRootPath, getSrcPath } from './build/config/getPath'
|
||||
|
||||
const testPlatform = process.env.TAURI_ENV_PLATFORM
|
||||
const testComponentsDirs = getComponentsDirs(testPlatform)
|
||||
@@ -35,8 +35,9 @@ export default defineConfig({
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': getSrcPath(),
|
||||
'~': getRootPath()
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
'#': fileURLToPath(new URL('./src/mobile', import.meta.url)),
|
||||
'~': fileURLToPath(new URL('.', import.meta.url))
|
||||
}
|
||||
},
|
||||
test: {
|
||||
|
||||
Reference in New Issue
Block a user