style: next lint 改为 eslint

This commit is contained in:
ocean-gao 2024-12-20 12:52:53 +08:00
parent 441eee1217
commit 161fa63b02
9 changed files with 2236 additions and 1544 deletions

View File

@ -1 +0,0 @@
public/serviceWorker.js

View File

@ -1,7 +0,0 @@
{
"extends": "next/core-web-vitals",
"plugins": ["prettier", "unused-imports"],
"rules": {
"unused-imports/no-unused-imports": "warn"
}
}

1
.gitignore vendored
View File

@ -36,7 +36,6 @@ yarn-error.log*
next-env.d.ts
dev
.vscode
.idea
# docker-compose env files

View File

@ -1,6 +0,0 @@
{
"./app/**/*.{js,ts,jsx,tsx,json,html,css,md}": [
"eslint --fix",
"prettier --write"
]
}

15
.vscode/README.md vendored Normal file
View File

@ -0,0 +1,15 @@
## VSCode
### 1. 扩展安装
> 以下为项目初始化必须要安装的扩展,若有冲突的扩展项,请先卸载掉或者去掉全局配置
1. `ESLint` # JS 及 CSS 文件格式化
2. `Git History`
3. `Git History Diff`
4. `Pretier - Code formatter` # JSON 文件格式化
5. `vscode-wxml` # 提供 wxml 语法支持
6. `vscode-icons` # 文件显示图标,开发体验优化用到
7. `wxml` # 微信小程序 wxml 格式化
8. `TODO Highlight` # TODO 高亮展示
9. `Todo Tree` # 显示待办任务列表

41
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"window.title": "${activeEditorMedium}${separator}${rootName}",
// Enable the ESlint flat config support
"eslint.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"
},
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"svelte",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}

80
eslint.config.mjs Normal file
View File

@ -0,0 +1,80 @@
// eslint.config.js
import antfu from '@antfu/eslint-config';
export default await antfu({
ignores: [
'pnpm-lock.yaml',
'public/serviceWorker.js', // 保持现有配置逻辑
],
stylistic: {
indent: 2,
quotes: 'single',
semi: 'always',
},
formatters: {
prettierOptions: {
tabWidth: 2,
useTabs: false,
trailingComma: 'all',
singleQuote: false,
semi: true,
},
/**
* Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
* By default uses Prettier
*/
css: true,
/**
* Format HTML files
* By default uses Prettier
*/
html: true,
/**
* Format Markdown files
* Supports Prettier and dprint
* By default uses Prettier
*/
markdown: 'prettier',
},
typescript: true,
vue: true,
react: true,
rules: {
'curly': ['error', 'multi-line'],
'vue/block-order': [
'error',
{
order: ['template', 'script', 'style'],
},
],
'style/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
multilineDetection: 'brackets',
},
],
'yml/indent': ['error', 4, { indentBlockSequences: true, indicatorValueIndent: 2 }],
'no-console': 'off',
'antfu/no-top-level-await': 'off',
'no-func-assign': 'off',
'no-useless-constructor': 'off',
'valid-typeof': 'off',
'regexp/no-super-linear-backtracking': 'off',
'eslint-comments/no-unlimited-disable': 'off',
'regexp/no-unused-capturing-group': 'off',
'style/no-tabs': 'off', // 兼容 go 代码风格
'no-array-constructor': 'off',
'prefer-regex-literals': 'off',
'style/max-statements-per-line': 'off',
'no-new-func': 'off',
'style/brace-style': 'off',
},
});

View File

@ -4,18 +4,23 @@
"private": true,
"packageManager": "pnpm@8.15.5",
"license": "mit",
"engines": {
"node": ">= 20.0.0"
},
"scripts": {
"prepare": "simple-git-hooks",
"bootstrap": "pnpm install",
"clean": "rm -rf ./node_modules",
"mask": "npx tsx app/masks/build.ts",
"mask:watch": "npx watch \"yarn mask\" app/masks",
"dev": "concurrently -r \"yarn run mask:watch\" \"next dev\"",
"build": "yarn mask && cross-env BUILD_MODE=standalone next build",
"mask:watch": "npx watch \"pnpm mask\" app/masks",
"dev": "concurrently -r \"pnpm run mask:watch\" \"next dev\"",
"proxy-dev": "sh ./scripts/init-proxy.sh && proxychains -f ./scripts/proxychains.conf pnpm dev",
"build": "pnpm mask && cross-env BUILD_MODE=standalone next build",
"start": "next start",
"lint": "next lint",
"export": "yarn mask && cross-env BUILD_MODE=export BUILD_APP=1 next build",
"export:dev": "concurrently -r \"yarn mask:watch\" \"cross-env BUILD_MODE=export BUILD_APP=1 next dev\"",
"prompts": "node ./scripts/fetch-prompts.mjs",
"prepare": "husky install",
"proxy-dev": "sh ./scripts/init-proxy.sh && proxychains -f ./scripts/proxychains.conf yarn dev"
"lint": "eslint --fix",
"export": "pnpm mask && cross-env BUILD_MODE=export BUILD_APP=1 next build",
"export:dev": "concurrently -r \"pnpm mask:watch\" \"cross-env BUILD_MODE=export BUILD_APP=1 next dev\"",
"prompts": "node ./scripts/fetch-prompts.mjs"
},
"dependencies": {
"@fortaine/fetch-event-source": "^3.0.6",
@ -47,13 +52,15 @@
"remark-breaks": "^3.0.2",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"rt-client": "https://github.com/Azure-Samples/aoai-realtime-audio-sdk/releases/download/js/v0.5.0/rt-client-0.5.0.tgz",
"sass": "^1.59.2",
"spark-md5": "^3.0.2",
"use-debounce": "^9.0.4",
"zustand": "^4.3.8",
"rt-client": "https://github.com/Azure-Samples/aoai-realtime-audio-sdk/releases/download/js/v0.5.0/rt-client-0.5.0.tgz"
"zustand": "^4.3.8"
},
"devDependencies": {
"@antfu/eslint-config": "3.9.1",
"@eslint-react/eslint-plugin": "^1.21.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.1",
"@types/js-yaml": "4.0.9",
@ -65,18 +72,24 @@
"@types/spark-md5": "^3.0.4",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint": "^8.49.0",
"eslint-config-next": "13.4.19",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unused-imports": "^3.2.0",
"husky": "^8.0.0",
"lint-staged": "^13.2.2",
"prettier": "^3.0.2",
"eslint": "^9.14.0",
"eslint-plugin-format": "^0.1.3",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"lint-staged": "^15.2.10",
"simple-git-hooks": "2.11.1",
"ts-node": "^10.9.2",
"tsx": "^4.16.0",
"typescript": "5.2.2",
"watch": "^1.0.2",
"webpack": "^5.88.1"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,jsx,vue,ts,tsx,css,html}": [
"npm run lint"
]
}
}

File diff suppressed because it is too large Load Diff