From 6c9c84090efd68c612fbc679746b9b9cc9e26222 Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 8 Dec 2021 05:39:01 +0800 Subject: [PATCH] chore: replace eslint-import-resolver-alias with eslint-import-resolver-typescript (#4546) Co-authored-by: Joe Previte --- .eslintrc.yaml | 9 +++----- package.json | 2 +- src/node/http.ts | 2 +- src/node/routes/pathProxy.ts | 2 +- src/node/wsRouter.ts | 1 + test/unit/node/proxy.test.ts | 2 +- test/unit/node/test-plugin/.eslintrc.js | 9 ++++++++ test/unit/node/test-plugin/.eslintrc.yaml | 5 ---- yarn.lock | 28 +++++++++++++++++++---- 9 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 test/unit/node/test-plugin/.eslintrc.js delete mode 100644 test/unit/node/test-plugin/.eslintrc.yaml diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b579a9a24..1bbbbd09e 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -36,11 +36,8 @@ rules: import/order: [error, { alphabetize: { order: "asc" }, groups: [["builtin", "external", "internal"], "parent", "sibling"] }] no-async-promise-executor: off - # This isn't a real module, just types, which apparently doesn't resolve. - import/no-unresolved: [error, { ignore: ["express-serve-static-core"] }] settings: - # Does not work with CommonJS unfortunately. - import/ignore: - - env-paths - - xdg-basedir + import/resolver: + typescript: + alwaysTryTypes: true diff --git a/package.json b/package.json index 92fe003cc..b031fbd4c 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "doctoc": "^2.0.0", "eslint": "^7.7.0", "eslint-config-prettier": "^8.1.0", - "eslint-import-resolver-alias": "^1.1.2", + "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-prettier": "^4.0.0", "prettier": "^2.2.1", diff --git a/src/node/http.ts b/src/node/http.ts index 09f472ba9..1719aaba1 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -4,7 +4,7 @@ import * as expressCore from "express-serve-static-core" import * as http from "http" import * as net from "net" import path from "path" -import qs from "qs" +import * as qs from "qs" import { Disposable } from "../common/emitter" import { CookieKeys, HttpCode, HttpError } from "../common/http" import { normalize } from "../common/util" diff --git a/src/node/routes/pathProxy.ts b/src/node/routes/pathProxy.ts index e32001743..5f4e9776d 100644 --- a/src/node/routes/pathProxy.ts +++ b/src/node/routes/pathProxy.ts @@ -1,6 +1,6 @@ import { Request, Response } from "express" import * as path from "path" -import qs from "qs" +import * as qs from "qs" import * as pluginapi from "../../../typings/pluginapi" import { HttpCode, HttpError } from "../../common/http" import { normalize } from "../../common/util" diff --git a/src/node/wsRouter.ts b/src/node/wsRouter.ts index d829d0821..0c60a5fa8 100644 --- a/src/node/wsRouter.ts +++ b/src/node/wsRouter.ts @@ -50,4 +50,5 @@ export function Router(): WebsocketRouter { return new WebsocketRouter() } +// eslint-disable-next-line import/no-named-as-default-member -- the typings are not updated correctly export const wss = new Websocket.Server({ noServer: true }) diff --git a/test/unit/node/proxy.test.ts b/test/unit/node/proxy.test.ts index 0861bfe84..55ea43672 100644 --- a/test/unit/node/proxy.test.ts +++ b/test/unit/node/proxy.test.ts @@ -1,4 +1,4 @@ -import bodyParser from "body-parser" +import * as bodyParser from "body-parser" import * as express from "express" import * as http from "http" import nodeFetch from "node-fetch" diff --git a/test/unit/node/test-plugin/.eslintrc.js b/test/unit/node/test-plugin/.eslintrc.js new file mode 100644 index 000000000..399941910 --- /dev/null +++ b/test/unit/node/test-plugin/.eslintrc.js @@ -0,0 +1,9 @@ +module.exports = { + settings: { + "import/resolver": { + typescript: { + project: __dirname, + }, + }, + }, +} diff --git a/test/unit/node/test-plugin/.eslintrc.yaml b/test/unit/node/test-plugin/.eslintrc.yaml deleted file mode 100644 index 67a20fa64..000000000 --- a/test/unit/node/test-plugin/.eslintrc.yaml +++ /dev/null @@ -1,5 +0,0 @@ -settings: - import/resolver: - alias: - map: - - [code-server, ./typings/pluginapi.d.ts] diff --git a/yarn.lock b/yarn.lock index 2e74db61a..0fafa4c90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1530,11 +1530,6 @@ eslint-config-prettier@^8.1.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== -eslint-import-resolver-alias@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-alias/-/eslint-import-resolver-alias-1.1.2.tgz#297062890e31e4d6651eb5eba9534e1f6e68fc97" - integrity sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w== - eslint-import-resolver-node@^0.3.4: version "0.3.4" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" @@ -1543,6 +1538,17 @@ eslint-import-resolver-node@^0.3.4: debug "^2.6.9" resolve "^1.13.1" +eslint-import-resolver-typescript@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz#07661966b272d14ba97f597b51e1a588f9722f0a" + integrity sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ== + dependencies: + debug "^4.3.1" + glob "^7.1.7" + is-glob "^4.0.1" + resolve "^1.20.0" + tsconfig-paths "^3.9.0" + eslint-module-utils@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz#b51be1e473dd0de1c5ea638e22429c2490ea8233" @@ -2036,6 +2042,18 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.1.7: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + global-modules@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-2.0.0.tgz#997605ad2345f27f51539bea26574421215c7780"