feat: replace no only tests with vitest (!2)

This gives us a much more robust configuration for our rules. Additionally, it expects tests to be converted to the `expect` API.

Reviewed-on: https://codeberg.org/nhcarrigan/eslint-config/pulls/2
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
2024-09-26 00:21:31 +00:00
committed by Naomi the Technomancer
parent 9b128c1bf1
commit 883274a3e4
9 changed files with 172 additions and 213 deletions
+11 -26
View File
@@ -4,42 +4,27 @@
* @author Naomi Carrigan
*/
import { suite, assert, test } from "vitest";
import { describe, expect, it } from "vitest";
import { disabledEslintRules, eslintRules } from "../src/rules/eslint.ts";
suite("ESLint Configs", () => {
test("should not enable disabled rules", () => {
describe("eslint configs", () => {
it("should not enable disabled rules", () => {
expect.assertions(20);
const disabled = Object.keys(disabledEslintRules);
const enabled = Object.keys(eslintRules);
for (const key of disabled) {
assert.notInclude(
enabled,
key,
`Disabled rule ${key} has been re-enabled!`,
);
expect(enabled, `Disabled rule ${key} has been re-enabled!`).not.toContain(key);
}
});
test("all disabled rules should be off", () => {
it("all disabled rules should be off", () => {
expect.assertions(20);
const rules = Object.entries(disabledEslintRules);
for (const [ name, rule ] of rules) {
if (Array.isArray(rule)) {
assert.strictEqual(
rule.at(0),
"off",
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
);
continue;
}
if (typeof rule === "string") {
assert.strictEqual(
rule,
"off",
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
);
continue;
}
assert.fail(`Could not determine rule type for ${name}!`);
expect(Array.isArray(rule)
? rule.at(0)
: rule, `${name} appears to be turned on - disabled rules should be explicitly turned off.`).toBe("off");
continue;
}
});
});