Skip to content

Commit 5423ab3

Browse files
authored
[PM-21934] Upgrade to eslint 9 (#14754)
Upgrades to Eslint v9. Since this is a major version there were breaking changes, but since we've previously migrated to flat configs in #12806 those were minimal.
1 parent 677a435 commit 5423ab3

File tree

19 files changed

+1942
-838
lines changed

19 files changed

+1942
-838
lines changed

.github/renovate.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
{
6060
matchPackageNames: [
6161
"@angular-eslint/schematics",
62+
"@eslint/compat",
6263
"@typescript-eslint/rule-tester",
6364
"@typescript-eslint/utils",
6465
"angular-eslint",
@@ -81,6 +82,7 @@
8182
{
8283
matchPackageNames: [
8384
"@angular-eslint/schematics",
85+
"@eslint/compat",
8486
"@typescript-eslint/rule-tester",
8587
"@typescript-eslint/utils",
8688
"angular-eslint",

apps/browser/src/key-management/vault-timeout/vault-timeout.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default class VaultTimeoutService extends BaseVaultTimeoutService {
1717
// setIntervals. It works by calling the native extension which sleeps for 10s,
1818
// efficiently replicating setInterval.
1919
async checkSafari() {
20-
// eslint-disable-next-line
2120
while (true) {
2221
try {
2322
await SafariApp.sendMessageToApp("sleep");

apps/browser/src/platform/popup/services/browser-router.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class BrowserRouterService {
2121
child = child.firstChild;
2222
}
2323

24+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
25+
// eslint-disable-next-line no-constant-binary-expression
2426
const updateUrl = !child?.data?.doNotSaveUrl ?? true;
2527

2628
if (updateUrl) {

apps/browser/src/platform/popup/view-cache/popup-router-cache.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class PopupRouterCacheService {
6262
child = child.firstChild;
6363
}
6464

65+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
66+
// eslint-disable-next-line no-constant-binary-expression
6567
return !child?.data?.doNotSaveUrl ?? true;
6668
}),
6769
switchMap((event) => this.push(event.url)),

apps/cli/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ export class CliUtils {
161161

162162
process.stdin.setEncoding("utf8");
163163
process.stdin.on("readable", () => {
164-
// eslint-disable-next-line
165164
while (true) {
166165
const chunk = process.stdin.read();
167166
if (chunk == null) {

apps/web/src/app/admin-console/organizations/reporting/organization-reporting-routing.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
99
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
1010
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
1111

12+
// eslint-disable-next-line no-restricted-imports
1213
import { ExposedPasswordsReportComponent } from "../../../dirt/reports/pages/organizations/exposed-passwords-report.component";
14+
// eslint-disable-next-line no-restricted-imports
1315
import { InactiveTwoFactorReportComponent } from "../../../dirt/reports/pages/organizations/inactive-two-factor-report.component";
16+
// eslint-disable-next-line no-restricted-imports
1417
import { ReusedPasswordsReportComponent } from "../../../dirt/reports/pages/organizations/reused-passwords-report.component";
18+
// eslint-disable-next-line no-restricted-imports
1519
import { UnsecuredWebsitesReportComponent } from "../../../dirt/reports/pages/organizations/unsecured-websites-report.component";
20+
// eslint-disable-next-line no-restricted-imports
1621
import { WeakPasswordsReportComponent } from "../../../dirt/reports/pages/organizations/weak-passwords-report.component";
17-
/* eslint no-restricted-imports: "error" */
1822
import { isPaidOrgGuard } from "../guards/is-paid-org.guard";
1923
import { organizationPermissionsGuard } from "../guards/org-permissions.guard";
2024
import { organizationRedirectGuard } from "../guards/org-redirect.guard";

apps/web/src/app/billing/organizations/change-plan-dialog.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
607607

608608
return (
609609
plan.PasswordManager.additionalStoragePricePerGb *
610+
// TODO: Eslint upgrade. Please resolve this since the null check does nothing
611+
// eslint-disable-next-line no-constant-binary-expression
610612
Math.abs(this.sub?.maxStorageGb ? this.sub?.maxStorageGb - 1 : 0 || 0)
611613
);
612614
}

apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
148148
paymentSource,
149149
);
150150
}
151+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
152+
// eslint-disable-next-line no-constant-binary-expression
151153
this.isUnpaid = this.subscriptionStatus === "unpaid" ?? false;
152154
// If the flag `launchPaymentModalAutomatically` is set to true,
153155
// we schedule a timeout (delay of 800ms) to automatically launch the payment modal.

apps/web/src/app/billing/shared/payment-method.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export class PaymentMethodComponent implements OnInit, OnDestroy {
143143

144144
[this.billing, this.sub] = await Promise.all([billingPromise, subPromise]);
145145
}
146+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
147+
// eslint-disable-next-line no-constant-binary-expression
146148
this.isUnpaid = this.subscription?.status === "unpaid" ?? false;
147149
this.loading = false;
148150
// If the flag `launchPaymentModalAutomatically` is set to true,

apps/web/src/app/core/router.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ export class RouterService {
7474

7575
const titleId: string = child?.snapshot?.data?.titleId;
7676
const rawTitle: string = child?.snapshot?.data?.title;
77+
78+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
79+
// eslint-disable-next-line no-constant-binary-expression
7780
const updateUrl = !child?.snapshot?.data?.doNotSaveUrl ?? true;
7881

7982
if (titleId != null || rawTitle != null) {

eslint.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
2+
import { fixupPluginRules } from "@eslint/compat";
33
import eslint from "@eslint/js";
44
import tseslint from "typescript-eslint";
55
import angular from "angular-eslint";
@@ -31,8 +31,8 @@ export default tseslint.config(
3131
reportUnusedDisableDirectives: "error",
3232
},
3333
plugins: {
34-
rxjs: rxjs,
35-
"rxjs-angular": angularRxjs,
34+
rxjs: fixupPluginRules(rxjs),
35+
"rxjs-angular": fixupPluginRules(angularRxjs),
3636
"@bitwarden/platform": platformPlugins,
3737
},
3838
languageOptions: {

libs/common/src/key-management/device-trust/services/device-trust.service.implementation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
8989
) {
9090
this.supportsDeviceTrust$ = this.userDecryptionOptionsService.userDecryptionOptions$.pipe(
9191
map((options) => {
92+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
93+
// eslint-disable-next-line no-constant-binary-expression
9294
return options?.trustedDeviceOption != null ?? false;
9395
}),
9496
);
@@ -97,6 +99,8 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
9799
supportsDeviceTrustByUserId$(userId: UserId): Observable<boolean> {
98100
return this.userDecryptionOptionsService.userDecryptionOptionsById$(userId).pipe(
99101
map((options) => {
102+
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
103+
// eslint-disable-next-line no-constant-binary-expression
100104
return options?.trustedDeviceOption != null ?? false;
101105
}),
102106
);

libs/eslint/fix-jsdom.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import JSDOMEnvironment from "jest-environment-jsdom";
2+
3+
export default class FixJSDOMEnvironment extends JSDOMEnvironment {
4+
constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) {
5+
super(...args);
6+
7+
// FIXME https://github.com/jsdom/jsdom/issues/3363
8+
this.global.structuredClone = structuredClone;
9+
}
10+
}

libs/eslint/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const sharedConfig = require("../../libs/shared/jest.config.angular");
33
/** @type {import('jest').Config} */
44
module.exports = {
55
...sharedConfig,
6+
testEnvironment: "./fix-jsdom.ts",
67
testMatch: ["**/+(*.)+(spec).+(mjs)"],
78
displayName: "libs/eslint tests",
89
preset: "jest-preset-angular",

libs/eslint/test.setup.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
import { clearImmediate, setImmediate } from "node:timers";
42

53
Object.defineProperties(globalThis, {

libs/eslint/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": "../shared/tsconfig",
33
"compilerOptions": {},
4-
"exclude": ["node_modules", "dist"]
4+
"exclude": ["node_modules", "dist"],
5+
"files": ["empty.ts"]
56
}

libs/importer/src/importers/dashlane/dashlane-csv-importer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class DashlaneCsvImporter extends BaseImporter implements Importer {
9292
this.parseIdRecord(cipher, row);
9393
}
9494

95-
if ((rowKeys[0] === "type") != null && rowKeys[1] === "title") {
95+
if (rowKeys[0] === "type" && rowKeys[1] === "title") {
9696
this.parsePersonalInformationRecord(cipher, row);
9797
}
9898

0 commit comments

Comments
 (0)