Skip to content

Commit

Permalink
Merge pull request #5622 from mozilla/eslint-increase-coverage
Browse files Browse the repository at this point in the history
Increase typescript-eslint coverage
  • Loading branch information
flozia authored Feb 24, 2025
2 parents 2b56c1b + 4b175c0 commit 415e321
Show file tree
Hide file tree
Showing 65 changed files with 530 additions and 92 deletions.
19 changes: 6 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,13 @@ const config = [
"@typescript-eslint/no-unsafe-call": "off",
},
},
// Ignore the following files for now.
// Next is not running ESLint on root files by default. The only way to
// include those would be to explicitly add them one by one. Instead, we
// run ESLint directly in addition to next lint on just the root files.
// For more info see:
// https://nextjs.org/docs/app/api-reference/config/eslint#linting-custom-directories-and-files
{
files: [
"src/app/global-error.js",
"src/db/migrations/*.js",
"src/scripts/build/*.js",
"src/scripts/loadtest/*.js",
// Next is not running ESLint on root files by default. The only way to
// include those would be to explicitly add them one by one. Instead, we
// run ESLint directly in addition to next lint on just the root files.
// For more info see:
// https://nextjs.org/docs/app/api-reference/config/eslint#linting-custom-directories-and-files
"*.{js,cjs,ts}",
],
files: ["*.{js,cjs,ts}"],
languageOptions: {
parserOptions: { project: null },
},
Expand Down
9 changes: 7 additions & 2 deletions src/app/global-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import * as Sentry from "@sentry/nextjs";
import NextError from "next/error";
import { useEffect } from "react";

export default function GlobalError({ error }) {
/**
* @param {Object} props
* @param {Error} props.error - The error object
* @param {number} props.statusCode - HTTP error status code (default: 500)
*/
export default function GlobalError({ error, statusCode = 500 }) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);
Expand All @@ -17,7 +22,7 @@ export default function GlobalError({ error }) {
<html>
<body>
{/* This is the default Next.js error component. */}
<NextError />
<NextError statusCode={statusCode} />
</body>
</html>
);
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20180418090800_initial_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.createTable("subscribers", (table) => {
table.increments("id").primary();
Expand All @@ -12,6 +16,10 @@ export function up(knex) {
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.dropTableIfExists("subscribers");
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.timestamps(false, true);
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropTimestamps();
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20180829161115_add_fx_newsletter_column.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.boolean("fx_newsletter").defaultTo(false);
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("fx_newsletter");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20180930071926_add_signup_language.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.string("signup_language");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("signup_language");
Expand Down
9 changes: 9 additions & 0 deletions src/db/migrations/20181007085241_add_sha1_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
// Note: this index was created on heroku, stage, and prod by hand
// Use this statement to "fake" the migration:
// INSERT INTO knex_migrations (name, batch, migration_time) values ('20181007085241_add_sha1_index.js', 4, '2018-10-07 08:52:42.000-05');

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.index("sha1", "subscribers_sha1_idx");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropIndex("sha1", "subscribers_sha1_idx");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20181108151941_add_created_at_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.index("created_at");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropIndex("created_at");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20181129152508_add_email_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.index("email", "subscribers_email_idx");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropIndex("email", "subscribers_email_idx");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20181227100332_add_fxa_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.string("fxa_refresh_token");
table.jsonb("fxa_profile_json");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("fxa_refresh_token");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20190117150910_add_verified_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.index("verified", "subscribers_verified_idx");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropIndex("verified", "subscribers_verified_idx");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20190219154519_add_fxa_uid_column.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.string("fxa_uid");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("fxa_uid");
Expand Down
8 changes: 8 additions & 0 deletions src/db/migrations/20190328111900_add_email_addresses_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<[void, void]> }
*/
export function up(knex) {
return Promise.all([
knex.schema.createTable("email_addresses", (table) => {
Expand All @@ -22,6 +26,10 @@ export function up(knex) {
]);
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<[void, void]> }
*/
export function down(knex) {
return Promise.all([
knex.schema.dropTableIfExists("email_addresses"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.timestamp("breaches_last_shown");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("breaches_last_shown");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("email_addresses", (table) => {
table.timestamps(false);
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("email_addresses", (table) => {
table.dropTimestamps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.boolean("all_emails_to_primary").defaultTo(false);
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("all_emails_to_primary");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("subscribers", (table) => {
table.string("fxa_access_token");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("subscribers", (table) => {
table.dropColumn("fxa_access_token");
Expand Down
9 changes: 9 additions & 0 deletions src/db/migrations/20190713193852_add_email_sha1_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
// Note: this index was created on heroku, stage, and prod by hand
// Use this statement to "fake" the migration:
// INSERT INTO knex_migrations (name, batch, migration_time) values ('20190713193852_add_email_sha1_index.js', (SELECT max(batch) + 1 FROM knex_migrations), '2019-07-13 19:52:42.000-05');

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up(knex) {
return knex.schema.table("email_addresses", (table) => {
table.index("sha1", "email_addresses_sha1_idx");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down(knex) {
return knex.schema.table("email_addresses", (table) => {
table.dropIndex("sha1", "email_addresses_sha1_idx");
Expand Down
Loading

0 comments on commit 415e321

Please sign in to comment.