【同步】前端项目源码

【修复】工作流兼容问题
This commit is contained in:
chudong
2025-05-10 11:53:11 +08:00
parent c514471adc
commit f1a75afaba
584 changed files with 55714 additions and 110 deletions

BIN
frontend/environment/.DS_Store vendored Normal file

Binary file not shown.

BIN
frontend/environment/eslint/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,33 @@
import js from '@eslint/js'
import prettierRules from 'eslint-config-prettier'
import turboPlugin from 'eslint-plugin-turbo'
import tseslint from 'typescript-eslint'
import onlyWarn from 'eslint-plugin-only-warn'
// eslint 配置
export default tseslint.config([
// 配置需要忽略的文件
{
ignores: ['node_modules', 'dist'],
},
// 配置 eslint 规则
js.configs.recommended,
...tseslint.configs.recommended,
// 配置 prettier 的 eslint 规则
prettierRules,
// 配置 turbo 的 eslint 规则
{
plugins: {
turbo: turboPlugin,
},
rules: {
'turbo/no-undeclared-env-vars': 'warn',
},
},
// 配置 only-warn 的 eslint 规则
{
plugins: {
onlyWarn,
},
},
])

View File

@@ -0,0 +1,32 @@
{
"name": "@baota/eslint",
"version": "1.0.0",
"type": "module",
"description": "",
"exports": {
".": "./src/index.js",
"./vue": "./src/vue.js",
"./vitest": "./src/vitest.js",
"./next": "./src/next.js"
},
"devDependencies": {
"@baota/typescript": "workspace:*",
"@baota/prettier": "workspace:*",
"eslint": "^9.23.0",
"@eslint/js": "^9.20.0",
"@next/eslint-plugin-next": "^15.1.6",
"@vue/eslint-config-typescript": "^14.5.0",
"@vitest/eslint-plugin": "^1.1.38",
"eslint-plugin-playwright": "^2.2.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-turbo": "^2.4.0",
"globals": "^15.15.0",
"typescript-eslint": "^8.24.0",
"eslint-plugin-vue": "^9.32.0",
"eslint-plugin-oxlint": "^0.16.2",
"@vue/eslint-config-prettier": "10.2.0"
}
}

View File

@@ -0,0 +1,3 @@
import prettierConfig from '@baota/prettier'
export default prettierConfig

View File

@@ -0,0 +1,33 @@
import js from '@eslint/js'
import prettierRules from 'eslint-config-prettier' // eslint插件 prettier
import turboPlugin from 'eslint-plugin-turbo' // eslint插件 turbo
import tseslint from 'typescript-eslint' // eslint插件 类型检查
import onlyWarn from 'eslint-plugin-only-warn' // eslint插件 只警告
// 配置 eslint 规则
export default tseslint.config([
// 配置需要忽略的文件
{
ignores: ['node_modules', 'dist'],
},
// 配置 eslint 规则
js.configs.recommended,
...tseslint.configs.recommended,
// 配置 prettier 的 eslint 规则
prettierRules,
// 配置 turbo 的 eslint 规则
{
plugins: {
turbo: turboPlugin,
},
rules: {
'turbo/no-undeclared-env-vars': 'warn',
},
},
// 配置 only-warn 的 eslint 规则
{
plugins: {
onlyWarn,
},
},
])

View File

@@ -0,0 +1,48 @@
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import { rules as prettierRules } from 'eslint-config-prettier'
import * as pluginReactHooks from 'eslint-plugin-react-hooks'
import * as pluginReact from 'eslint-plugin-react'
import * as pluginNext from '@next/eslint-plugin-next'
import baseConfig from './index.js'
// 配置 next.js 的 eslint 规则
const nextConfig = tseslint.config([
...baseConfig,
js.configs.recommended,
prettierRules,
...tseslint.configs.recommended,
{
...pluginReact.configs.flat.recommended,
languageOptions: {
...pluginReact.configs.flat.recommended.languageOptions,
globals: {
...globals.serviceworker,
},
},
},
{
plugins: {
'@next/next': pluginNext,
},
rules: {
...pluginNext.configs.recommended.rules,
...pluginNext.configs['core-web-vitals'].rules,
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
},
settings: { react: { version: 'detect' } },
rules: {
...pluginReactHooks.configs.recommended.rules,
// React scope no longer necessary with new JSX transform.
'react/react-in-jsx-scope': 'off',
},
},
])
export default nextConfig

View File

