diff --git a/.eslintrc.json b/.eslintrc.json index 3a1c197326..fae64d869e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,7 +4,7 @@ "browser": true, "webextensions": true }, - "plugins": ["@typescript-eslint", "rxjs", "rxjs-angular"], + "plugins": ["@typescript-eslint", "rxjs", "rxjs-angular", "import"], "parser": "@typescript-eslint/parser", "parserOptions": { "project": ["./tsconfig.eslint.json"], @@ -18,6 +18,16 @@ "prettier", "plugin:rxjs/recommended" ], + "settings": { + "import/parsers": { + "@typescript-eslint/parser": [".ts"] + }, + "import/resolver": { + "typescript": { + "alwaysTryTypes": true + } + } + }, "rules": { "@typescript-eslint/no-explicit-any": "off", // TODO: This should be re-enabled "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], @@ -65,6 +75,27 @@ "selector": "CallExpression[callee.name='svgIcon']" } ], - "curly": ["error", "all"] + "curly": ["error", "all"], + "import/namespace": ["off"], // This doesn't resolve namespace imports correctly, but TS will throw for this anyway + "import/no-restricted-paths": [ + "error", + { + "zones": [ + // Do not allow angular/node/electron code to be imported into common + { + "target": "./libs/common/**/*", + "from": "./libs/angular/**/*" + }, + { + "target": "./libs/common/**/*", + "from": "./libs/node/**/*" + }, + { + "target": "./libs/common/**/*", + "from": "./libs/electron/**/*" + } + ] + } + ] } } diff --git a/libs/common/spec/importers/bitwardenPasswordProtectedImporter.spec.ts b/libs/common/spec/importers/bitwardenPasswordProtectedImporter.spec.ts index 820f8db38c..67e03d030c 100644 --- a/libs/common/spec/importers/bitwardenPasswordProtectedImporter.spec.ts +++ b/libs/common/spec/importers/bitwardenPasswordProtectedImporter.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg, SubstituteOf } from "@fluffy-spoon/substitute"; +import { Substitute, Arg, SubstituteOf } from "@fluffy-spoon/substitute"; import { CryptoService } from "@bitwarden/common/abstractions/crypto.service"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; diff --git a/libs/common/spec/models/domain/cipher.spec.ts b/libs/common/spec/models/domain/cipher.spec.ts index c7c0d36714..0158945d8c 100644 --- a/libs/common/spec/models/domain/cipher.spec.ts +++ b/libs/common/spec/models/domain/cipher.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg } from "@fluffy-spoon/substitute"; +import { Substitute, Arg } from "@fluffy-spoon/substitute"; import { CipherRepromptType } from "@bitwarden/common/enums/cipherRepromptType"; import { CipherType } from "@bitwarden/common/enums/cipherType"; diff --git a/libs/common/spec/models/domain/encString.spec.ts b/libs/common/spec/models/domain/encString.spec.ts index adcfaf0706..413d091d68 100644 --- a/libs/common/spec/models/domain/encString.spec.ts +++ b/libs/common/spec/models/domain/encString.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg } from "@fluffy-spoon/substitute"; +import { Substitute, Arg } from "@fluffy-spoon/substitute"; import { mock, MockProxy } from "jest-mock-extended"; import { AbstractEncryptService } from "@bitwarden/common/abstractions/abstractEncrypt.service"; diff --git a/libs/common/spec/models/domain/login.spec.ts b/libs/common/spec/models/domain/login.spec.ts index 6021a4b290..b2235e7583 100644 --- a/libs/common/spec/models/domain/login.spec.ts +++ b/libs/common/spec/models/domain/login.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg } from "@fluffy-spoon/substitute"; +import { Substitute, Arg } from "@fluffy-spoon/substitute"; import { UriMatchType } from "@bitwarden/common/enums/uriMatchType"; import { LoginData } from "@bitwarden/common/models/data/loginData"; diff --git a/libs/common/spec/models/domain/send.spec.ts b/libs/common/spec/models/domain/send.spec.ts index 575821abc9..903043f86c 100644 --- a/libs/common/spec/models/domain/send.spec.ts +++ b/libs/common/spec/models/domain/send.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg, SubstituteOf } from "@fluffy-spoon/substitute"; +import { Substitute, Arg, SubstituteOf } from "@fluffy-spoon/substitute"; import { AbstractEncryptService } from "@bitwarden/common/abstractions/abstractEncrypt.service"; import { CryptoService } from "@bitwarden/common/abstractions/crypto.service"; diff --git a/libs/common/spec/models/domain/sendAccess.spec.ts b/libs/common/spec/models/domain/sendAccess.spec.ts index 7772fe428a..32b01d13fd 100644 --- a/libs/common/spec/models/domain/sendAccess.spec.ts +++ b/libs/common/spec/models/domain/sendAccess.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg } from "@fluffy-spoon/substitute"; +import { Substitute, Arg } from "@fluffy-spoon/substitute"; import { SendType } from "@bitwarden/common/enums/sendType"; import { SendAccess } from "@bitwarden/common/models/domain/sendAccess"; diff --git a/libs/common/spec/services/import.service.spec.ts b/libs/common/spec/services/import.service.spec.ts index 654c1b6124..2b47518bc5 100644 --- a/libs/common/spec/services/import.service.spec.ts +++ b/libs/common/spec/services/import.service.spec.ts @@ -1,4 +1,4 @@ -import Substitute, { SubstituteOf } from "@fluffy-spoon/substitute"; +import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { CipherService } from "@bitwarden/common/abstractions/cipher.service"; diff --git a/libs/common/spec/utils.ts b/libs/common/spec/utils.ts index 0ea16b4d72..4f9dc4076f 100644 --- a/libs/common/spec/utils.ts +++ b/libs/common/spec/utils.ts @@ -1,4 +1,4 @@ -import Substitute, { Arg } from "@fluffy-spoon/substitute"; +import { Substitute, Arg } from "@fluffy-spoon/substitute"; import { EncString } from "@bitwarden/common/models/domain/encString"; diff --git a/libs/common/spec/web/services/webCryptoFunction.service.spec.ts b/libs/common/spec/web/services/webCryptoFunction.service.spec.ts index 964364a1fa..ce131472d4 100644 --- a/libs/common/spec/web/services/webCryptoFunction.service.spec.ts +++ b/libs/common/spec/web/services/webCryptoFunction.service.spec.ts @@ -1,4 +1,4 @@ -import Substitute from "@fluffy-spoon/substitute"; +import { Substitute } from "@fluffy-spoon/substitute"; import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service"; import { Utils } from "@bitwarden/common/misc/utils";