Skip to content

Commit 208eebb

Browse files
committed
refactor: unify ESLint
1 parent 02443a6 commit 208eebb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4304
-2300
lines changed

.eslintrc.json

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
"plugin:import/recommended",
1414
"plugin:import/typescript"
1515
],
16-
"ignorePatterns": [
17-
"dist",
18-
".eslintrc.json"
19-
],
16+
"ignorePatterns": ["dist", ".eslintrc.json"],
2017
"parser": "@typescript-eslint/parser",
21-
"plugins": [
22-
"react-refresh",
23-
"import"
24-
],
18+
"plugins": ["react-refresh", "import"],
2519
"rules": {
2620
"react-refresh/only-export-components": [
2721
"warn",
@@ -36,10 +30,7 @@
3630
"builtin",
3731
"external",
3832
"internal",
39-
[
40-
"parent",
41-
"sibling"
42-
],
33+
["parent", "sibling"],
4334
"index",
4435
"object",
4536
"type"
@@ -51,9 +42,7 @@
5142
"position": "before"
5243
}
5344
],
54-
"pathGroupsExcludedImportTypes": [
55-
"react"
56-
],
45+
"pathGroupsExcludedImportTypes": ["react"],
5746
"newlines-between": "always",
5847
"alphabetize": {
5948
"order": "asc",
@@ -71,4 +60,4 @@
7160
"node": true
7261
}
7362
}
74-
}
63+
}

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches:
6-
- main # 当推送到 main 分支时触发
6+
- main # 当推送到 main 分支时触发
77

88
permissions:
9-
contents: write # 需要写入权限来部署到 GitHub Pages
9+
contents: write # 需要写入权限来部署到 GitHub Pages
1010

1111
jobs:
1212
build-and-deploy:
@@ -23,8 +23,8 @@ jobs:
2323
- name: Setup pnpm 📦
2424
uses: pnpm/action-setup@v2
2525
with:
26-
version: 9.1.2 # 使用 pnpm 8.x 版本,您可以根据需要调整
27-
run_install: false # 我们将在后面手动运行安装
26+
version: 9.1.2 # 使用 pnpm 8.x 版本,您可以根据需要调整
27+
run_install: false # 我们将在后面手动运行安装
2828

2929
- name: Get pnpm store directory
3030
id: pnpm-cache
@@ -51,5 +51,5 @@ jobs:
5151
- name: Deploy to GitHub Pages 🚀
5252
uses: JamesIves/github-pages-deploy-action@v4
5353
with:
54-
folder: dist # 要部署的文件夹
55-
branch: gh-pages # 部署到的分支
54+
folder: dist # 要部署的文件夹
55+
branch: gh-pages # 部署到的分支

.prettierrc.js renamed to .prettierrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
jsxSingleQuote: false,
99
trailingComma: 'none',
1010
bracketSpacing: true,
11-
jsxBracketSameLine: false,
11+
bracketSameLine: false,
1212
arrowParens: 'always',
1313
rangeStart: 0,
1414
rangeEnd: Infinity,

deploy/docker-compose.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,46 @@ services:
44
image: peerjs/peerjs-server
55
container_name: peerjs-server
66
ports:
7-
- "9000:9000"
8-
- "9443:9443" # 添加HTTPS端口
7+
- '9000:9000'
8+
- '9443:9443' # 添加HTTPS端口
99
environment:
1010
- PORT=9000
1111
- KEY=peerjs
1212
- DEBUG=*
13-
- ALLOW_DISCOVERY=false # 设置为 true 可以启用房间发现功能
14-
- PROXIED=true # 在反向代理后面,设置为 true
15-
- EXPIRE_TIMEOUT=5000 # 连接超时时间(毫秒)
16-
- ALIVE_TIMEOUT=60000 # 保持连接的超时时间(毫秒)
17-
- CONCURRENT_LIMIT=5000 # 并发连接数限制
18-
- SECURE=true # 启用HTTPS
19-
- SSL_KEY=/ssl/privkey.pem # SSL私钥路径
20-
- SSL_CERT=/ssl/cert.pem # SSL证书路径
21-
- ALLOW_ORIGINS=https://yourdomain.com # 限制允许的源域名
22-
- USERNAME=admin # 设置基本认证用户名
23-
- PASSWORD=yourStrongPassword # 设置基本认证密码
13+
- ALLOW_DISCOVERY=false # 设置为 true 可以启用房间发现功能
14+
- PROXIED=true # 在反向代理后面,设置为 true
15+
- EXPIRE_TIMEOUT=5000 # 连接超时时间(毫秒)
16+
- ALIVE_TIMEOUT=60000 # 保持连接的超时时间(毫秒)
17+
- CONCURRENT_LIMIT=5000 # 并发连接数限制
18+
- SECURE=true # 启用HTTPS
19+
- SSL_KEY=/ssl/privkey.pem # SSL私钥路径
20+
- SSL_CERT=/ssl/cert.pem # SSL证书路径
21+
- ALLOW_ORIGINS=https://yourdomain.com # 限制允许的源域名
22+
- USERNAME=admin # 设置基本认证用户名
23+
- PASSWORD=yourStrongPassword # 设置基本认证密码
2424
restart: always
2525
volumes:
2626
- ./ssl:/ssl
27-
command: ["--port", "9000", "--key", "peerjs", "--proxied", "true", "--secure", "true", "--sslkey", "/ssl/privkey.pem", "--sslcert", "/ssl/cert.pem", "--allow_origins", "https://yourdomain.com", "--username", "admin", "--password", "yourStrongPassword"]
27+
command:
28+
[
29+
'--port',
30+
'9000',
31+
'--key',
32+
'peerjs',
33+
'--proxied',
34+
'true',
35+
'--secure',
36+
'true',
37+
'--sslkey',
38+
'/ssl/privkey.pem',
39+
'--sslcert',
40+
'/ssl/cert.pem',
41+
'--allow_origins',
42+
'https://yourdomain.com',
43+
'--username',
44+
'admin',
45+
'--password',
46+
'yourStrongPassword'
47+
]
2848
networks:
2949
- peerjs-network

