mirror of
https://github.com/tobi/qmd.git
synced 2026-09-14 20:27:06 +08:00
75f6d5ee82
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.
33 lines
936 B
TypeScript
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],
|
|
},
|
|
],
|
|
},
|
|
);
|