@ref0/workspace 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +171 -1
  2. package/dist/bin.mjs +19 -7
  3. package/dist/lint/generic/ast-fields.mjs +32 -0
  4. package/dist/lint/generic/build-cache-inputs.d.mts +9 -0
  5. package/dist/lint/generic/build-cache-inputs.mjs +147 -0
  6. package/dist/lint/generic/effect-gen-wrappers.d.mts +13 -0
  7. package/dist/lint/generic/effect-gen-wrappers.mjs +100 -0
  8. package/dist/lint/generic/folder-imports.mjs +84 -0
  9. package/dist/lint/generic/folder-layers.d.mts +40 -0
  10. package/dist/lint/generic/folder-layers.mjs +82 -0
  11. package/dist/lint/generic/imports.mjs +34 -0
  12. package/dist/lint/generic/package-graph.d.mts +36 -0
  13. package/dist/lint/generic/package-graph.mjs +111 -0
  14. package/dist/lint/generic/package-imports.mjs +85 -0
  15. package/dist/lint/generic/plugin.d.mts +7 -3
  16. package/dist/lint/generic/plugin.mjs +21 -3
  17. package/dist/lint/generic/public-docs.d.mts +12 -0
  18. package/dist/lint/generic/public-docs.mjs +345 -0
  19. package/dist/lint/generic/pure-effect-fn.mjs +107 -0
  20. package/dist/lint/generic/pure-top-level.d.mts +44 -0
  21. package/dist/lint/generic/pure-top-level.mjs +393 -0
  22. package/dist/lint/generic/rule-options.mjs +17 -0
  23. package/dist/lint/generic/workspace-packages.d.mts +58 -0
  24. package/dist/lint/generic/workspace-packages.mjs +119 -0
  25. package/dist/lint/graph.d.mts +8 -0
  26. package/dist/lint/graph.mjs +3 -0
  27. package/dist/review-record/command.mjs +107 -0
  28. package/dist/review-record/index.d.mts +3 -0
  29. package/dist/review-record/index.mjs +3 -0
  30. package/dist/review-record/review-record.d.mts +33 -0
  31. package/dist/review-record/review-record.mjs +1256 -0
  32. package/dist/review-record/settings.d.mts +40 -0
  33. package/dist/review-record/settings.mjs +103 -0
  34. package/dist/symbols/symbols.mjs +1 -1
  35. package/dist/task-sources.d.mts +16 -0
  36. package/dist/task-sources.mjs +121 -0
  37. package/package.json +13 -1
