1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

Prevent banned imports into libs/common (#3599)

Also fix typescript-eslint/parser config and fix linting errors
This commit is contained in:
Thomas Rittson 2022-09-27 11:17:43 +10:00 committed by GitHub
parent 22a878792e
commit 5ffa3ccd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 11 deletions

View File

@ -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/**/*"
}
]
}
]
}
}

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";