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,73 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { RuleTester } from "eslint";
|
||||
import rule from "./no-relative-parent-import-in-tests.js";
|
||||
|
||||
const tester = new RuleTester({
|
||||
languageOptions: { ecmaVersion: "latest", sourceType: "module" },
|
||||
});
|
||||
|
||||
const featureTest = "/repo/packages/auth/src/di/container.test.ts";
|
||||
const featureSrc = "/repo/packages/auth/src/di/container.ts";
|
||||
const coreTest = "/repo/packages/core-audit/src/di/bind-audit.test.ts";
|
||||
|
||||
describe("no-relative-parent-import-in-tests", () => {
|
||||
it("passes when a feature test uses the @/ alias", () => {
|
||||
tester.run("no-relative-parent-import-in-tests", rule, {
|
||||
valid: [
|
||||
{
|
||||
filename: featureTest,
|
||||
code: `import { x } from "@/infrastructure/x";`,
|
||||
},
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("passes for same-directory ./ imports", () => {
|
||||
tester.run("no-relative-parent-import-in-tests", rule, {
|
||||
valid: [
|
||||
{ filename: featureTest, code: `import { x } from "./container";` },
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("fires when a feature test imports via ../", () => {
|
||||
tester.run("no-relative-parent-import-in-tests", rule, {
|
||||
valid: [],
|
||||
invalid: [
|
||||
{
|
||||
filename: featureTest,
|
||||
code: `import { x } from "../infrastructure/x";`,
|
||||
errors: [
|
||||
{
|
||||
messageId: "relativeParentImport",
|
||||
data: { source: "../infrastructure/x" },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores ../ imports in non-test source files", () => {
|
||||
tester.run("no-relative-parent-import-in-tests", rule, {
|
||||
valid: [
|
||||
{
|
||||
filename: featureSrc,
|
||||
code: `import { x } from "../infrastructure/x";`,
|
||||
},
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores core-package test files (governed by their own templates)", () => {
|
||||
tester.run("no-relative-parent-import-in-tests", rule, {
|
||||
valid: [
|
||||
{ filename: coreTest, code: `import { x } from "../noop-audit-log";` },
|
||||
],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user