Initial Commit
This commit is contained in:
18
packages/foundation/data/validation/tests/dep-graph.test.ts
Normal file
18
packages/foundation/data/validation/tests/dep-graph.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import pkg from "../package.json";
|
||||
|
||||
describe("dep-graph", () => {
|
||||
it("runtime @suaveplan/* deps are exactly the expected set", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const deps = Object.keys(pkg.dependencies ?? {})
|
||||
.filter((d) => d.startsWith("@suaveplan/"))
|
||||
.sort();
|
||||
|
||||
expect(deps).toEqual([
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/events",
|
||||
"@suaveplan/types",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const SRC_DIR = join(import.meta.dirname, "../src");
|
||||
|
||||
const DISALLOWED = [
|
||||
"node:fs",
|
||||
"node:path",
|
||||
"process.env",
|
||||
"Buffer",
|
||||
"document",
|
||||
"window",
|
||||
];
|
||||
|
||||
async function collectTsFiles(dir: string): Promise<string[]> {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const files: string[] = [];
|
||||
for (const e of entries) {
|
||||
if (e.name === "__benchmarks__") continue;
|
||||
if (e.isDirectory()) {
|
||||
files.push(...(await collectTsFiles(join(dir, e.name))));
|
||||
} else if (
|
||||
e.name.endsWith(".ts") &&
|
||||
!e.name.endsWith(".test.ts") &&
|
||||
!e.name.endsWith(".bench.ts")
|
||||
) {
|
||||
files.push(join(dir, e.name));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
describe("no-disallowed", () => {
|
||||
it("source files must not use disallowed APIs", {
|
||||
timeout: 5000,
|
||||
}, async () => {
|
||||
const files = await collectTsFiles(SRC_DIR);
|
||||
const violations: string[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
const content = await readFile(file, "utf-8");
|
||||
for (const banned of DISALLOWED) {
|
||||
if (content.includes(banned)) {
|
||||
violations.push(`${file}: contains "${banned}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import pkg from "../package.json";
|
||||
|
||||
describe("tree-shake", () => {
|
||||
it("sideEffects is false", { timeout: 5000 }, () => {
|
||||
expect(pkg.sideEffects).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user