From be22fcb87d163e3e847a1296c44181c4d9b63242 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jul 2021 14:31:03 +0800 Subject: [PATCH 1/6] Fix: Bump ES version in ESlint config --- .eslintrc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3a699223a..8ef64ed1a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,6 +3,7 @@ module.exports = { browser: true, commonjs: true, es2017: true, + es11: true, node: true, }, extends: [ @@ -10,7 +11,7 @@ module.exports = { "plugin:vue/vue3-recommended", ], parserOptions: { - ecmaVersion: 2018, + ecmaVersion: 2020, sourceType: "module", }, rules: { From b91e9ddb7af81a03de78c9714e1383f969fd98a3 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jul 2021 19:23:10 +0800 Subject: [PATCH 2/6] Fix: Add babel-eslint --- .eslintrc.js | 5 ++--- package-lock.json | 22 ++++++++++++++++++++++ package.json | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8ef64ed1a..9c8779a98 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,16 +2,15 @@ module.exports = { env: { browser: true, commonjs: true, - es2017: true, - es11: true, + es2020: true, node: true, }, extends: [ "eslint:recommended", "plugin:vue/vue3-recommended", ], + parser: "babel-eslint", parserOptions: { - ecmaVersion: 2020, sourceType: "module", }, rules: { diff --git a/package-lock.json b/package-lock.json index 810fe3059..01e0e1385 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1241,6 +1241,28 @@ "follow-redirects": "^1.10.0" } }, + "babel-eslint": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", + "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0", + "eslint-visitor-keys": "^1.0.0", + "resolve": "^1.12.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + } + } + }, "babel-plugin-add-module-exports": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz", diff --git a/package.json b/package.json index 4d6a0fb6e..000e5c94a 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@vitejs/plugin-legacy": "^1.5.0", "@vitejs/plugin-vue": "^1.3.0", "@vue/compiler-sfc": "^3.1.5", + "babel-eslint": "^10.1.0", "core-js": "^3.15.2", "eslint": "^7.31.0", "eslint-plugin-vue": "^7.14.0", From 1006b37a6781cd174baab2b6b4873ddfa3727ffd Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jul 2021 19:33:45 +0800 Subject: [PATCH 3/6] Fix: Add fix for babel-eslist --- .eslintrc.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9c8779a98..426d53154 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,7 +17,14 @@ module.exports = { // override/add rules settings here, such as: // 'vue/no-unused-vars': 'error' "no-unused-vars": "warn", - indent: ["error", 4], + indent: [ + "error", + 4, + { + ignoredNodes: ["TemplateLiteral"], + SwitchCase: 1, + }, + ], quotes: ["warn", "double"], //semi: ['off', 'never'], "vue/html-indent": ["warn", 4], // default: 2 From 47b19ea2f27edfb1994aa1b8fff3df2f54b8a664 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Fri, 30 Jul 2021 12:24:46 +0800 Subject: [PATCH 4/6] ESLint: fix file --- server/database.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/database.js b/server/database.js index bde0c2792..ab7340413 100644 --- a/server/database.js +++ b/server/database.js @@ -1,8 +1,9 @@ const fs = require("fs"); -const {sleep} = require("../src/util"); -const {R} = require("redbean-node"); -const {setSetting, setting} = require("./util-server"); - +const { sleep } = require("../src/util"); +const { R } = require("redbean-node"); +const { + setSetting, setting, +} = require("./util-server"); class Database { @@ -95,11 +96,11 @@ class Database { const listener = (reason, p) => { Database.noReject = false; }; - process.addListener('unhandledRejection', listener); + process.addListener("unhandledRejection", listener); console.log("Closing DB") - while (true) { + for (;;) { Database.noReject = true; await R.close() await sleep(2000) @@ -112,7 +113,7 @@ class Database { } console.log("SQLite closed") - process.removeListener('unhandledRejection', listener); + process.removeListener("unhandledRejection", listener); } } From cdaa0a54a454a1a65eebac5182acef68c0fedff5 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Fri, 30 Jul 2021 12:27:54 +0800 Subject: [PATCH 5/6] Fix: use new version of babel-eslint-parser --- .eslintrc.js | 3 ++- package-lock.json | 41 +++++++++++++++++++---------------------- package.json | 2 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 426d53154..14dbe41fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,9 +9,10 @@ module.exports = { "eslint:recommended", "plugin:vue/vue3-recommended", ], - parser: "babel-eslint", + parser: "@babel/eslint-parser", parserOptions: { sourceType: "module", + requireConfigFile: false, }, rules: { // override/add rules settings here, such as: diff --git a/package-lock.json b/package-lock.json index 01e0e1385..c62dc8eed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -96,6 +96,25 @@ } } }, + "@babel/eslint-parser": { + "version": "7.14.7", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.14.7.tgz", + "integrity": "sha512-6WPwZqO5priAGIwV6msJcdc9TsEPzYeYdS/Xuoap+/ihkgN6dzHp2bcAAwyWZ5bLzk0vvjDmKvRwkqNaiJ8BiQ==", + "dev": true, + "requires": { + "eslint-scope": "^5.1.1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@babel/generator": { "version": "7.14.8", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.8.tgz", @@ -1241,28 +1260,6 @@ "follow-redirects": "^1.10.0" } }, - "babel-eslint": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", - "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/traverse": "^7.7.0", - "@babel/types": "^7.7.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, "babel-plugin-add-module-exports": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz", diff --git a/package.json b/package.json index 000e5c94a..7b80ae39b 100644 --- a/package.json +++ b/package.json @@ -56,11 +56,11 @@ "vue-toastification": "^2.0.0-rc.1" }, "devDependencies": { + "@babel/eslint-parser": "^7.13.10", "@types/bootstrap": "^5.0.17", "@vitejs/plugin-legacy": "^1.5.0", "@vitejs/plugin-vue": "^1.3.0", "@vue/compiler-sfc": "^3.1.5", - "babel-eslint": "^10.1.0", "core-js": "^3.15.2", "eslint": "^7.31.0", "eslint-plugin-vue": "^7.14.0", From e0320729006baf24a165b0b715477d29f29c0d9b Mon Sep 17 00:00:00 2001 From: LouisLam Date: Fri, 30 Jul 2021 15:13:51 +0800 Subject: [PATCH 6/6] eslint: allow while (true) --- .eslintrc.js | 3 +++ server/database.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 14dbe41fd..3283fa5a5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -61,6 +61,9 @@ module.exports = { "space-infix-ops": "warn", "arrow-spacing": "warn", "no-trailing-spaces": "warn", + "no-constant-condition": ["error", { + "checkLoops": false, + }], "space-before-blocks": "warn", //'no-console': 'warn', "no-extra-boolean-cast": "off", diff --git a/server/database.js b/server/database.js index ab7340413..571313bc4 100644 --- a/server/database.js +++ b/server/database.js @@ -100,7 +100,7 @@ class Database { console.log("Closing DB") - for (;;) { + while (true) { Database.noReject = true; await R.close() await sleep(2000)