@@ -0,0 +1,40 @@
1
+ /**
2
+ * How one source folder's places stack. A place is a folder of the source, a folder inside one,
3
+ * such as `protocol/bytes`, or a file at its top, named without its extension. A file imports any
4
+ * module of its own place, and of any place in a layer below its own: never one beside it, or
5
+ * above.
6
+ */
7
+ export interface SourceLayers {
8
+ /** The source's places, layer by layer, from the bottom. */
9
+ readonly layers: ReadonlyArray<ReadonlyArray<string>>;
10
+ /**
11
+ * Imports allowed against the layers and the features, by the file that makes each, from the
12
+ * source, to the modules it imports, without their extensions. An entry no import needs fails,
13
+ * so the list only shrinks.
14
+ */
15
+ readonly exceptions?: {
16
+ readonly [file: string]: ReadonlyArray<string>;
17
+ };
18
+ /**
19
+ * Places a host can leave out. No other place imports one, wherever it sits, but a file in a
20
+ * `testing/` folder, which builds whole hosts.
21
+ */
22
+ readonly features?: ReadonlyArray<string>;
23
+ /**
24
+ * When the files at the top of the source are its entry points, above every place: each imports
25
+ * anything, and nothing imports one. `reexports` holds each to re-exports, as a package's are;
26
+ * `code` lets each hold code, as an app's server does. Left out, the top files are places.
27
+ */
28
+ readonly entries?: 'reexports' | 'code';
29
+ }
30
+ /**
31
+ * Each layered source folder, from the root, such as `packages/cli/src`, to its layers. A source
32
+ * may sit in a place of another, such as `packages/cli/src/harness`, and a file is held to every
33
+ * source it's in. `Source` lets a repo hold the keys to its own, as `satisfies FolderLayers<…>`.
34
+ */
35
+ export type FolderLayers<Source extends string = string> = { readonly [Name in Source]: SourceLayers; };
36
+ /** What `ref0-generic/folder-imports` takes: the repo's root, as an absolute path, and its sources. */
37
+ export interface FolderImportsOptions {
38
+ readonly root: string;
39
+ readonly sources: FolderLayers;
40
+ }
@@ -0,0 +1,82 @@
1
+ import { Schema } from "effect";
2
+ // src/lint/generic/folder-layers.ts
3
+ const decodeFolderImportsOptions = Schema.decodeUnknownSync(Schema.Tuple([Schema.Struct({
4
+ root: Schema.String,
5
+ sources: Schema.Record(Schema.String, Schema.Struct({
6
+ layers: Schema.Array(Schema.Array(Schema.String)),
7
+ exceptions: Schema.optionalKey(Schema.Record(Schema.String, Schema.Array(Schema.String))),
8
+ features: Schema.optionalKey(Schema.Array(Schema.String)),
9
+ entries: Schema.optionalKey(Schema.Literals(["reexports", "code"]))
10
+ }))
11
+ })]));
12
+ /** The rule's options as decoded: the root, and each source with its places' ranks. */
13
+ const folderImportsOf = (options) => {
14
+ const [{ root, sources }] = decodeFolderImportsOptions(options);
15
+ return {
16
+ root,
17
+ sources: Object.entries(sources).map(([folder, source]) => ({
18
+ ...source,
19
+ folder,
20
+ ranks: new Map(source.layers.flatMap((layer, rank) => layer.map((place) => [place, rank])))
21
+ }))
22
+ };
23
+ };
24
+ /** The module a path names, without its extension, such as `protocol/bytes/sha1`. */
25
+ const moduleNamed = (path) => path.replace(/\.[cm]?[jt]sx?$/, "");
26
+ /** Whether a module sits at the top of its source. */
27
+ const atTop = (module) => !module.includes("/");
28
+ /**
29
+ * The place that holds `module`: the deepest place it's in, such as `protocol/bytes` for
30
+ * `protocol/bytes/sha1`. A module in no place gives the first folder on its path that holds no
31
+ * place, such as `drafts` for `drafts/idea`, or the module itself.
32
+ */
33
+ const placeOf = (source, module) => {
34
+ const places = [...source.ranks.keys()];
35
+ const holding = places.filter((place) => module === place || module.startsWith(`${place}/`)).toSorted((a, b) => b.length - a.length)[0];
36
+ if (holding !== void 0) return holding;
37
+ const folders = module.split("/").slice(0, -1);
38
+ return folders.map((_, depth) => folders.slice(0, depth + 1).join("/")).find((folder) => !places.some((place) => place.startsWith(`${folder}/`))) ?? module;
39
+ };
40
+ const testingFile = /(^|\/)testing\//;
41
+ /**
42
+ * What's wrong with `file` importing `module`, both from the source's folder, if anything: a place
43
+ * in no layer, an entry point imported, a feature imported from outside it, or a place beside its
44
+ * own or above it. The source's exceptions aren't read here.
45
+ */
46
+ const layerProblem = (source, file, module) => {
47
+ const fromModule = moduleNamed(file);
48
+ if (source.entries !== void 0 && atTop(fromModule)) return void 0;
49
+ const from = placeOf(source, fromModule);
50
+ if (source.entries !== void 0 && atTop(module)) return {
51
+ messageId: "entry",
52
+ data: {
53
+ from,
54
+ to: module
55
+ }
56
+ };
57
+ const to = placeOf(source, module);
58
+ if (from === to) return void 0;
59
+ const fromRank = source.ranks.get(from);
60
+ const toRank = source.ranks.get(to);
61
+ if (fromRank === void 0 || toRank === void 0) return {
62
+ messageId: "unplaced",
63
+ data: { place: fromRank === void 0 ? from : to }
64
+ };
65
+ const features = source.features ?? [];
66
+ if (features.includes(to) && !features.includes(from) && !testingFile.test(file)) return {
67
+ messageId: "feature",
68
+ data: {
69
+ from,
70
+ to
71
+ }
72
+ };
73
+ if (toRank < fromRank) return void 0;
74
+ return {
75
+ messageId: toRank === fromRank ? "beside" : "above",
76
+ data: {
77
+ from,
78
+ to
79
+ }
80
+ };
81
+ };
82
+ export { folderImportsOf, layerProblem, moduleNamed, placeOf };
@@ -0,0 +1,34 @@
1
+ import { Schema } from "effect";
2
+ // src/lint/generic/imports.ts
3
+ const isString = Schema.is(Schema.String);
4
+ /** The module a dynamic import names, when it's written out. */
5
+ const sourceOf = (node) => {
6
+ if (node.type === "Literal") return isString(node.value) ? node.value : void 0;
7
+ return node.type === "TemplateLiteral" && node.expressions.length === 0 ? node.quasis[0]?.value.cooked ?? void 0 : void 0;
8
+ };
9
+ /**
10
+ * A visitor that hands `check` each import in a file: its node, the module it names, and whether
11
+ * it takes only types, so it loads nothing. That's an import, a re-export, a dynamic import whose
12
+ * module is written out, and an `import()` type. `import { type A }` isn't types only:
13
+ * `verbatimModuleSyntax` keeps it as `import {} from`, which still loads its module. It visits
14
+ * Oxlint's tree in a rule, and oxc's from `parseSync`, so each node is only what it reads.
15
+ */
16
+ const importsVisitor = (check) => ({
17
+ ImportDeclaration(node) {
18
+ check(node, node.source.value, node.importKind === "type");
19
+ },
20
+ ExportNamedDeclaration(node) {
21
+ if (node.source !== null) check(node, node.source.value, node.exportKind === "type");
22
+ },
23
+ ExportAllDeclaration(node) {
24
+ check(node, node.source.value, node.exportKind === "type");
25
+ },
26
+ ImportExpression(node) {
27
+ const source = sourceOf(node.source);
28
+ if (source !== void 0) check(node, source, false);
29
+ },
30
+ TSImportType(node) {
31
+ check(node, node.source.value, true);
32
+ }
33
+ });
34
+ export { importsVisitor };
@@ -0,0 +1,36 @@
1
+ import { Workspace } from "./workspace-packages.mjs";
2
+ /**
3
+ * How a package may import an entry point of another: `values`, anything; `types`, only with
4
+ * `import type`, which loads nothing; or `tests`, anything, but only in its tests and the modules
5
+ * in a `testing/` folder they share.
6
+ */
7
+ export type How = 'values' | 'types' | 'tests';
8
+ /**
9
+ * The entry points of a package another imports, by how it may import each. An entry point is a
10
+ * key of the package's `exports` without its `./`, such as `cast`, or `.` for its root. A
11
+ * pattern's is its folder: `testing/vectors` for `./testing/vectors/*.json`.
12
+ */
13
+ export type Edge = { readonly [Kind in How]?: ReadonlyArray<string>; };
14
+ /**
15
+ * What each package and app may import of the others, by name, then by entry point. Every package
16
+ * and app is named, with `{}` when it imports none of the others. `From` and `To` let a repo hold
17
+ * its graph to its own names, as `satisfies PackageGraph<Library | App, Library>`.
18
+ */
19
+ export type PackageGraph<From extends string = string, To extends string = string> = { readonly [Name in From]: { readonly [Name in To]?: Edge; }; };
20
+ /**
21
+ * What `ref0-generic/package-imports` takes: where the packages are, the graph, and `nodeFiles`,
22
+ * the files of a package that run only in Node, by its name, from its folder, which take values
23
+ * where it takes only types.
24
+ */
25
+ export interface PackageGraphOptions extends Workspace {
26
+ readonly graph: PackageGraph;
27
+ readonly nodeFiles?: {
28
+ readonly [name: string]: ReadonlyArray<string>;
29
+ };
30
+ }
31
+ /**
32
+ * What's wrong with the graph itself: a package it leaves out, a name no package has, an edge to
33
+ * an app, an edge to a package its importer doesn't depend on, an entry point the target doesn't
34
+ * export, and a Node-only file that isn't there. A repo's test expects none.
35
+ */
36
+ export declare const graphProblems: (options: PackageGraphOptions) => ReadonlyArray<string>;
@@ -0,0 +1,111 @@
1
+ import { ownerOf, workspacePackages } from "./workspace-packages.mjs";
2
+ import { existsSync } from "node:fs";
3
+ import { join, posix } from "node:path";
4
+ import { Schema } from "effect";
5
+ // src/lint/generic/package-graph.ts
6
+ const hows = [
7
+ "values",
8
+ "types",
9
+ "tests"
10
+ ];
11
+ const Edge = Schema.Struct({
12
+ values: Schema.optionalKey(Schema.Array(Schema.String)),
13
+ types: Schema.optionalKey(Schema.Array(Schema.String)),
14
+ tests: Schema.optionalKey(Schema.Array(Schema.String))
15
+ });
16
+ const PackageGraphOptions = Schema.Struct({
17
+ root: Schema.String,
18
+ packages: Schema.Array(Schema.String),
19
+ apps: Schema.optionalKey(Schema.Array(Schema.String)),
20
+ graph: Schema.Record(Schema.String, Schema.Record(Schema.String, Edge)),
21
+ nodeFiles: Schema.optionalKey(Schema.Record(Schema.String, Schema.Array(Schema.String)))
22
+ });
23
+ const decodePackageGraphOptions = Schema.decodeUnknownSync(Schema.Tuple([PackageGraphOptions]));
24
+ /** A test: what a test runner runs. */
25
+ const testFile = /\.(test|spec)(-d)?\.[cm]?[jt]sx?$/;
26
+ /** Code only tests run: a test, or a module in a `testing/` folder that tests share. */
27
+ const testCode = (path) => testFile.test(path) || /\/testing\/[^/]+$/.test(path);
28
+ /** The workspace package an import names, such as `@acme/ui` for `@acme/ui/cast`. */
29
+ const packageNamed = (source, packages) => {
30
+ const parts = source.split("/");
31
+ return packages.get(source.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? "");
32
+ };
33
+ /** Whether `subpath`, such as `./testing/vectors/keys.json`, matches an `exports` pattern. */
34
+ const matches = (pattern, subpath) => {
35
+ const [before = "", after = ""] = pattern.split("*");
36
+ return subpath.startsWith(before) && subpath.endsWith(after);
37
+ };
38
+ /**
39
+ * The entry point of `to` an import names, as the graph writes it: `cast` for `@acme/ui/cast`, `.`
40
+ * for `@acme/ui`, `base.css` for `@acme/ui/base.css?raw`, and a pattern's folder,
41
+ * `testing/vectors` for `@acme/core/testing/vectors/keys.json`.
42
+ */
43
+ const entryNamed = (to, source) => {
44
+ const subpath = `.${source.replace(/\?.*$/, "").slice(to.name.length)}`;
45
+ const pattern = to.entries.find((key) => key.includes("*") && matches(key, subpath));
46
+ const entry = pattern === void 0 ? subpath : pattern.slice(0, pattern.indexOf("/*"));
47
+ return entry === "." ? entry : entry.slice(2);
48
+ };
49
+ /** Whether `to` exports `entry`, as the graph writes it. */
50
+ const exported = (to, entry) => to.entries.some((key) => key === (entry === "." ? "." : `./${entry}`) || key.startsWith(`./${entry}/*`));
51
+ /** An entry point as an import names it, such as `@acme/ui/cast`, or `@acme/ui` for `.`. */
52
+ const shown = (to, entry) => entry === "." ? to : `${to}/${entry}`;
53
+ /** The entry points an edge lists, each in backticks, in order. */
54
+ const listed = (edge) => hows.flatMap((how) => edge[how] ?? []).toSorted().map((entry) => `\`${entry}\``).join(", ");
55
+ /** Why `path`, in `from`, may not import `to`'s `entry` as it does, if it may not. */
56
+ const edgeProblem = ({ graph, nodeFiles }, from, to, entry, path, typesOnly) => {
57
+ if (to.app) return "app";
58
+ const edge = graph[from.name]?.[to.name];
59
+ if (edge === void 0) return "edge";
60
+ if (entry === void 0) return "relative";
61
+ const how = hows.find((kind) => edge[kind]?.includes(entry) === true);
62
+ if (how === void 0) return "entry";
63
+ if (how === "tests" && !testCode(path)) return "tests";
64
+ const runsInNode = testFile.test(path) || (nodeFiles?.[from.name] ?? []).some((file) => `${from.directory}/${file}` === path);
65
+ return how === "types" && !typesOnly && !runsInNode ? "types" : void 0;
66
+ };
67
+ /** What the file at `path` imports by `source`: a package, or a relative path's target from the root. */
68
+ const importedBy = (packages, path, source) => {
69
+ if (!source.startsWith(".")) return {
70
+ to: packageNamed(source, packages),
71
+ target: void 0
72
+ };
73
+ const target = posix.normalize(posix.join(posix.dirname(path), source.replace(/\?.*$/, "")));
74
+ return {
75
+ to: ownerOf(target, packages),
76
+ target
77
+ };
78
+ };
79
+ /**
80
+ * What's wrong with the graph itself: a package it leaves out, a name no package has, an edge to
81
+ * an app, an edge to a package its importer doesn't depend on, an entry point the target doesn't
82
+ * export, and a Node-only file that isn't there. A repo's test expects none.
83
+ */
84
+ const graphProblems = (options) => {
85
+ const { root, graph, nodeFiles = {} } = options;
86
+ const packages = workspacePackages(options);
87
+ const missing = [...packages.keys()].flatMap((name) => graph[name] === void 0 ? [`${name} isn't in the graph: add it, with {} if it imports none of the others.`] : []);
88
+ const edges = Object.entries(graph).flatMap(([from, targets]) => {
89
+ const source = packages.get(from);
90
+ if (source === void 0) return [`${from} is no workspace package: remove it.`];
91
+ return Object.entries(targets).flatMap(([to, edge = {}]) => {
92
+ const target = packages.get(to);
93
+ if (target === void 0) return [`${from}'s edge names ${to}, which is no workspace package.`];
94
+ if (target.app) return [`${from}'s edge names ${to}, an app, which nothing imports.`];
95
+ const undeclared = source.dependencies.has(to) ? [] : [`${from} imports ${to} but its package.json doesn't depend on it.`];
96
+ const unexported = hows.flatMap((how) => (edge[how] ?? []).flatMap((entry) => exported(target, entry) ? [] : [`${from}'s edge lists ${shown(to, entry)}, which ${to} doesn't export.`]));
97
+ return [...undeclared, ...unexported];
98
+ });
99
+ });
100
+ const nodeOnly = Object.entries(nodeFiles).flatMap(([name, files]) => {
101
+ const owner = packages.get(name);
102
+ if (owner === void 0) return [`nodeFiles names ${name}, which is no workspace package.`];
103
+ return files.flatMap((file) => existsSync(join(root, owner.directory, file)) ? [] : [`nodeFiles lists ${owner.directory}/${file}, which isn't there.`]);
104
+ });
105
+ return [
106
+ ...missing,
107
+ ...edges,
108
+ ...nodeOnly
109
+ ];
110
+ };
111
+ export { decodePackageGraphOptions, edgeProblem, entryNamed, graphProblems, importedBy, listed, packageNamed, shown, testFile };
@@ -0,0 +1,85 @@
1
+ import { importsVisitor } from "./imports.mjs";
2
+ import { decodePackageGraphOptions, edgeProblem, entryNamed, importedBy, listed, shown, testFile } from "./package-graph.mjs";
3
+ import { decodedOnce } from "./rule-options.mjs";
4
+ import { fromRoot, ownerOf, workspacePackages } from "./workspace-packages.mjs";
5
+ import { resolve } from "node:path";
6
+ import { defineRule } from "vite-plus/lint/plugins";
7
+ // src/lint/generic/package-imports.ts
8
+ const optionsOf = decodedOnce((options) => decodePackageGraphOptions(options)[0]);
9
+ const packageImportsRule = defineRule({
10
+ meta: {
11
+ messages: {
12
+ app: "Nothing imports an app, and {{to}} is one. Move what {{from}} needs into a package.",
13
+ edge: "{{from}} doesn't import {{to}}: the package graph has no such edge.",
14
+ entry: "{{from}} doesn't import {{entry}}: its edge to {{to}} in the package graph lists {{listed}}. To import another entry point, add it to that edge.",
15
+ tests: "{{from}} imports {{entry}} only in its tests, as the package graph says.",
16
+ types: "{{from}} takes only types from {{entry}}, as the package graph says. Write `import type`, which loads nothing: `import { type … }` still loads {{entry}}.",
17
+ relative: "This relative path leaves {{from}} for {{to}}. Import {{to}} by its name, through its exports.",
18
+ outside: "This relative path leaves {{from}} for a file no package or app holds.",
19
+ self: "{{from}} imports itself by name, which goes around its folder layers. Import the module by its relative path."
20
+ },
21
+ schema: [{
22
+ type: "object",
23
+ properties: {
24
+ root: { type: "string" },
25
+ packages: {
26
+ type: "array",
27
+ items: { type: "string" }
28
+ },
29
+ apps: {
30
+ type: "array",
31
+ items: { type: "string" }
32
+ },
33
+ graph: { type: "object" },
34
+ nodeFiles: { type: "object" }
35
+ },
36
+ required: [
37
+ "root",
38
+ "packages",
39
+ "graph"
40
+ ],
41
+ additionalProperties: false
42
+ }]
43
+ },
44
+ create(context) {
45
+ const options = optionsOf(context.options);
46
+ const packages = workspacePackages(options);
47
+ const path = fromRoot(options.root, resolve(context.filename));
48
+ const from = ownerOf(path, packages);
49
+ if (from === void 0) return {};
50
+ const check = (node, source, typesOnly) => {
51
+ const { to, target } = importedBy(packages, path, source);
52
+ if (to === from) {
53
+ if (target === void 0 && !testFile.test(path)) context.report({
54
+ node,
55
+ messageId: "self",
56
+ data: { from: from.name }
57
+ });
58
+ return;
59
+ }
60
+ if (to === void 0) {
61
+ if (target !== void 0) context.report({
62
+ node,
63
+ messageId: "outside",
64
+ data: { from: from.name }
65
+ });
66
+ return;
67
+ }
68
+ const entry = target === void 0 ? entryNamed(to, source) : void 0;
69
+ const messageId = edgeProblem(options, from, to, entry, path, typesOnly);
70
+ if (messageId === void 0) return;
71
+ context.report({
72
+ node,
73
+ messageId,
74
+ data: {
75
+ from: from.name,
76
+ to: to.name,
77
+ entry: entry === void 0 ? to.name : shown(to.name, entry),
78
+ listed: listed(options.graph[from.name]?.[to.name] ?? {})
79
+ }
80
+ });
81
+ };
82
+ return importsVisitor(check);
83
+ }
84
+ });
85
+ export { packageImportsRule };
@@ -1,7 +1,11 @@
1
1
  /**
2
- * Rules any ref-0 repo can turn on, each over the files its config names. Two take options:
3
- * `entry-reexports` the repo's root, its packages and its source condition, and `no-comments` the
4
- * repo's root and its comment budget's file.
2
+ * Rules any ref-0 repo can turn on, each over the files its config names. These take options:
3
+ * `entry-reexports` the repo's root, its packages and its source condition, `no-comments` the
4
+ * repo's root and its comment budget's file, `package-imports` where its packages are and their
5
+ * graph, `folder-imports` its sources' layers, `public-docs` where its packages are and their
6
+ * source condition, `build-cache-inputs` where its packages are and their build tasks,
7
+ * `pure-top-level` the callees it treats as pure, and `effect-gen-wrappers` the functions it
8
+ * allows.
5
9
  */
