Skip to content

Commit

Permalink
Fix up getSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Mar 5, 2024
1 parent d887c24 commit 1c5f396
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/eslint-plugin/src/rules/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,17 @@ interface Settings {
}

function getSettings(context: Parameters<(typeof rule)["create"]>[0]): Settings {
const dt = context.settings.dt;
if (!dt || typeof dt !== "object") {
return {};
const dt = context.settings.dt ?? {};
if (typeof dt !== "object") {
throw new Error("Invalid dt settings");
}

let versionsToTest = (dt as Record<string, unknown>).versionsToTest;
versionsToTest ??= undefined;
if (!Array.isArray(versionsToTest)) {
const versionsToTest = (dt as Record<string, unknown>).versionsToTest ?? undefined;
if (versionsToTest !== undefined && !Array.isArray(versionsToTest)) {
throw new Error("Invalid versionsToTest");
}

for (const version of versionsToTest) {
for (const version of versionsToTest ?? []) {
if (typeof version !== "object" || typeof version.versionName !== "string" || typeof version.path !== "string") {
throw new Error("Invalid version to test");
}
Expand Down

0 comments on commit 1c5f396

Please sign in to comment.