EslintPluginImportResolveError: unable to load resolver "alias"

278 Views Asked by At

We have just done our weekly Dependancy updates and now our eslint process throws the following error

EslintPluginImportResolveError: unable to load resolver "alias".
Occurred while linting /TheForgotPasswordPage.stories.ts:5
Rule: "import/no-cycle"

The line it refers to is

import AddListener from "../../../../../.storybook/resources/msw/GetPayloadHelper.ts";

which in turn refers to in GetPayloadHelper:

import { matchRequestUrl } from "msw";
import type { MockedRequest } from "msw";
import type { SetupServerApi } from "msw/node";
import { getWorker } from "msw-storybook-addon";

/**
 * Creates a listener that is used to capture post/put requests and return any request json
 *
 * - The capture only happens once per listener as it prevents an error
 *   where a body buffer is read multiple times for a `Isomorphic Request`
 * - Currently only one request is supported
 * @todo refactor to support multiple attempts to the same endpoint
 * @param url the request url
 * @param callback a callback that gets called and will receive the json payload as a parameter
 */
export default function AddListener(url: string, callback: (requestJson: unknown) => void): void {
  let firstCallCaptured = false;
  const worker = getWorker() as SetupServerApi;
  worker.events.on("request:match", async (request: MockedRequest) => {
    if (firstCallCaptured === false && matchRequestUrl(request.url, url).matches) {
      firstCallCaptured = true;
      callback(await request.json());
    }
  });
}

The code works but the rule isnt happy and I dont know how to resolve it.

0

There are 0 best solutions below