6
10
  declare const _default: import("vite-plus/lint/plugins").Plugin;
7
11
  export { _default as default };
@@ -1,28 +1,46 @@
1
+ import { buildCacheInputsRule } from "./build-cache-inputs.mjs";
1
2
  import { effectEncodingRule } from "./effect-encoding.mjs";
3
+ import { effectGenWrappersRule } from "./effect-gen-wrappers.mjs";
2
4
  import { entryReexportsRule } from "./entry-reexports.mjs";
3
5
  import { envAtEntrypointsRule } from "./env-at-entrypoints.mjs";
4
6
  import { exportTypeSideEffectsRule } from "./export-type-side-effects.mjs";
7
+ import { folderImportsRule } from "./folder-imports.mjs";
5
8
  import { indexBarrelOnlyRule } from "./index-barrel.mjs";
6
9
  import { logMessagesRule } from "./log-messages.mjs";
7
10
  import { noCommentsRule } from "./no-comments.mjs";
11
+ import { packageImportsRule } from "./package-imports.mjs";
12
+ import { publicDocsRule } from "./public-docs.mjs";
13
+ import { pureEffectFnRule } from "./pure-effect-fn.mjs";
14
+ import { pureTopLevelRule } from "./pure-top-level.mjs";
8
15
  import { seededPropertiesRule } from "./seeded-properties.mjs";
