2022-05-03 21:45:37 +02:00
|
|
|
{
|
|
|
|
"root": true,
|
|
|
|
"env": {
|
|
|
|
"browser": true,
|
|
|
|
"webextensions": true
|
|
|
|
},
|
2023-01-31 18:39:10 +01:00
|
|
|
"overrides": [
|
|
|
|
{
|
|
|
|
"files": ["*.ts", "*.js"],
|
|
|
|
"plugins": ["@typescript-eslint", "rxjs", "rxjs-angular", "import"],
|
|
|
|
"parser": "@typescript-eslint/parser",
|
|
|
|
"parserOptions": {
|
|
|
|
"project": ["./tsconfig.eslint.json"],
|
|
|
|
"sourceType": "module",
|
|
|
|
"ecmaVersion": 2020
|
|
|
|
},
|
|
|
|
"extends": [
|
|
|
|
"eslint:recommended",
|
2024-08-02 19:59:38 +02:00
|
|
|
"plugin:@angular-eslint/recommended",
|
2023-01-31 18:39:10 +01:00
|
|
|
"plugin:@typescript-eslint/recommended",
|
|
|
|
"plugin:import/recommended",
|
|
|
|
"plugin:import/typescript",
|
2023-08-15 19:25:51 +02:00
|
|
|
"plugin:rxjs/recommended",
|
2024-08-02 19:59:38 +02:00
|
|
|
"prettier",
|
2023-08-15 19:25:51 +02:00
|
|
|
"plugin:storybook/recommended"
|
2023-01-31 18:39:10 +01:00
|
|
|
],
|
|
|
|
"settings": {
|
|
|
|
"import/parsers": {
|
|
|
|
"@typescript-eslint/parser": [".ts"]
|
2022-05-03 21:45:37 +02:00
|
|
|
},
|
2023-01-31 18:39:10 +01:00
|
|
|
"import/resolver": {
|
|
|
|
"typescript": {
|
|
|
|
"alwaysTryTypes": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"rules": {
|
2024-08-02 19:59:38 +02:00
|
|
|
"@angular-eslint/component-class-suffix": 0,
|
|
|
|
"@angular-eslint/contextual-lifecycle": 0,
|
|
|
|
"@angular-eslint/directive-class-suffix": 0,
|
|
|
|
"@angular-eslint/no-empty-lifecycle-method": 0,
|
|
|
|
"@angular-eslint/no-host-metadata-property": 0,
|
|
|
|
"@angular-eslint/no-input-rename": 0,
|
|
|
|
"@angular-eslint/no-inputs-metadata-property": 0,
|
|
|
|
"@angular-eslint/no-output-native": 0,
|
|
|
|
"@angular-eslint/no-output-on-prefix": 0,
|
|
|
|
"@angular-eslint/no-output-rename": 0,
|
|
|
|
"@angular-eslint/no-outputs-metadata-property": 0,
|
|
|
|
"@angular-eslint/use-lifecycle-interface": "error",
|
|
|
|
"@angular-eslint/use-pipe-transform-interface": 0,
|
2023-01-31 18:39:10 +01:00
|
|
|
"@typescript-eslint/explicit-member-accessibility": [
|
|
|
|
"error",
|
2023-09-26 23:07:22 +02:00
|
|
|
{ "accessibility": "no-public" }
|
2022-05-03 21:45:37 +02:00
|
|
|
],
|
2023-09-26 23:07:22 +02:00
|
|
|
"@typescript-eslint/no-explicit-any": "off", // TODO: This should be re-enabled
|
2024-02-02 21:13:37 +01:00
|
|
|
"@typescript-eslint/no-floating-promises": "error",
|
2023-09-26 23:07:22 +02:00
|
|
|
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
|
|
|
|
"@typescript-eslint/no-this-alias": ["error", { "allowedNames": ["self"] }],
|
|
|
|
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
2023-01-31 18:39:10 +01:00
|
|
|
"no-console": "error",
|
|
|
|
"import/no-unresolved": "off", // TODO: Look into turning off once each package is an actual package.
|
|
|
|
"import/order": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
"alphabetize": {
|
|
|
|
"order": "asc"
|
|
|
|
},
|
|
|
|
"newlines-between": "always",
|
|
|
|
"pathGroups": [
|
|
|
|
{
|
|
|
|
"pattern": "@bitwarden/**",
|
|
|
|
"group": "external",
|
|
|
|
"position": "after"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"pattern": "src/**/*",
|
|
|
|
"group": "parent",
|
|
|
|
"position": "before"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"pathGroupsExcludedImportTypes": ["builtin"]
|
|
|
|
}
|
|
|
|
],
|
2024-03-21 17:09:44 +01:00
|
|
|
"rxjs-angular/prefer-takeuntil": ["error", { "alias": ["takeUntilDestroyed"] }],
|
2023-01-31 18:39:10 +01:00
|
|
|
"rxjs/no-exposed-subjects": ["error", { "allowProtected": true }],
|
|
|
|
"no-restricted-syntax": [
|
|
|
|
"error",
|
2022-09-27 03:17:43 +02:00
|
|
|
{
|
2023-01-31 18:39:10 +01:00
|
|
|
"message": "Calling `svgIcon` directly is not allowed",
|
|
|
|
"selector": "CallExpression[callee.name='svgIcon']"
|
2022-09-27 03:17:43 +02:00
|
|
|
},
|
|
|
|
{
|
2023-01-31 18:39:10 +01:00
|
|
|
"message": "Accessing FormGroup using `get` is not allowed, use `.value` instead",
|
|
|
|
"selector": "ChainExpression[expression.object.callee.property.name='get'][expression.property.name='value']"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"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": [
|
2024-08-14 20:24:29 +02:00
|
|
|
{
|
|
|
|
"target": ["libs/**/*"],
|
|
|
|
"from": ["apps/**/*"],
|
|
|
|
"message": "Libs should not import app-specific code."
|
|
|
|
},
|
2023-01-31 18:39:10 +01:00
|
|
|
{
|
2023-06-13 02:03:32 +02:00
|
|
|
// avoid specific frameworks or large dependencies in common
|
2023-01-31 18:39:10 +01:00
|
|
|
"target": "./libs/common/**/*",
|
2023-06-13 02:03:32 +02:00
|
|
|
"from": [
|
|
|
|
// Angular
|
|
|
|
"./libs/angular/**/*",
|
|
|
|
"./node_modules/@angular*/**/*",
|
|
|
|
|
|
|
|
// Node
|
|
|
|
"./libs/node/**/*",
|
|
|
|
|
2024-05-30 21:38:31 +02:00
|
|
|
//Generator
|
|
|
|
"./libs/tools/generator/components/**/*",
|
|
|
|
"./libs/tools/generator/core/**/*",
|
|
|
|
"./libs/tools/generator/extensions/**/*",
|
|
|
|
|
2023-06-13 02:03:32 +02:00
|
|
|
// Import/export
|
|
|
|
"./libs/importer/**/*",
|
2024-02-13 20:22:37 +01:00
|
|
|
"./libs/tools/export/vault-export/vault-export-core/**/*"
|
2023-06-13 02:03:32 +02:00
|
|
|
]
|
2023-11-09 23:06:42 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// avoid import of unexported state objects
|
|
|
|
"target": [
|
|
|
|
"!(libs)/**/*",
|
|
|
|
"libs/!(common)/**/*",
|
|
|
|
"libs/common/!(src)/**/*",
|
|
|
|
"libs/common/src/!(platform)/**/*",
|
|
|
|
"libs/common/src/platform/!(state)/**/*"
|
|
|
|
],
|
|
|
|
"from": ["./libs/common/src/platform/state/**/*"],
|
|
|
|
// allow module index import
|
|
|
|
"except": ["**/state/index.ts"]
|
2023-01-31 18:39:10 +01:00
|
|
|
}
|
|
|
|
]
|
2022-09-27 03:17:43 +02:00
|
|
|
}
|
2023-01-31 18:39:10 +01:00
|
|
|
],
|
2023-10-17 19:02:33 +02:00
|
|
|
"no-restricted-imports": ["error", { "patterns": ["src/**/*"] }]
|
2022-09-27 03:17:43 +02:00
|
|
|
}
|
2023-01-31 18:39:10 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["*.html"],
|
|
|
|
"parser": "@angular-eslint/template-parser",
|
2023-02-02 22:27:08 +01:00
|
|
|
"plugins": ["@angular-eslint/template", "tailwindcss"],
|
2023-01-31 18:39:10 +01:00
|
|
|
"rules": {
|
2023-02-02 22:27:08 +01:00
|
|
|
"@angular-eslint/template/button-has-type": "error",
|
|
|
|
"tailwindcss/no-custom-classname": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
// uses negative lookahead to whitelist any class that doesn't start with "tw-"
|
|
|
|
// in other words: classnames that start with tw- must be valid TailwindCSS classes
|
|
|
|
"whitelist": ["(?!(tw)\\-).*"]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"tailwindcss/enforces-negative-arbitrary-values": "error",
|
|
|
|
"tailwindcss/enforces-shorthand": "error",
|
|
|
|
"tailwindcss/no-contradicting-classname": "error"
|
2023-01-31 18:39:10 +01:00
|
|
|
}
|
|
|
|
},
|
2023-12-15 15:02:21 +01:00
|
|
|
{
|
|
|
|
"files": ["libs/admin-console/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/admin-console/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2022-09-29 16:38:50 +02:00
|
|
|
{
|
2023-08-08 15:37:25 +02:00
|
|
|
"files": ["libs/angular/src/**/*.ts"],
|
2022-09-29 16:38:50 +02:00
|
|
|
"rules": {
|
2023-08-08 15:37:25 +02:00
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
|
2022-09-29 16:38:50 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-08-08 15:37:25 +02:00
|
|
|
"files": ["libs/auth/src/**/*.ts"],
|
2022-09-29 16:38:50 +02:00
|
|
|
"rules": {
|
2023-08-08 15:37:25 +02:00
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/auth/*", "src/**/*"] }]
|
2022-09-29 16:38:50 +02:00
|
|
|
}
|
|
|
|
},
|
2023-12-15 15:02:21 +01:00
|
|
|
{
|
|
|
|
"files": ["libs/billing/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/billing/*", "src/**/*"] }]
|
|
|
|
}
|
|
|
|
},
|
2022-09-29 16:38:50 +02:00
|
|
|
{
|
2023-08-08 15:37:25 +02:00
|
|
|
"files": ["libs/common/src/**/*.ts"],
|
2022-09-29 16:38:50 +02:00
|
|
|
"rules": {
|
2023-08-08 15:37:25 +02:00
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/common/*", "src/**/*"] }]
|
2022-09-29 16:38:50 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-08-08 15:37:25 +02:00
|
|
|
"files": ["libs/components/src/**/*.ts"],
|
2022-09-29 16:38:50 +02:00
|
|
|
"rules": {
|
2023-08-16 14:26:56 +02:00
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/components/*", "src/**/*", "@bitwarden/angular/*"] }
|
|
|
|
]
|
2023-08-08 15:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
2024-05-30 21:38:31 +02:00
|
|
|
{
|
|
|
|
"files": ["libs/tools/generator/components/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/generator-components/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["libs/tools/generator/core/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/generator-core/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-06-20 16:49:23 +02:00
|
|
|
"files": ["libs/tools/generator/extensions/history/src/**/*.ts"],
|
2024-05-30 21:38:31 +02:00
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
2024-06-20 16:49:23 +02:00
|
|
|
{ "patterns": ["@bitwarden/generator-history/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["libs/tools/generator/extensions/legacy/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/generator-legacy/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["libs/tools/generator/extensions/navigation/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/generator-navigation/*", "src/**/*"] }
|
2024-05-30 21:38:31 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2023-08-08 15:37:25 +02:00
|
|
|
{
|
2024-02-13 20:22:37 +01:00
|
|
|
"files": ["libs/tools/export/vault-export/vault-export-core/src/**/*.ts"],
|
2023-08-08 15:37:25 +02:00
|
|
|
"rules": {
|
2024-02-13 20:22:37 +01:00
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/vault-export-core/*", "src/**/*"] }
|
|
|
|
]
|
2022-09-29 16:38:50 +02:00
|
|
|
}
|
2023-03-23 11:43:27 +01:00
|
|
|
},
|
2024-03-20 23:11:57 +01:00
|
|
|
{
|
|
|
|
"files": ["libs/tools/export/vault-export/vault-export-ui/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{ "patterns": ["@bitwarden/vault-export-ui/*", "src/**/*"] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2023-03-23 11:43:27 +01:00
|
|
|
{
|
|
|
|
"files": ["libs/importer/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/importer/*", "src/**/*"] }]
|
|
|
|
}
|
2023-04-19 11:30:46 +02:00
|
|
|
},
|
|
|
|
{
|
2023-08-08 15:37:25 +02:00
|
|
|
"files": ["libs/node/src/**/*.ts"],
|
2023-04-19 11:30:46 +02:00
|
|
|
"rules": {
|
2023-08-08 15:37:25 +02:00
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
|
2023-04-19 11:30:46 +02:00
|
|
|
}
|
2023-08-22 16:02:48 +02:00
|
|
|
},
|
2023-12-15 15:02:21 +01:00
|
|
|
{
|
|
|
|
"files": ["libs/platform/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/platform/*", "src/**/*"] }]
|
|
|
|
}
|
|
|
|
},
|
2024-05-29 12:26:40 +02:00
|
|
|
{
|
|
|
|
"files": ["libs/tools/send/send-ui/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/send-ui/*", "src/**/*"] }]
|
|
|
|
}
|
|
|
|
},
|
2024-10-11 23:00:45 +02:00
|
|
|
{
|
|
|
|
"files": ["libs/tools/card/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/tools-card/*", "src/**/*"] }]
|
|
|
|
}
|
|
|
|
},
|
2023-08-22 16:02:48 +02:00
|
|
|
{
|
|
|
|
"files": ["libs/vault/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/vault/*", "src/**/*"] }]
|
|
|
|
}
|
2023-10-10 19:13:50 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["apps/browser/src/**/*.ts", "libs/**/*.ts"],
|
2023-11-09 23:06:42 +01:00
|
|
|
"excludedFiles": [
|
|
|
|
"apps/browser/src/autofill/{content,notification}/**/*.ts",
|
|
|
|
"apps/browser/src/**/background/**/*.ts", // It's okay to have long lived listeners in the background
|
|
|
|
"apps/browser/src/platform/background.ts"
|
|
|
|
],
|
2023-10-10 19:13:50 +02:00
|
|
|
"rules": {
|
|
|
|
"no-restricted-syntax": [
|
|
|
|
"error",
|
|
|
|
{
|
2023-11-09 23:06:42 +01:00
|
|
|
"message": "Using addListener in the browser popup produces a memory leak in Safari, use `BrowserApi.addListener` instead",
|
|
|
|
// This selector covers events like chrome.storage.onChange & chrome.runtime.onMessage
|
|
|
|
"selector": "CallExpression > [object.object.object.name='chrome'][property.name='addListener']"
|
2023-10-10 19:13:50 +02:00
|
|
|
},
|
|
|
|
{
|
2023-11-09 23:06:42 +01:00
|
|
|
"message": "Using addListener in the browser popup produces a memory leak in Safari, use `BrowserApi.addListener` instead",
|
|
|
|
// This selector covers events like chrome.storage.local.onChange
|
|
|
|
"selector": "CallExpression > [object.object.object.object.name='chrome'][property.name='addListener']"
|
2023-10-10 19:13:50 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-04-19 21:02:40 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["**/*.ts"],
|
|
|
|
"excludedFiles": ["**/platform/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
"patterns": [
|
|
|
|
"**/platform/**/internal", // General internal pattern
|
|
|
|
// All features that have been converted to barrel files
|
|
|
|
"**/platform/messaging/**"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-05-20 12:18:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["bitwarden_license/bit-common/src/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/bit-common/*", "src/**/*"] }]
|
|
|
|
}
|
2024-06-25 21:45:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["apps/**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
// Catches static imports
|
|
|
|
"no-restricted-imports": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
"patterns": ["biwarden_license/**", "@bitwarden/bit-common/*", "@bitwarden/bit-web/*"]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
// Catches dynamic imports, e.g. in routing modules where modules are lazy-loaded
|
|
|
|
"no-restricted-syntax": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
"message": "Don't import Bitwarden licensed code into OSS code.",
|
|
|
|
"selector": "ImportExpression > Literal.source[value=/.*(bitwarden_license|bit-common|bit-web).*/]"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-09-29 16:38:50 +02:00
|
|
|
}
|
|
|
|
]
|
2022-05-03 21:45:37 +02:00
|
|
|
}
|