Can't deactivate sonarjs/no-empty-test-file

The rule sonarjs/no-empty-test-file of eslint-plugin-sonarjs reports on test files which contains no test. Unfortunately, this rule can’t detect that some tests are generated, e.g., with:

import { describe } from "vitest";
import { makeTestSuiteForAbstractButton } from "./AbstractButton.test.js";
import ResetButton from "./ResetButton.js";

describe("ResetButton", () => {
	makeTestSuiteForAbstractButton({
		class: ResetButton,
		name: "ResetButton",
	});
});

That’s a problem but not the reason why I’m creating this issue. I’m creating this issue because there is no way for me to disable this rule in this specific file using eslint-disable. If I add the following line at the top of the file

/* eslint-disable sonarjs/no-empty-test-file -- there are generated tests */

I now get 2 errors:

  • ResetButton.test.js 1 error error: Unused eslint-disable directive (no problems were reported from ‘sonarjs/no-empty-test-file’) [:heavy_multiplication_x: 2 problems (2 errors, 0 warnings)]
  • ResetButton.test.js 1 error error: Add some tests to this file or delete it [sonarjs/no-empty-test-file]

This repository is a small reproducing example: GitHub - DamienCassou/sonarjs-issue-cant-deactivate-no-empty-test-file: Reproduce a bug with eslint-plugin-sonarjs

Hello @DamienCassou,

thanks for reporting this. It seems we (or ESLint) have a bug to apply to disabled flag to some of our rules raising errors on a file (instead of a node). I’ve created a ticket to fix this.

Thanks!