瀏覽代碼

feat: Add ESLint (#176)

master
Lipis 4 年之前
父節點
當前提交
c0eeac3feb
No account linked to committer's email address
共有 8 個文件被更改,包括 888 次插入38 次删除
  1. 3
    0
      .eslintrc.json
  2. 5
    3
      .github/dependabot.yml
  3. 2
    6
      .github/workflows/lint.yml
  4. 0
    1
      .github/workflows/publish-docker.yml
  5. 2
    6
      .github/workflows/test.yml
  6. 15
    6
      package.json
  7. 1
    1
      src/index.ts
  8. 860
    15
      yarn.lock

+ 3
- 0
.eslintrc.json 查看文件

1
+{
2
+  "extends": "@excalidraw/eslint-config"
3
+}

+ 5
- 3
.github/dependabot.yml 查看文件

1
 version: 2
1
 version: 2
2
 updates:
2
 updates:
3
-  - package-ecosystem: "npm"
4
-    directory: "/"
3
+  - package-ecosystem: npm
4
+    directory: /
5
     schedule:
5
     schedule:
6
-      interval: "weekly"
6
+      interval: weekly
7
+      day: sunday
8
+      time: "01:00"

+ 2
- 6
.github/workflows/lint.yml 查看文件

6
 jobs:
6
 jobs:
7
   lint:
7
   lint:
8
     runs-on: ubuntu-latest
8
     runs-on: ubuntu-latest
9
-
10
     steps:
9
     steps:
11
       - uses: actions/checkout@v1
10
       - uses: actions/checkout@v1
12
-
13
       - name: Setup Node.js 14.x
11
       - name: Setup Node.js 14.x
14
         uses: actions/setup-node@v1
12
         uses: actions/setup-node@v1
15
         with:
13
         with:
16
           node-version: 14.x
14
           node-version: 14.x
17
-
18
       - name: Install dependencies
15
       - name: Install dependencies
19
-        run: yarn
20
-
16
+        run: yarn --frozen-lockfile
21
       - name: Lint
17
       - name: Lint
22
-        run: yarn lint
18
+        run: yarn test:other

+ 0
- 1
.github/workflows/publish-docker.yml 查看文件

8
 jobs:
8
 jobs:
9
   publish-docker:
9
   publish-docker:
10
     runs-on: ubuntu-latest
10
     runs-on: ubuntu-latest
11
-
12
     steps:
11
     steps:
13
       - uses: actions/checkout@v2
12
       - uses: actions/checkout@v2
14
       - uses: docker/build-push-action@v1
13
       - uses: docker/build-push-action@v1

+ 2
- 6
.github/workflows/test.yml 查看文件

6
 jobs:
6
 jobs:
7
   test:
7
   test:
8
     runs-on: ubuntu-latest
8
     runs-on: ubuntu-latest
9
-
10
     steps:
9
     steps:
11
       - uses: actions/checkout@v1
10
       - uses: actions/checkout@v1
12
-
13
       - name: Setup Node.js 14.x
11
       - name: Setup Node.js 14.x
14
         uses: actions/setup-node@v1
12
         uses: actions/setup-node@v1
15
         with:
13
         with:
16
           node-version: 14.x
14
           node-version: 14.x
17
-
18
       - name: Install dependencies
15
       - name: Install dependencies
19
-        run: yarn
20
-
16
+        run: yarn --frozen-lockfile
21
       - name: Test and Build
17
       - name: Test and Build
22
         run: |
18
         run: |
23
-          yarn test
19
+          yarn test:code
24
           yarn build
20
           yarn build

+ 15
- 6
package.json 查看文件

1
 {
1
 {
2
   "dependencies": {
2
   "dependencies": {
3
+    "@excalidraw/eslint-config": "1.0.0",
3
     "@excalidraw/prettier-config": "1.0.2",
4
     "@excalidraw/prettier-config": "1.0.2",
4
     "@types/debug": "4.1.5",
5
     "@types/debug": "4.1.5",
5
     "@types/express": "4.17.11",
6
     "@types/express": "4.17.11",
6
     "@types/node": "14.14.31",
7
     "@types/node": "14.14.31",
7
     "@types/socket.io": "2.1.4",
8
     "@types/socket.io": "2.1.4",
9
+    "@typescript-eslint/eslint-plugin": "4.16.1",
10
+    "@typescript-eslint/parser": "4.16.1",
8
     "debug": "4.3.1",
11
     "debug": "4.3.1",
12
+    "eslint": "7.21.0",
13
+    "eslint-config-prettier": "8.1.0",
14
+    "eslint-plugin-prettier": "3.3.1",
9
     "express": "4.17.1",
15
     "express": "4.17.1",
10
     "prettier": "2.2.1",
16
     "prettier": "2.2.1",
11
     "socket.io": "2.3.0",
17
     "socket.io": "2.3.0",
12
-    "ts-node-dev": "1.1.1",
13
-    "typescript": "4.1.5"
18
+    "ts-node-dev": "1.1.6",
19
+    "typescript": "4.2.2"
14
   },
20
   },
15
   "license": "MIT",
21
   "license": "MIT",
16
   "main": "dist/index.js",
22
   "main": "dist/index.js",
18
   "prettier": "@excalidraw/prettier-config",
24
   "prettier": "@excalidraw/prettier-config",
19
   "scripts": {
25
   "scripts": {
20
     "build": "tsc",
26
     "build": "tsc",
21
-    "format": "yarn prettier --write",
22
-    "lint": "yarn prettier --list-different",
23
-    "prettier": "prettier \"**/*.{ts,md,json,yaml,yml}\"",
27
+    "fix:code": "yarn test:code --fix",
28
+    "fix:other": "yarn prettier --write",
29
+    "fix": "yarn fix:other && yarn fix:code",
30
+    "prettier": "prettier . --ignore-path=.gitignore",
24
     "start": "node dist/index.js",
31
     "start": "node dist/index.js",
25
     "start:dev": "ts-node-dev --respawn --transpile-only src/index.ts",
32
     "start:dev": "ts-node-dev --respawn --transpile-only src/index.ts",
26
-    "test": "yarn lint"
33
+    "test:code": "eslint --ext .ts .",
34
+    "test:other": "yarn prettier --list-different",
35
+    "test": "yarn test:other && yarn test:code"
27
   },
36
   },
28
   "version": "1.0.0"
37
   "version": "1.0.0"
29
 }
38
 }

+ 1
- 1
src/index.ts 查看文件

23
 });
23
 });
24
 
24
 
25
 const io = socketIO(server, {
25
 const io = socketIO(server, {
26
-  handlePreflightRequest: function (req, res) {
26
+  handlePreflightRequest: (req, res) => {
27
     const headers = {
27
     const headers = {
28
       "Access-Control-Allow-Headers": "Content-Type, Authorization",
28
       "Access-Control-Allow-Headers": "Content-Type, Authorization",
29
       "Access-Control-Allow-Origin":
29
       "Access-Control-Allow-Origin":

+ 860
- 15
yarn.lock
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存