9
16
  import { definePlugin } from "vite-plus/lint/plugins";
10
17
  // src/lint/generic/plugin.ts
11
18
  /**
12
- * Rules any ref-0 repo can turn on, each over the files its config names. Two take options:
13
- * `entry-reexports` the repo's root, its packages and its source condition, and `no-comments` the
14
- * repo's root and its comment budget's file.
19
+ * Rules any ref-0 repo can turn on, each over the files its config names. These take options:
20
+ * `entry-reexports` the repo's root, its packages and its source condition, `no-comments` the
21
+ * repo's root and its comment budget's file, `package-imports` where its packages are and their
22
+ * graph, `folder-imports` its sources' layers, `public-docs` where its packages are and their
23
+ * source condition, `build-cache-inputs` where its packages are and their build tasks,
24
+ * `pure-top-level` the callees it treats as pure, and `effect-gen-wrappers` the functions it
25
+ * allows.
15
26
  */
16
27
  var plugin_default = definePlugin({
17
28
  meta: { name: "ref0-generic" },
18
29
  rules: {
30
+ "build-cache-inputs": buildCacheInputsRule,
19
31
  "effect-encoding": effectEncodingRule,
32
+ "effect-gen-wrappers": effectGenWrappersRule,
20
33
  "entry-reexports": entryReexportsRule,
21
34
  "env-at-entrypoints": envAtEntrypointsRule,
22
35
  "export-type-side-effects": exportTypeSideEffectsRule,
36
+ "folder-imports": folderImportsRule,
23
37
  "index-barrel-only": indexBarrelOnlyRule,
24
38
  "log-messages": logMessagesRule,
25
39
  "no-comments": noCommentsRule,
40
+ "package-imports": packageImportsRule,
41
+ "public-docs": publicDocsRule,
42
+ "pure-effect-fn": pureEffectFnRule,
43
+ "pure-top-level": pureTopLevelRule,
26
44
  "seeded-properties": seededPropertiesRule
27
45
  }
28
46
  });
@@ -0,0 +1,12 @@
1
+ import { Workspace } from "./workspace-packages.mjs";
2
+ import "vite-plus/lint/plugins";
3
+ import { parseSync } from "vite-plus";
4
+ /**
5
+ * What `ref0-generic/public-docs` takes: where the packages are, `condition`, the export condition
6
+ * that names an entry point's source, such as `@ref0/source`, and `entries`, the entry files from
7
+ * the root whose exports it follows, which default to each public package's published ones.
8
+ */
9
+ export interface PublicDocsOptions extends Workspace {
10
+ readonly condition: string;
11
+ readonly entries?: ReadonlyArray<string>;
12
+ }