@@ -0,0 +1,16 @@
import tseslint from 'typescript-eslint'
import pluginVitest from '@vitest/eslint-plugin' // vitest 插件,用于解析 .test 和 .spec 文件
import pluginPlaywright from 'eslint-plugin-playwright' // playwright 插件,用于解析 playwright 测试
export default tseslint.config([
// 配置 vitest 的 eslint 规则
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*'],
},
// 配置 playwright 的 eslint 规则
{
...pluginPlaywright.configs['flat/recommended'],
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
},
])

View File

@@ -0,0 +1,26 @@
import pluginVue from 'eslint-plugin-vue' // vue 插件,用于解析 .vue 文件
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript' // vue ts 配置,用于解析 .ts 和 .tsx 文件
import oxlint from 'eslint-plugin-oxlint' // oxlint 插件,用于解析 oxlint 规则
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting' // prettier 配置,用于跳过格式化
// 配置 vue 的 eslint 规则
export default defineConfigWithVueTs(
// 配置需要解析的文件
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
},
// 配置需要忽略的文件
{
name: 'app/files-to-ignore',
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
},
// 配置 vue 的 eslint 规则
pluginVue.configs['flat/essential'],
// 配置 vue ts 的 eslint 规则
vueTsConfigs.recommended,
// 配置 oxlint 的 eslint 规则
...oxlint.configs['flat/recommended'],
// 配置 prettier 的 eslint 规则
skipFormatting,
)

View File

@@ -0,0 +1,4 @@
{
"extends": "@baota/typescript/base.json",
"include": ["**/*.{js,ts,jsx,tsx}", "eslint.config.ts", "./types.d.ts"]
}

View File

@@ -0,0 +1,7 @@
declare module 'eslint-plugin-only-warn' {
const plugin: any
export default plugin
}
declare module '@next/eslint-plugin-next'
declare module 'globals'

View File

@@ -0,0 +1,11 @@
export default {
tabWidth: 2, // 缩进
useTabs: true, // 缩进方式
semi: false, // 语句结尾是否加分号
singleQuote: true, // 单引号
printWidth: 120, // 换行长度
arrowParens: 'always', // 箭头函数参数
bracketSpacing: true, // 对象花括号内是否加空格
endOfLine: 'auto', // 换行符
vueIndentScriptAndStyle: true, // vue文件内script和style标签缩进
}

View File

