Files
tobi__qmd/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.test.ts
T
Tobias Lütke 75f6d5ee82 chore: add oxlint and a vendored anti-slop fence
Enable the high-signal anti-slop rules as errors and fix the real slop
(chained assertions, object parameters). SQLite/CLI/MCP typeof/unknown
stays off. bun.lock changes for the new devDependencies; flake FOD
hashes are not updated.
2026-08-18 14:24:46 +00:00

33 lines
936 B
TypeScript

import { RuleTester } from "oxlint/plugins-dev";
import { noConditionalEmptyObjectSpreadRule } from "./no-conditional-empty-object-spread.ts";
const tester = new RuleTester({ languageOptions: { parserOptions: { lang: "ts" } } });
const error = { messageId: "avoid" };
if (noConditionalEmptyObjectSpreadRule.meta?.fixable !== undefined) {
throw new Error("The rule must not offer an unsafe semantics-changing fix.");
}
tester.run(
"anti-slop/no-conditional-empty-object-spread",
noConditionalEmptyObjectSpreadRule,
{
valid: [
"const result = { value };",
"const result = { ...values };",
"const result = condition ? { value } : {};",
],
invalid: [
{
code: "const result = { ...(value !== undefined ? { value } : {}) };",
errors: [error],
},
{
code: "const result = { ...(condition ? {} : { value }) };",
errors: [error],
},
],
},
);