S2004 (`sonarjs/no-nested-functions`) triggers in describe()/it() test files

The sonarjs/no-nested-functions of eslint-plugin-sonarjs 2.0.4 complains about code like:

import { describe, expect, it } from "vitest";

describe("Foo", () => {
  describe("visiting", () => {
    describe("accept()", () => {
      it("throws an exception", () => {
        expect(() => "id".accept("bar")).toThrowError("some error");
      });
    });
  });
});

The error message is:

Refactor this code to not nest functions more than 4 levels deep

In such test suites, functions are a way to group tests and don’t add to the complexity of the file. I would advocate for deactivating this rule in such files or raising the limit.

Hello Damien,

Thank you for the feedback.

I have opened a ticket to track this issue: JS-486.