Resolve linting errors after updating lint deps

This commit is contained in:
Vincent 2023-09-25 12:09:40 +02:00
Родитель 1c872d62bc
Коммит f0aa942442
Не найден ключ, соответствующий данной подписи
9 изменённых файлов: 40 добавлений и 11 удалений

Просмотреть файл

@ -28,6 +28,7 @@
" This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. ",
2
],
"jsdoc/tag-lines": ["error", "any", { "startLines": 1 }],
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-param-description": "off",
@ -105,6 +106,9 @@
// (i.e. the code inside `(nextjs_migration)`),
// to avoid a barrage of warnings for older code:
"files": ["**/*.{ts,tsx}"],
"excludedFiles": [
"./src/app/(nextjs_migration)/**/*"
],
"extends": [
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],

Просмотреть файл

@ -94,11 +94,11 @@ export async function POST(req: NextRequest) {
// Leaving the `async` for now because of the commented-out `await`:
// eslint-disable-next-line @typescript-eslint/require-await
async function sendTestNotification(req: NextRequest, res: NextResponse) {
async function sendTestNotification(_req: NextRequest, _res: NextResponse) {
// The test breach notification can be viewed in the public Mailinator inbox
// as documented in the README:
// https://github.com/mozilla/blurts-server#trigger-breach-alert-email
const breachNotificationData = {
const _breachNotificationData = {
breachName: "Adobe",
// Hash for dummy email `localmonitor20200827@mailinator.com`
hashPrefix: "365050",

Просмотреть файл

@ -75,7 +75,7 @@ export default async function UserBreaches() {
// `(authenticated)/layout.tsx` ensures that `session` is not undefined,
// so the type assertion should be safe:
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
user: session!.user as any,
user: session!.user,
options: {
countryCode: getCountryCode(headerList),
},

Просмотреть файл

@ -165,6 +165,9 @@ export default async function Settings() {
sha1: session.user.subscriber.primary_sha1,
primary: true,
verified: true,
// This is old code that mixed objects with different structure in the same
// array, hence the need to assert `any`:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
const breachCounts = new Map();

Просмотреть файл

@ -297,7 +297,7 @@ function getSortedDataClasses(
breach: HibpLikeDbBreach,
isUserBrowserFirefox = false,
isUserLocaleEnUs = false,
isUserLocalEn = false,
_isUserLocalEn = false,
changePWLink = false
) {
const l10n = getL10n();

Просмотреть файл

@ -39,7 +39,7 @@ export interface UserInfo {
export async function POST(
req: NextRequest
): Promise<NextResponse<WelcomeScanBody | unknown>> {
): Promise<NextResponse<WelcomeScanBody> | NextResponse<unknown>> {
const session = await getServerSession(authOptions);
if (!session?.user?.subscriber) {
throw new Error("No session");

Просмотреть файл

@ -35,7 +35,7 @@ export interface ScanProgressBody {
// @see the onerep-events route and https://docs.onerep.com/#section/Webhooks-Endpoints
export async function GET(
_req: NextRequest
): Promise<NextResponse<ScanProgressBody | unknown>> {
): Promise<NextResponse<ScanProgressBody> | NextResponse<unknown>> {
const session = await getServerSession(authOptions);
if (typeof session?.user?.email === "string") {
try {

Просмотреть файл

@ -89,6 +89,8 @@ const breachResolutionDataTypes = {
* @param options
* @returns {*} void
*/
// Old untyped code, adding type defitions now isn't worth the effort:
/* eslint-disable @typescript-eslint/no-explicit-any */
function appendBreachResolutionChecklist(
userBreachData: any,
options: Partial<{ countryCode: string }> = {}
@ -131,6 +133,7 @@ function appendBreachResolutionChecklist(
});
}
}
/* eslint-enable @typescript-eslint/no-explicit-any */
/**
* Get a subset of the breach resolution data types map
@ -143,6 +146,8 @@ function appendBreachResolutionChecklist(
* @param {{ countryCode: string }} options
* @returns map of relevant breach resolution recommendations
*/
// Old untyped code, adding type defitions now isn't worth the effort:
/* eslint-disable @typescript-eslint/no-explicit-any */
function getResolutionRecsPerBreach(
dataTypes: any[],
args: { companyName: string; breachedCompanyLink: string },
@ -184,6 +189,7 @@ function getResolutionRecsPerBreach(
// loop through the breach recs
return filteredBreachRecs;
}
/* eslint-enable @typescript-eslint/no-explicit-any */
/**
* Get the fluent string for the body
@ -192,6 +198,8 @@ function getResolutionRecsPerBreach(
* @param args
* @returns body string
*/
// Old untyped code, adding type defitions now isn't worth the effort:
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function getBodyMessage(body: string, args: any): string {
const l10n = getL10n();
const { stringArgs } = args;
@ -207,6 +215,8 @@ function getBodyMessage(body: string, args: any): string {
}
// find fluent text based on fluent ids
// Old untyped code, adding type defitions now isn't worth the effort:
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function getRecommendationFromResolution(resolution: any, args: any) {
const l10n = getL10n();
const [resolutionType, resolutionContent] = resolution;
@ -224,6 +234,8 @@ function getRecommendationFromResolution(resolution: any, args: any) {
* @param originalDataTypes breach DataTypes array from HIBP
* @returns filtered breach data types
*/
// Old untyped code, adding type defitions now isn't worth the effort:
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function filterBreachDataTypes(originalDataTypes: any[]) {
const relevantDataTypes = Object.values(BreachDataTypes);
// This function predates proper use of TypeScript, so we don't have a better

20
src/knex-tables.d.ts поставляемый
Просмотреть файл

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Knex } from "knex";
import { Profile } from "next-auth";
import { Scan } from "./app/functions/server/onerep";
import { StateAbbr } from "./utils/states";
import { RemovalStatus } from "./app/functions/universal/scanResult";
@ -60,11 +61,14 @@ declare module "knex/types/tables" {
fxa_profile_json: null | Profile;
fxa_uid: null | string;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
breaches_last_shown: null | unknown;
all_emails_to_primary: boolean;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
breaches_resolved: null | unknown;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
waitlists_joined: null | unknown;
breach_stats: null | {
passwords: { count: number; numResolved: number };
@ -76,8 +80,10 @@ declare module "knex/types/tables" {
monitoredEmails: { count: number };
};
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
monthly_email_at: null | unknown;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
monthly_email_optout: null | unknown;
breach_resolution:
| null
@ -96,10 +102,12 @@ declare module "knex/types/tables" {
>
>);
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
db_migration_1: null | unknown;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
db_migration_2: null | unknown;
onerep_profile_id: null | OnerepProfileRow.onerep_profile_id;
onerep_profile_id: null | number;
email_addresses: SubscriberEmail[];
}
type SubscriberOptionalColumns = Extract<
@ -261,15 +269,17 @@ declare module "knex/types/tables" {
subscribers: Knex.CompositeTableType<
SubscriberRow,
// On updates, auto-generated columns cannot be set, and nullable columns are optional:
// On inserts, auto-generated columns cannot be set, and nullable columns are optional.
Omit<
SubscriberRow,
SubscriberAutoInsertedColumns | SubscriberOptionalColumns
> &
Partial<Pick<SubscriberRow, SubscriberOptionalColumns>>,
// On updates, don't allow updating the ID and created date; all other fields are optional, except updated_at:
Partial<Omit<SubscriberRow, "id" | "created_at">> &
Pick<SubscriberRow, "updated_at">
// On updates, don't allow updating the ID and created date; all
// otherfields are optional, except updated_at. Also, fxa_profile_json
// takes the data as a serialised string:
Partial<Omit<SubscriberRow, "id" | "created_at" | "fxa_profile_json">> &
Pick<SubscriberRow, "updated_at"> & { fxa_profile_json: string | null }
>;
email_addresses: Knex.CompositeTableType<