chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo content deleted, auth-only reference feature, web-next shell, all gates green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor library traces, and product naming are curated out; generic template repairs (coverage provider devDeps, root test:coverage script, live lint fixes, root-only release-please) are kept. See TEMPLATE.md for provenance, curation list, and usage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { RuleTester } from "eslint";
|
||||
import rule from "./pii-declaration-must-be-complete.js";
|
||||
|
||||
const tester = new RuleTester({
|
||||
languageOptions: {
|
||||
parser: await import("@typescript-eslint/parser"),
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
});
|
||||
|
||||
describe("pii-declaration-must-be-complete", () => {
|
||||
it("passes when custom.pii has all required fields", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
slug: "email",
|
||||
type: "email",
|
||||
custom: {
|
||||
pii: {
|
||||
category: "contact",
|
||||
purpose: "authentication",
|
||||
exportable: false,
|
||||
restrictable: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
},
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("fires when category is missing", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
pii: {
|
||||
purpose: "authentication",
|
||||
exportable: false,
|
||||
restrictable: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
errors: [{ messageId: "missingField", data: { field: "category" } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("fires when purpose is missing", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
pii: {
|
||||
category: "contact",
|
||||
exportable: false,
|
||||
restrictable: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
errors: [{ messageId: "missingField", data: { field: "purpose" } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("fires when exportable is missing", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
pii: {
|
||||
category: "contact",
|
||||
purpose: "authentication",
|
||||
restrictable: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: "missingField", data: { field: "exportable" } },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("fires when restrictable is missing", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
pii: {
|
||||
category: "contact",
|
||||
purpose: "authentication",
|
||||
exportable: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: "missingField", data: { field: "restrictable" } },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("is a no-op when custom has no pii property", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
someOtherProperty: "value",
|
||||
},
|
||||
};
|
||||
`,
|
||||
},
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("is a no-op when custom.pii is not an object", () => {
|
||||
tester.run("pii-declaration-must-be-complete", rule, {
|
||||
valid: [
|
||||
{
|
||||
code: `
|
||||
const field = {
|
||||
custom: {
|
||||
pii: true,
|
||||
},
|
||||
};
|
||||
`,
|
||||
},
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user