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’) [ 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