Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(enable sonarlint deprecation rule + fixes) #1411

Merged
merged 10 commits into from
Nov 20, 2024
Merged
3 changes: 2 additions & 1 deletion app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/prefer-promise-reject-errors */
import { PassThrough } from "stream";
import type {
ActionFunctionArgs,
Expand Down Expand Up @@ -81,6 +80,7 @@ function handleBotRequest(
pipe(body);
},
onShellError(error: unknown) {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject(error ?? "Unknown error");
},
onError(error: unknown) {
Expand Down Expand Up @@ -140,6 +140,7 @@ function handleBrowserRequest(
onShellError(error: unknown) {
logError({ error });

// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject(error ?? "Unknown error");
},
onError(error: unknown) {
Expand Down
11 changes: 3 additions & 8 deletions app/services/flow/server/buildFlowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import type {
MachineContext,
TransitionConfigOrTarget as XStateTransitionConfigOrTarget,
} from "xstate";
import {
getInitialSnapshot,
getNextSnapshot,
pathToStateValue,
setup,
} from "xstate";
import { initialTransition, pathToStateValue, setup, transition } from "xstate";
import type { Context } from "~/domains/contexts";
import type { GenericGuard, Guards } from "~/domains/guards.server";
import type { ArrayConfig } from "~/services/array";
Expand Down Expand Up @@ -107,7 +102,7 @@ export const nextStepId = (
context,
});
// Get snapshot of next machine state using the given event
const destinationState = getNextSnapshot(machine, resolvedState, { type });
const [destinationState] = transition(machine, resolvedState, { type });
const destinationStepIds = stateValueToStepIds(destinationState.value);

// Return undefined if the stepId in the new state matches the previous one
Expand Down Expand Up @@ -140,7 +135,7 @@ const metaFromStepId = (machine: FlowStateMachine, currentStepId: string) => {

function getInitial(machine: FlowStateMachine) {
// The initial state might be nested and needs to be resolved
const initialSnapshot = getInitialSnapshot(machine);
const [initialSnapshot] = initialTransition(machine);
Spencer6497 marked this conversation as resolved.
Show resolved Hide resolved
return stateValueToStepIds(initialSnapshot.value).pop();
}

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ export default tseslint.config(

// to be enabled later
"sonarjs/no-unstable-nested-components": "warn", // TODO: enable later
"sonarjs/deprecation": "off", // TODO: enable after remix upgrades to react router v7 and we move to Single Fetch

// fix/reevaluate
"sonarjs/deprecation": "off",
"sonarjs/no-alphabetical-sort": "off",

// typescript-eslint
Expand Down
2 changes: 1 addition & 1 deletion scripts/unusedStrapiEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function unusedStrapiEntry() {

console.log(
`Found ${unusedUrls.length} unused strapi entries with following stepIds: `,
// eslint-disable-next-line sonarjs/no-misleading-array-reverse
// eslint-disable-next-line sonarjs/no-misleading-array-reverse, sonarjs/no-alphabetical-sort
unusedUrls.sort(),
);
}
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/pom/Formular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ export class Formular {

async clickNext() {
await this.page.locator(`button[name="${this.nextButtonName}"]`).click();
await this.page.waitForNavigation(); // deprecated but URL for waitForURL is unknown
/**
* waitForNavigation() is 'deprecated' (not actually, just discouraged) for its inherent raciness.
* However, as we don't know what the next page's url is going to be beforehand,
* we can't drop-in the replacement waitForURL().
*
* see https://github.com/microsoft/playwright/issues/20853 for a discussion,
*/
await this.page.waitForNavigation();
}

async fillRadioPage(field: string, option: string) {
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/pom/Vorabcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export class Vorabcheck {
async clickNext() {
await this.page.locator(`button[name="${this.nextButtonName}"]`).click();
await this.page.waitForLoadState("load");
await this.page.waitForNavigation(); // deprecated but URL for waitForURL is unknown
/**
* waitForNavigation() is 'deprecated' (not actually, just discouraged) for its inherent raciness.
* However, as we don't know what the next page's url is going to be beforehand,
* we can't drop-in the replacement waitForURL().
*
* see https://github.com/microsoft/playwright/issues/20853 for a discussion,
*/
await this.page.waitForNavigation();
}

async clickNextWithoutJavaScript() {
Expand Down
Loading