eslint.config.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import js from '@eslint/js'
2-
import globals from 'globals'
3-
import react from 'eslint-plugin-react'
4-
import reactHooks from 'eslint-plugin-react-hooks'
5-
import reactRefresh from 'eslint-plugin-react-refresh'
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import react from 'eslint-plugin-react';
4+
import reactHooks from 'eslint-plugin-react-hooks';
5+
import reactRefresh from 'eslint-plugin-react-refresh';
66

77
export default [
88
{ ignores: ['dist'] },
@@ -14,25 +14,22 @@ export default [
1414
parserOptions: {
1515
ecmaVersion: 'latest',
1616
ecmaFeatures: { jsx: true },
17-
sourceType: 'module',
18-
},
17+
sourceType: 'module'
18+
}
1919
},
2020
settings: { react: { version: '18.3' } },
2121
plugins: {
2222
react,
2323
'react-hooks': reactHooks,
24-
'react-refresh': reactRefresh,
24+
'react-refresh': reactRefresh
2525
},
2626
rules: {
2727
...js.configs.recommended.rules,
2828
...react.configs.recommended.rules,
2929
...react.configs['jsx-runtime'].rules,
3030
...reactHooks.configs.recommended.rules,
3131
'react/jsx-no-target-blank': 'off',
32-
'react-refresh/only-export-components': [
33-
'warn',
34-
{ allowConstantExport: true },
35-
],
36-
},
37-
},
38-
]
32+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
33+
}
34+
}
35+
];

index.html

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>PeerChat - 基于 WebRTC 的实时聊天应用</title>
8+
<!-- GitHub Pages 重定向脚本 -->
9+
<script type="text/javascript">
10+
// 单页应用的 GitHub Pages 重定向处理
11+
(function () {
12+
// 如果是重定向过来的,从 URL 中提取路径
13+
var redirect = sessionStorage.redirect;
14+
delete sessionStorage.redirect;
15+
if (redirect && redirect != location.href) {
16+
history.replaceState(null, null, redirect);
17+
}
18+
})();
19+
</script>
20+
</head>
321

4-
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>PeerChat - 基于 WebRTC 的实时聊天应用</title>
9-
<!-- GitHub Pages 重定向脚本 -->
10-
<script type="text/javascript">
11-
// 单页应用的 GitHub Pages 重定向处理
12-
(function () {
13-
// 如果是重定向过来的,从 URL 中提取路径
14-
var redirect = sessionStorage.redirect
15-
delete sessionStorage.redirect
16-
if (redirect && redirect != location.href) {
17-
history.replaceState(null, null, redirect)
18-
}
19-
})();
20-
</script>
21-
</head>
22-
23-
<body>
24-
<div id="root"></div>
25-
<script type="module" src="/src/main.tsx"></script>
26-
</body>
27-
28-
</html>
22+
<body>
23+
<div id="root"></div>
24+
<script type="module" src="/src/main.tsx"></script>
25+
</body>
26+
</html>

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"build": "vite build",
99
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1010
"lint:fix": "eslint . --ext ts,tsx --fix",
11+
"format": "prettier --write .",
12+
"format:check": "prettier --check .",
1113
"preview": "vite preview",
1214
"predeploy": "npm run build",
1315
"deploy": "gh-pages -d dist",
@@ -66,6 +68,7 @@
6668
"postcss": "^8.4.35",
6769
"postcss-import": "^16.0.0",
6870
"postcss-nesting": "^12.0.2",
71+
"prettier": "^3.6.2",
6972
"sass": "1.69.5",
7073
"tailwindcss": "^3.4.1",
7174
"tailwindcss-animate": "^1.0.7",
@@ -74,4 +77,4 @@
7477
"vite": "^5.1.0"
7578
},
7679
"packageManager": "pnpm@9.1.2"
77-
}
80+
}

0 commit comments

Comments
 (0)