generated from nhcarrigan/template
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:
+11
-26
@@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user