@@ -0,0 +1,17 @@
{
"name": "@baota/prettier",
"version": "1.0.0",
"type": "module",
"description": "",
"exports": {
".": "./index.js"
},
"dependencies": {},
"devDependencies": {
"@baota/typescript": "workspace:*",
"prettier": "^3.5.3"
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@@ -0,0 +1,3 @@
import prettierConfig from './index.js'
export default prettierConfig

View File

@@ -0,0 +1,4 @@
{
"extends": "@baota/typescript/base.json",
"include": ["**/*.{js,ts,jsx,tsx}", "eslint.config.ts", "./types.d.ts"]
}

View File

@@ -0,0 +1,6 @@
import config from '@baota/eslint'
// eslint 配置
const eslintConfig = config
export default eslintConfig

View File

@@ -0,0 +1,192 @@
/**
* @type {import('stylelint').Config}
*/
export default {
// 继承配置
extends: [
'stylelint-config-standard',
'stylelint-config-prettier',
'stylelint-config-html',
'stylelint-config-tailwindcss',
],
// 插件
plugins: ['stylelint-order'],
// 规则
rules: {
'declaration-block-trailing-semicolon': null,
'no-descending-specificity': null,
// TailwindCSS 规则
'at-rule-no-unknown': [
true,
{
ignoreAtRules: ['tailwind', 'apply', 'variants', 'responsive', 'screen', 'layer'],
},
],
// 缩进 2 空格
indentation: 2,
// 颜色值小写
'color-hex-case': 'lower',
// 禁止空块
'block-no-empty': true,
// 颜色6位长度
'color-hex-length': 'long',
// 兼容自定义标签名
'selector-type-no-unknown': [
true,
{
ignoreTypes: [],
},
],
// 忽略特殊伪类选择器
'selector-pseudo-element-no-unknown': [
true,
{
ignorePseudoElements: ['v-deep', ':deep'],
},
],
// 禁止空注释
'comment-no-empty': true,
// 禁止简写属性覆盖相关普通属性
'declaration-block-no-shorthand-property-overrides': true,
// 禁止重复的属性
'declaration-block-no-duplicate-properties': true,
// 属性的排序
'order/properties-order': [
// 定位
{
groupName: 'positioning',
emptyLineBefore: 'always',
properties: ['position', 'top', 'right', 'bottom', 'left', 'z-index'],
},
// 布局
{
groupName: 'layout',
emptyLineBefore: 'always',
properties: [
'display',
'flex',
'flex-direction',
'flex-wrap',
'flex-basis',
'flex-grow',
'flex-shrink',
'flex-flow',
'grid',
'grid-template-columns',
'grid-template-rows',
'grid-template-areas',
'grid-auto-columns',
'grid-auto-rows',
'grid-auto-flow',
'gap',
'justify-content',
'align-items',
'align-content',
'order',
'float',
'clear',
],
},
// 盒模型
{
groupName: 'box-model',
emptyLineBefore: 'always',
properties: [
'width',
'min-width',
'max-width',
'height',
'min-height',
'max-height',
'margin',
'margin-top',
'margin-right',
'margin-bottom',
'margin-left',
'padding',
'padding-top',
'padding-right',
'padding-bottom',
'padding-left',
'box-sizing',
'overflow',
'overflow-x',
'overflow-y',
],
},
// 排版
{
groupName: 'typography',
emptyLineBefore: 'always',
properties: [
'font',
'font-family',
'font-size',
'font-weight',
'font-style',
'font-variant',
'font-size-adjust',
'line-height',
'letter-spacing',
'text-align',
'text-transform',
'text-decoration',
'text-indent',
'text-overflow',
'text-shadow',
'white-space',
'word-break',
'word-spacing',
'word-wrap',
'color',
],
},
// 视觉效果
{
groupName: 'visual',
emptyLineBefore: 'always',
properties: [
'background',
'background-color',
'background-image',
'background-repeat',
'background-position',
'background-size',
'border',
'border-width',
'border-style',
'border-color',
'border-radius',
'box-shadow',
'opacity',
'visibility',
'cursor',
'pointer-events',
],
},
// 动画
{
groupName: 'animation',
emptyLineBefore: 'always',
properties: [
'transition',
'transition-property',
'transition-duration',
'transition-timing-function',
'transition-delay',
'animation',
'animation-name',
'animation-duration',
'animation-timing-function',
'animation-delay',
'animation-iteration-count',
'animation-direction',
'animation-fill-mode',
'animation-play-state',
'transform',
'transform-origin',
],
},
],
},
}

View File

@@ -0,0 +1,23 @@
{
"name": "@baota/stylelint",
"version": "1.0.0",
"type": "module",
"main": "stylelint.config.js",
"files": [
"stylelint.config.js"
],
"dependencies": {},
"devDependencies": {
"stylelint": "^16.16.0",
"stylelint-config-standard": "^37.0.0",
"stylelint-config-tailwindcss": "^1.0.0",
"stylelint-order": "^6.0.4",
"@baota/typescript": "workspace:*",
"@baota/prettier": "workspace:*",
"@baota/eslint": "workspace:*"
},
"exports": {
".": "./stylelint.config.js",
"./rules": "./index.ts"
}
}

View File

@@ -0,0 +1,3 @@
import prettierConfig from '@baota/prettier'
// 使用 prettier 配置
export default prettierConfig

View File

@@ -0,0 +1,4 @@
{
"extends": "@baota/typescript/base.json",
"include": ["**/*.{js,ts,jsx,tsx}", "eslint.config.ts", "./types.d.ts"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"incremental": false,
"isolatedModules": true,
"lib": ["es2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"moduleDetection": "force",
"moduleResolution": "Bundler",
"noUncheckedIndexedAccess": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ES2022"
},
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
}

View File

@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"plugins": [{ "name": "next" }],
"module": "ESNext",
"moduleResolution": "Bundler",
"allowJs": true,
"jsx": "preserve",
"noEmit": true
}
}

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

View File

@@ -0,0 +1,15 @@
{
"name": "@baota/typescript",
"version": "1.0.0",
"type": "module",
"license": "MIT",
"exports": {
"./*": "./*"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"typescript": "^5.8.2"
}
}

View File

@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx"
}
}

View File

View File

@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"allowJs": true,
"importHelpers": true,
"jsx": "preserve",
"jsxImportSource": "vue",
"types": ["vue"],
"lib": ["esnext", "dom", "dom.iterable", "scripthost", "ES2015", "DOM"]
}
}