@ref0/workspace 0.0.0-stage → 0.2.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 (82) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +169 -2
  3. package/dist/bin.d.mts +1 -0
  4. package/dist/bin.mjs +113 -0
  5. package/dist/docs-budget.mjs +122 -0
  6. package/dist/lint/anti-slop/LICENSE +21 -0
  7. package/dist/lint/anti-slop/UPSTREAM.md +11 -0
  8. package/dist/lint/anti-slop/effect/plugin.d.mts +3 -0
  9. package/dist/lint/anti-slop/effect/plugin.mjs +19 -0
  10. package/dist/lint/anti-slop/effect/rules/no-manual-effect-error-tag.mjs +33 -0
  11. package/dist/lint/anti-slop/effect/rules/no-manual-tag-comparison.mjs +32 -0
  12. package/dist/lint/anti-slop/effect/rules/no-manual-tagged-construction.mjs +22 -0
  13. package/dist/lint/anti-slop/effect/rules/no-service-constructor-imports.mjs +36 -0
  14. package/dist/lint/anti-slop/effect/rules/prefer-effect-match.mjs +40 -0
  15. package/dist/lint/anti-slop/effect/shared/tagged-values.mjs +40 -0
  16. package/dist/lint/anti-slop/plugin.d.mts +3 -0
  17. package/dist/lint/anti-slop/plugin.mjs +45 -0
  18. package/dist/lint/anti-slop/rules/no-array-filter-map.mjs +31 -0
  19. package/dist/lint/anti-slop/rules/no-chained-type-assertions.mjs +56 -0
  20. package/dist/lint/anti-slop/rules/no-conditional-empty-object-spread.mjs +32 -0
  21. package/dist/lint/anti-slop/rules/no-known-value-widening.mjs +236 -0
  22. package/dist/lint/anti-slop/rules/no-module-mocking.mjs +48 -0
  23. package/dist/lint/anti-slop/rules/no-object-parameters.mjs +48 -0
  24. package/dist/lint/anti-slop/rules/no-reduce-accumulator-copy.mjs +85 -0
  25. package/dist/lint/anti-slop/rules/no-reflect-apply.mjs +21 -0
  26. package/dist/lint/anti-slop/rules/no-reflect-get.mjs +21 -0
  27. package/dist/lint/anti-slop/rules/no-runtime-typeof.mjs +52 -0
  28. package/dist/lint/anti-slop/rules/no-shape-in-symbol-names.mjs +36 -0
  29. package/dist/lint/anti-slop/rules/no-unknown-parameters.mjs +44 -0
  30. package/dist/lint/anti-slop/rules/no-unknown-returns.mjs +47 -0
  31. package/dist/lint/anti-slop/rules/no-unknown-type-aliases.mjs +33 -0
  32. package/dist/lint/anti-slop/rules/no-unsafe-dictionary-type.mjs +121 -0
  33. package/dist/lint/anti-slop/rules/no-widen-then-assert.mjs +191 -0
  34. package/dist/lint/anti-slop/rules/require-readable-spacing.mjs +86 -0
  35. package/dist/lint/anti-slop/rules/require-safety-comment-for-type-assertion.mjs +82 -0
  36. package/dist/lint/anti-slop/shared/array-method.mjs +70 -0
  37. package/dist/lint/anti-slop/shared/child-nodes.mjs +24 -0
  38. package/dist/lint/anti-slop/shared/dictionary-types.mjs +248 -0
  39. package/dist/lint/anti-slop/shared/function-parameters.mjs +25 -0
  40. package/dist/lint/anti-slop/shared/lexical-type-parameters.mjs +21 -0
  41. package/dist/lint/anti-slop/shared/reflect-method.mjs +16 -0
  42. package/dist/lint/anti-slop/shared/scope.mjs +12 -0
  43. package/dist/lint/anti-slop/shared/string-literal.mjs +6 -0
  44. package/dist/lint/anti-slop/shared/type-alias-resolution.mjs +134 -0
  45. package/dist/lint/anti-slop/vendor/eslint-stylistic/LICENSE +22 -0
  46. package/dist/lint/anti-slop/vendor/eslint-stylistic/UPSTREAM.md +29 -0
  47. package/dist/lint/anti-slop/vendor/eslint-stylistic/padding-line-ast.mjs +32 -0
  48. package/dist/lint/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.mjs +608 -0
  49. package/dist/lint/config.d.mts +20 -0
  50. package/dist/lint/config.mjs +135 -0
  51. package/dist/lint/generic/effect-encoding.mjs +45 -0
  52. package/dist/lint/generic/entry-reexports.mjs +81 -0
  53. package/dist/lint/generic/env-at-entrypoints.mjs +65 -0
  54. package/dist/lint/generic/export-type-side-effects.mjs +22 -0
  55. package/dist/lint/generic/index-barrel.mjs +14 -0
  56. package/dist/lint/generic/log-messages.mjs +39 -0
  57. package/dist/lint/generic/plugin.d.mts +6 -0
  58. package/dist/lint/generic/plugin.mjs +26 -0
  59. package/dist/lint/generic/seeded-properties.mjs +78 -0
  60. package/dist/lint/plugins.d.mts +9 -0
  61. package/dist/lint/plugins.mjs +14 -0
  62. package/dist/lint/t3code/LICENSE +21 -0
  63. package/dist/lint/t3code/UPSTREAM.md +24 -0
  64. package/dist/lint/t3code/plugin.d.mts +2 -0
  65. package/dist/lint/t3code/plugin.mjs +20 -0
  66. package/dist/lint/t3code/rules/no-global-process-runtime.mjs +76 -0
  67. package/dist/lint/t3code/rules/no-inline-schema-compile.mjs +112 -0
  68. package/dist/lint/t3code/rules/no-manual-effect-runtime-in-tests.mjs +67 -0
  69. package/dist/lint/t3code/rules/no-native-title-tooltip.mjs +33 -0
  70. package/dist/lint/t3code/rules/no-test-in-loop.mjs +69 -0
  71. package/dist/lint/t3code/rules/no-unscoped-has.mjs +147 -0
  72. package/dist/lint/t3code/utils.mjs +21 -0
  73. package/dist/package-exports.mjs +157 -0
  74. package/dist/symbols/check.mjs +209 -0
  75. package/dist/symbols/find.mjs +63 -0
  76. package/dist/symbols/symbols.mjs +390 -0
  77. package/dist/type-coverage.mjs +68 -0
  78. package/dist/types/cache.mjs +157 -0
  79. package/dist/types/inputs.mjs +71 -0
  80. package/dist/types/projects.mjs +65 -0
  81. package/dist/types/types.mjs +175 -0
  82. package/package.json +68 -3
@@ -0,0 +1,135 @@
1
+ // src/lint/config.ts
2
+ const agentToolingIgnorePatterns = [
3
+ ".agent/**",
4
+ ".agents/**",
5
+ ".claude/**",
6
+ ".codex/**",
7
+ ".continue/**",
8
+ ".cursor/**",
9
+ ".gemini/**",
10
+ ".opencode/**",
11
+ ".pi/**",
12
+ ".roo/**",
13
+ ".windsurf/**"
14
+ ];
15
+ const unsafeAnyRules = [
16
+ "typescript/no-explicit-any",
17
+ "typescript/no-unsafe-argument",
18
+ "typescript/no-unsafe-assignment",
19
+ "typescript/no-unsafe-call",
20
+ "typescript/no-unsafe-member-access",
21
+ "typescript/no-unsafe-return"
22
+ ];
23
+ const typeAware = process.env["REF0_LINT_TYPES"] !== "none";
24
+ /**
25
+ * The format and lint settings every ref-0 repo shares. A repo's `lint/config.ts` merges its own
26
+ * over them with `merge`, and registers the shared plugins beside its own.
27
+ */
28
+ const base = {
29
+ fmt: {
30
+ ignorePatterns: agentToolingIgnorePatterns,
31
+ semi: true,
32
+ singleQuote: true
33
+ },
34
+ lint: {
35
+ ignorePatterns: [...agentToolingIgnorePatterns, "**/dist/**"],
36
+ options: {
37
+ reportUnusedDisableDirectives: typeAware ? "error" : "off",
38
+ typeAware,
39
+ typeCheck: false
40
+ },
41
+ plugins: ["typescript", "import"],
42
+ rules: {
43
+ "oxc/no-accumulating-spread": "error",
44
+ "anti-slop/no-array-filter-map": "error",
45
+ "anti-slop/no-reduce-accumulator-copy": "error",
46
+ "anti-slop/no-chained-type-assertions": "error",
47
+ "anti-slop/no-conditional-empty-object-spread": "error",
48
+ "anti-slop/no-known-value-widening": "error",
49
+ "anti-slop/no-module-mocking": "error",
50
+ "anti-slop/no-object-parameters": "error",
51
+ "anti-slop/no-reflect-apply": "error",
52
+ "anti-slop/no-reflect-get": "error",
53
+ "anti-slop/no-runtime-typeof": "error",
54
+ "anti-slop/no-shape-in-symbol-names": "error",
55
+ "anti-slop/no-unknown-parameters": "error",
56
+ "anti-slop/no-unknown-returns": "error",
57
+ "anti-slop/no-unknown-type-aliases": "error",
58
+ "anti-slop/no-unsafe-dictionary-type": "error",
59
+ "anti-slop/no-widen-then-assert": "error",
60
+ "anti-slop/require-readable-spacing": "error",
61
+ "anti-slop/require-safety-comment-for-type-assertion": "error",
62
+ "anti-slop-effect/no-manual-effect-error-tag": "error",
63
+ "anti-slop-effect/no-manual-tag-comparison": "error",
64
+ "anti-slop-effect/no-manual-tagged-construction": "error",
65
+ "anti-slop-effect/no-service-constructor-imports": "error",
66
+ "anti-slop-effect/prefer-effect-match": "error",
67
+ "t3code/no-global-process-runtime": "error",
68
+ "t3code/no-inline-schema-compile": "error",
69
+ "t3code/no-manual-effect-runtime-in-tests": "error",
70
+ "t3code/no-native-title-tooltip": "error",
71
+ "t3code/no-test-in-loop": "error",
72
+ "t3code/no-unscoped-has": "error",
73
+ ...Object.fromEntries(unsafeAnyRules.map((rule) => [rule, "error"]))
74
+ },
75
+ overrides: [
76
+ {
77
+ files: ["**/*.test.ts", "**/*.test.tsx"],
78
+ plugins: ["vitest"],
79
+ rules: { "ref0-generic/seeded-properties": "error" }
80
+ },
81
+ {
82
+ files: [
83
+ "**/*.test.ts",
84
+ "**/*.test.tsx",
85
+ "**/*.test-d.ts"
86
+ ],
87
+ rules: Object.fromEntries(unsafeAnyRules.map((rule) => [rule, "off"]))
88
+ },
89
+ {
90
+ files: ["**/index.ts"],
91
+ rules: { "ref0-generic/index-barrel-only": "error" }
92
+ },
93
+ {
94
+ files: ["**/*"],
95
+ rules: {
96
+ "import/no-cycle": "error",
97
+ "typescript/no-import-type-side-effects": "error",
98
+ "ref0-generic/export-type-side-effects": "error",
99
+ "import/default": "off",
100
+ "import/namespace": "off"
101
+ }
102
+ }
103
+ ]
104
+ }
105
+ };
106
+ /** Two lists, the shared one first, or nothing when neither config sets it. */
107
+ const lists = (shared, own) => shared == null && own == null ? void 0 : [...shared ?? [], ...own ?? []];
108
+ /** Two objects, the shared one's keys overwritten by the repo's, or nothing when neither sets it. */
109
+ const objects = (shared, own) => shared === void 0 && own === void 0 ? void 0 : {
110
+ ...shared,
111
+ ...own
112
+ };
113
+ /**
114
+ * `local` over `base`, base first: ignores, plugins and overrides are joined, and rules and options
115
+ * are merged, so a local rule wins over the shared one. Any other setting is local's when it has
116
+ * one.
117
+ */
118
+ const merge = (base, local) => {
119
+ const shared = base;
120
+ const own = local;
121
+ const joined = Object.entries({
122
+ ignorePatterns: lists(shared.ignorePatterns, own.ignorePatterns),
123
+ plugins: lists(shared.plugins, own.plugins),
124
+ jsPlugins: lists(shared.jsPlugins, own.jsPlugins),
125
+ overrides: lists(shared.overrides, own.overrides),
126
+ rules: objects(shared.rules, own.rules),
127
+ options: objects(shared.options, own.options)
128
+ }).filter(([, setting]) => setting !== void 0);
129
+ return {
130
+ ...base,
131
+ ...local,
132
+ ...Object.fromEntries(joined)
133
+ };
134
+ };
135
+ export { base, merge };
@@ -0,0 +1,45 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/effect-encoding.ts
3
+ /** Whether `node` calls `name` as a method, as `x.name(…)`. */
4
+ const callsMethod = (node, name) => node?.type === "CallExpression" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === name;
5
+ /** Whether `node` is the literal `value`. */
6
+ const isLiteral = (node, value) => node?.type === "Literal" && node.value === value;
7
+ /** Whether `node` is `x.toString(16).padStart(2, '0')`: one byte as two hex digits. */
8
+ const hexesByte = (node) => callsMethod(node, "padStart") && isLiteral(node.arguments[0], 2) && isLiteral(node.arguments[1], "0") && node.callee.type === "MemberExpression" && callsMethod(node.callee.object, "toString") && isLiteral(node.callee.object.arguments[0], 16);
9
+ /** Whether `node` is a function whose result is one byte as two hex digits. */
10
+ const hexesEachByte = (node) => {
11
+ if (node?.type !== "ArrowFunctionExpression" && node?.type !== "FunctionExpression") return false;
12
+ if (node.body?.type !== "BlockStatement") return hexesByte(node.body);
13
+ const last = node.body.body.at(-1);
14
+ return last?.type === "ReturnStatement" && hexesByte(last.argument);
15
+ };
16
+ /** Whether `node` calls `Array.from(…)`. */
17
+ const callsArrayFrom = (node) => callsMethod(node, "from") && node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "Array";
18
+ /** Whether `node` maps bytes to hex digits: `bytes.map(hexOf)` or `Array.from(bytes, hexOf)`. */
19
+ const mapsBytesToHex = (node) => callsMethod(node, "map") && hexesEachByte(node.arguments[0]) || callsArrayFrom(node) && hexesEachByte(node.arguments[1]);
20
+ /** Whether `node` is `String.fromCharCode(...bytes)`: bytes as a binary string for `btoa`. */
21
+ const binaryStringOf = (node) => callsMethod(node, "fromCharCode") && node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "String" && node.arguments[0]?.type === "SpreadElement";
22
+ /**
23
+ * Bytes become hex, base64 or base64url through Effect's `Hex`, `Base64` and `Base64Url`, from
24
+ * `effect/encoding`, not a loop or `btoa` written again at each call site. Code that loads no
25
+ * Effect, such as the compiler's isolate and the SDK's root, is out of the rule's files.
26
+ */
27
+ const effectEncodingRule = defineRule({
28
+ meta: { messages: {
29
+ handHex: "Encode bytes as hex with `Hex.encode(bytes)` from 'effect/encoding', not by mapping each byte through `toString(16)`.",
30
+ handBase64: "Encode bytes as base64 with `Base64.encode(bytes)`, or base64url with `Base64Url.encode(bytes)`, from 'effect/encoding', not `btoa(String.fromCharCode(...))`."
31
+ } },
32
+ create(context) {
33
+ return { CallExpression(node) {
34
+ if (callsMethod(node, "join") && isLiteral(node.arguments[0], "") && node.callee.type === "MemberExpression" && mapsBytesToHex(node.callee.object)) context.report({
35
+ node,
36
+ messageId: "handHex"
37
+ });
38
+ if (node.callee.type === "Identifier" && node.callee.name === "btoa" && binaryStringOf(node.arguments[0])) context.report({
39
+ node,
40
+ messageId: "handBase64"
41
+ });
42
+ } };
43
+ }
44
+ });
45
+ export { effectEncodingRule };
@@ -0,0 +1,81 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join, relative, resolve, sep } from "node:path";
3
+ import { Schema } from "effect";
4
+ import { defineRule } from "vite-plus/lint/plugins";
5
+ // src/lint/generic/entry-reexports.ts
6
+ /**
7
+ * What the rule takes: the repo's root, as an absolute path; `entries`, the folders from the root
8
+ * of the packages whose entry files it checks, such as `packages/ui`; and `condition`, the export
9
+ * condition that names an entry point's source, such as `@ref0/source`, read when an entry point
10
+ * maps conditions to files.
11
+ */
12
+ const Options = Schema.Struct({
13
+ root: Schema.String,
14
+ entries: Schema.Array(Schema.String),
15
+ condition: Schema.String
16
+ });
17
+ const decodeOptions = Schema.decodeUnknownSync(Schema.Tuple([Options]));
18
+ /** What the rule reads of a package's `package.json`: each entry point's file, or its files. */
19
+ const decodeManifest = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Struct({ exports: Schema.optionalKey(Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Record(Schema.String, Schema.String)]))) })));
20
+ const isString = Schema.is(Schema.String);
21
+ /** A path from the root, with `/` between its parts. */
22
+ const fromRoot = (root, path) => relative(root, path).split(sep).join("/");
23
+ /**
24
+ * Each file the packages' `exports` name, from the root, such as `packages/ui/src/cast.ts`: an
25
+ * entry point's file, or its file under the condition. Read once for each set of options, so a
26
+ * lint run reads each manifest once.
27
+ */
28
+ const entryFilesOf = (() => {
29
+ const read = /* @__PURE__ */ new Map();
30
+ return ({ root, entries, condition }) => {
31
+ const key = JSON.stringify([
32
+ root,
33
+ entries,
34
+ condition
35
+ ]);
36
+ const known = read.get(key);
37
+ if (known !== void 0) return known;
38
+ const files = new Set(entries.flatMap((directory) => {
39
+ const manifest = decodeManifest(readFileSync(join(root, directory, "package.json"), "utf8"));
40
+ return Object.values(manifest.exports ?? {}).flatMap((target) => {
41
+ const file = isString(target) ? target : target[condition];
42
+ return file === void 0 ? [] : [fromRoot(root, join(root, directory, file.replace(/^\.\//, "")))];
43
+ });
44
+ }));
45
+ read.set(key, files);
46
+ return files;
47
+ };
48
+ })();
49
+ const entryReexportsRule = defineRule({
50
+ meta: {
51
+ messages: { byName: "This file is an entry point of its package, so it re-exports by name: write `export { a, type B } from`, with only the names another package or app imports, and `export type { … } from` when every name is a type." },
52
+ schema: [{
53
+ type: "object",
54
+ properties: {
55
+ root: { type: "string" },
56
+ entries: {
57
+ type: "array",
58
+ items: { type: "string" }
59
+ },
60
+ condition: { type: "string" }
61
+ },
62
+ required: [
63
+ "root",
64
+ "entries",
65
+ "condition"
66
+ ],
67
+ additionalProperties: false
68
+ }]
69
+ },
70
+ create(context) {
71
+ const [options] = decodeOptions(context.options);
72
+ if (!entryFilesOf(options).has(fromRoot(options.root, resolve(context.filename)))) return {};
73
+ return { ExportAllDeclaration(node) {
74
+ context.report({
75
+ node,
76
+ messageId: "byName"
77
+ });
78
+ } };
79
+ }
80
+ });
81
+ export { entryReexportsRule };
@@ -0,0 +1,65 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/env-at-entrypoints.ts
3
+ /**
4
+ * Whether a type is the Worker's `Env`, or holds it whole: `Env`, `Pick<Env, …>`, `Env | …`. A
5
+ * single binding's type, such as `Env['STORE']`, isn't: it names what's used, not every binding.
6
+ */
7
+ const holdsEnv = (type) => {
8
+ switch (type.type) {
9
+ case "TSTypeReference": return type.typeName.type === "Identifier" && type.typeName.name === "Env" || (type.typeArguments?.params.some(holdsEnv) ?? false);
10
+ case "TSUnionType":
11
+ case "TSIntersectionType": return type.types.some(holdsEnv);
12
+ case "TSTypeOperator": return holdsEnv(type.typeAnnotation);
13
+ default: return false;
14
+ }
15
+ };
16
+ /** A parameter's type annotation, under a default, a rest or a constructor's `readonly`. */
17
+ const annotationOf = (parameter) => {
18
+ switch (parameter.type) {
19
+ case "TSParameterProperty": return annotationOf(parameter.parameter);
20
+ case "AssignmentPattern": return annotationOf(parameter.left);
21
+ default: return parameter.typeAnnotation;
22
+ }
23
+ };
24
+ /**
25
+ * Business logic takes services, not the Worker's `env`: only an entrypoint reads `env`, and builds
26
+ * the bindings' layer from it. A class that extends another may take `env` in its constructor,
27
+ * since the runtime hands it to each Durable Object, Workflow and `WorkerEntrypoint` there; any
28
+ * other entrypoint file is named in the rule's `excludeFiles`.
29
+ */
30
+ const envAtEntrypointsRule = defineRule({
31
+ meta: { messages: { envParameter: "Take the services this needs, not `env`: only an entrypoint reads `env`, to build the bindings layer." } },
32
+ create(context) {
33
+ const constructors = /* @__PURE__ */ new Set();
34
+ const checkClass = (node) => {
35
+ if (node.superClass === null) return;
36
+ for (const member of node.body.body) if (member.type === "MethodDefinition" && member.kind === "constructor") constructors.add(member.value);
37
+ };
38
+ const checkFunction = (node) => {
39
+ if (constructors.has(node)) return;
40
+ for (const parameter of node.params) {
41
+ const annotation = annotationOf(parameter);
42
+ if (annotation != null && holdsEnv(annotation.typeAnnotation)) context.report({
43
+ node: parameter,
44
+ messageId: "envParameter"
45
+ });
46
+ }
47
+ };
48
+ const checkProperty = (node) => {
49
+ if (node.typeAnnotation != null && holdsEnv(node.typeAnnotation.typeAnnotation)) context.report({
50
+ node,
51
+ messageId: "envParameter"
52
+ });
53
+ };
54
+ return {
55
+ ClassDeclaration: checkClass,
56
+ ClassExpression: checkClass,
57
+ ArrowFunctionExpression: checkFunction,
58
+ FunctionDeclaration: checkFunction,
59
+ FunctionExpression: checkFunction,
60
+ PropertyDefinition: checkProperty,
61
+ TSPropertySignature: checkProperty
62
+ };
63
+ }
64
+ });
65
+ export { envAtEntrypointsRule };
@@ -0,0 +1,22 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/export-type-side-effects.ts
3
+ /**
4
+ * A re-export whose names are all marked `type`, such as `export { type A } from './a'`, still
5
+ * loads `./a`: `verbatimModuleSyntax` keeps it as `export {} from './a'`. `import/no-cycle` skips
6
+ * it as type-only, so it asks for `export type { A } from './a'`, which TypeScript erases, as
7
+ * `typescript/no-import-type-side-effects` does for an import.
8
+ */
9
+ const exportTypeSideEffectsRule = defineRule({
10
+ meta: { messages: { exportType: "Every name this re-export takes is a type, yet it still loads its module at runtime: write it as `export type { … } from`" } },
11
+ create(context) {
12
+ return { ExportNamedDeclaration(node) {
13
+ const names = node.specifiers;
14
+ if (node.source === null || node.exportKind === "type" || names.length === 0) return;
15
+ if (names.every((name) => name.exportKind === "type")) context.report({
16
+ node,
17
+ messageId: "exportType"
18
+ });
19
+ } };
20
+ }
21
+ });
22
+ export { exportTypeSideEffectsRule };
@@ -0,0 +1,14 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/index-barrel.ts
3
+ const indexBarrelOnlyRule = defineRule({
4
+ meta: { messages: { onlyReExports: "index.ts files are barrels only; move implementations to a named module and re-export from it" } },
5
+ create(context) {
6
+ return { Program(node) {
7
+ for (const statement of node.body) if (!((statement.type === "ExportAllDeclaration" || statement.type === "ExportNamedDeclaration") && statement.source !== null)) context.report({
8
+ node: statement,
9
+ messageId: "onlyReExports"
10
+ });
11
+ } };
12
+ }
13
+ });
14
+ export { indexBarrelOnlyRule };
@@ -0,0 +1,39 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/log-messages.ts
3
+ /** Effect's log calls, whose first argument is the line's message. */
4
+ const logCalls = /* @__PURE__ */ new Set([
5
+ "log",
6
+ "logDebug",
7
+ "logInfo",
8
+ "logWarning",
9
+ "logError",
10
+ "logFatal",
11
+ "logTrace"
12
+ ]);
13
+ /** First arguments that are never a message: an object or array literal, or a new value. */
14
+ const notMessages = /* @__PURE__ */ new Set([
15
+ "ObjectExpression",
16
+ "ArrayExpression",
17
+ "NewExpression"
18
+ ]);
19
+ /**
20
+ * A log line has a message: a line logged with an error or fields first gets `message: ''`, which
21
+ * a log viewer that groups errors by message puts with every other line that has none. An
22
+ * identifier or any other expression passes, since lint can't see its type.
23
+ */
24
+ const logMessagesRule = defineRule({
25
+ meta: { messages: { noMessage: "Pass `Effect.{{name}}` its message first, and the error or fields after it: a line without one is logged with an empty message." } },
26
+ create(context) {
27
+ return { CallExpression(node) {
28
+ const callee = node.callee;
29
+ if (callee.type !== "MemberExpression" || callee.object.type !== "Identifier" || callee.object.name !== "Effect" || callee.computed || callee.property.type !== "Identifier" || !logCalls.has(callee.property.name)) return;
30
+ const [first] = node.arguments;
31
+ if (first === void 0 || notMessages.has(first.type)) context.report({
32
+ node,
33
+ messageId: "noMessage",
34
+ data: { name: callee.property.name }
35
+ });
36
+ } };
37
+ }
38
+ });
39
+ export { logMessagesRule };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Rules any ref-0 repo can turn on, each over the files its config names. Only `entry-reexports`
3
+ * takes options: the repo's root, its packages and its source condition.
4
+ */
5
+ declare const _default: import("vite-plus/lint/plugins").Plugin;
6
+ export { _default as default };
@@ -0,0 +1,26 @@
1
+ import { effectEncodingRule } from "./effect-encoding.mjs";
2
+ import { entryReexportsRule } from "./entry-reexports.mjs";
3
+ import { envAtEntrypointsRule } from "./env-at-entrypoints.mjs";
4
+ import { exportTypeSideEffectsRule } from "./export-type-side-effects.mjs";
5
+ import { indexBarrelOnlyRule } from "./index-barrel.mjs";
6
+ import { logMessagesRule } from "./log-messages.mjs";
7
+ import { seededPropertiesRule } from "./seeded-properties.mjs";
8
+ import { definePlugin } from "vite-plus/lint/plugins";
9
+ // src/lint/generic/plugin.ts
10
+ /**
11
+ * Rules any ref-0 repo can turn on, each over the files its config names. Only `entry-reexports`
12
+ * takes options: the repo's root, its packages and its source condition.
13
+ */
14
+ var plugin_default = definePlugin({
15
+ meta: { name: "ref0-generic" },
16
+ rules: {
17
+ "effect-encoding": effectEncodingRule,
18
+ "entry-reexports": entryReexportsRule,
19
+ "env-at-entrypoints": envAtEntrypointsRule,
20
+ "export-type-side-effects": exportTypeSideEffectsRule,
21
+ "index-barrel-only": indexBarrelOnlyRule,
22
+ "log-messages": logMessagesRule,
23
+ "seeded-properties": seededPropertiesRule
24
+ }
25
+ });
26
+ export { plugin_default as default };
@@ -0,0 +1,78 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ // src/lint/generic/seeded-properties.ts
3
+ const isNamed = (node, names) => node.type === "Identifier" && names.has(node.name);
4
+ /** A tester, `it`, or one of its own, as `it.effect` or `it.live`. */
5
+ const isTester = (node, names) => isNamed(node, names.testers) || node.type === "MemberExpression" && !node.computed && isNamed(node.object, names.testers);
6
+ const isKey = (node, key) => node.type === "Property" && !node.computed && node.key.type === "Identifier" && node.key.name === key;
7
+ /** Whether a call is a property test: `prop`, `it.prop` or a tester's own, as `it.effect.prop`. */
8
+ const isProperty = (node, names) => {
9
+ const callee = node.callee;
10
+ if (isNamed(callee, names.props)) return true;
11
+ return callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "prop" && isTester(callee.object, names);
12
+ };
13
+ /**
14
+ * Whether an object's members, read as JavaScript writes them, last one winning, leave `key` set
15
+ * as `holds` says. A spread may set it, so it counts as set, unless a later member sets it again.
16
+ */
17
+ const leaves = (node, key, holds) => {
18
+ let set = false;
19
+ for (const each of node.properties) if (each.type === "SpreadElement") set = true;
20
+ else if (isKey(each, key)) set = holds(each.value);
21
+ return set;
22
+ };
23
+ /** A seed that isn't left `undefined`. */
24
+ const isSeed = (value) => !(value.type === "Identifier" && value.name === "undefined");
25
+ /**
26
+ * Whether a property's options set its seed. A name, such as `fuzzed`, is read as seeded, since
27
+ * its value is out of sight. An object is seeded when it spreads one, as `{ ...fuzzed, timeout }`
28
+ * does, or its `arbitrary` sets a `seed`, and nothing after takes it away. A number is a timeout.
29
+ */
30
+ const isSeeded = (options) => {
31
+ if (options === void 0 || options.type === "Literal") return false;
32
+ if (options.type !== "ObjectExpression") return true;
33
+ return leaves(options, "arbitrary", (arbitrary) => arbitrary.type !== "ObjectExpression" || leaves(arbitrary, "seed", isSeed));
34
+ };
35
+ /**
36
+ * A property test runs from one seed, `fuzzed`'s, as the `fuzzing` skill says. Without one,
37
+ * fast-check draws a new seed each run, so what a property finds shows up as a flake that a retry
38
+ * hides, and the next run can't reach it again.
39
+ */
40
+ const seededPropertiesRule = defineRule({
41
+ meta: { messages: { unseeded: "Pass `fuzzed`, from the package's testing module, as the property's last argument, or spread it into its options, so every run draws the same cases, as the fuzzing skill says." } },
42
+ create(context) {
43
+ const names = {
44
+ testers: /* @__PURE__ */ new Set(["it", "test"]),
45
+ props: /* @__PURE__ */ new Set(),
46
+ layers: /* @__PURE__ */ new Set()
47
+ };
48
+ const kinds = /* @__PURE__ */ new Map([
49
+ ["it", names.testers],
50
+ ["test", names.testers],
51
+ ["prop", names.props],
52
+ ["layer", names.layers]
53
+ ]);
54
+ return {
55
+ ImportDeclaration(node) {
56
+ if (node.source.value !== "@effect/vitest") return;
57
+ for (const each of node.specifiers) {
58
+ if (each.type !== "ImportSpecifier" || each.imported.type !== "Identifier") continue;
59
+ kinds.get(each.imported.name)?.add(each.local.name);
60
+ }
61
+ },
62
+ CallExpression(node) {
63
+ const opened = node.callee;
64
+ if (opened.type === "CallExpression" && (isNamed(opened.callee, names.layers) || opened.callee.type === "MemberExpression" && !opened.callee.computed && opened.callee.property.type === "Identifier" && opened.callee.property.name === "layer" && isTester(opened.callee.object, names))) {
65
+ for (const each of node.arguments) if (each.type === "ArrowFunctionExpression" || each.type === "FunctionExpression") {
66
+ const [tester] = each.params;
67
+ if (tester?.type === "Identifier") names.testers.add(tester.name);
68
+ }
69
+ }
70
+ if (isProperty(node, names) && !isSeeded(node.arguments[3])) context.report({
71
+ node: node.callee,
72
+ messageId: "unseeded"
73
+ });
74
+ }
75
+ };
76
+ }
77
+ });
78
+ export { seededPropertiesRule };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The shared Oxlint plugins, each the absolute path of its file, which a repo's config hands
3
+ * Oxlint in `jsPlugins`. Each plugin names its own rules' prefix: `anti-slop`, `anti-slop-effect`,
4
+ * `t3code` and `ref0-generic`.
5
+ */
6
+ export declare const antiSlop: string;
7
+ export declare const antiSlopEffect: string;
8
+ export declare const t3code: string;
9
+ export declare const generic: string;
@@ -0,0 +1,14 @@
1
+ import { fileURLToPath } from "node:url";
2
+ // src/lint/plugins.ts
3
+ const extension = import.meta.url.endsWith(".ts") ? ".ts" : ".mjs";
4
+ const pathOf = (plugin) => fileURLToPath(new URL(`./${plugin}/plugin${extension}`, import.meta.url));
5
+ /**
6
+ * The shared Oxlint plugins, each the absolute path of its file, which a repo's config hands
7
+ * Oxlint in `jsPlugins`. Each plugin names its own rules' prefix: `anti-slop`, `anti-slop-effect`,
8
+ * `t3code` and `ref0-generic`.
9
+ */
10
+ const antiSlop = pathOf("anti-slop");
11
+ const antiSlopEffect = pathOf("anti-slop/effect");
12
+ const t3code = pathOf("t3code");
13
+ const generic = pathOf("generic");
14
+ export { antiSlop, antiSlopEffect, generic, t3code };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 T3 Tools Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # T3 Code lint rules provenance
2
+
3
+ - Source: <https://github.com/pingdotgg/t3code>, MIT, its license beside this file
4
+ - Source commit: `429c625a8515f9c2e4af28c488fbf32ce7789645`
5
+ - Source snapshot: `oxlint-plugin-t3code/` at that commit: `utils.ts` and six of its nine rules
6
+ - Installed plugin: `src/lint/t3code/plugin.ts`, which `@ref0/workspace/lint/plugins` exports as `t3code`; its rules are `t3code/*`
7
+ - Oxlint plugin API: imported from `vite-plus/lint/plugins` instead of `@oxlint/plugins`, so it always matches the Oxlint version bundled by Vite+, as with anti-slop.
8
+
9
+ | Rule | What it stops |
10
+ | --- | --- |
11
+ | `no-manual-effect-runtime-in-tests` | `Effect.runPromise`, `runSync` and the rest in test files, instead of `it.effect` with test layers |
12
+ | `no-test-in-loop` | `it`, `test` or `describe` called inside a `for` loop, instead of `.each` |
13
+ | `no-inline-schema-compile` | `Schema.decode*`, `encode*` or `is` compiled inside a function body, so it's rebuilt on every call |
14
+ | `no-global-process-runtime` | `process.platform` and `process.arch`, or `os.platform()` and `os.arch()`, read directly instead of through an Effect service |
15
+ | `no-native-title-tooltip` | The native `title` attribute used as a tooltip on an intrinsic element |
16
+ | `no-unscoped-has` | A Tailwind arbitrary variant whose `:has()` isn't anchored, which makes Chrome restyle the whole page on any DOM change |
17
+
18
+ Left out: `namespace-node-imports` (taste), `no-hermes-unsupported-apis` and `no-mobile-uniwind-theme-escape-hatches` (React Native).
19
+
20
+ ## Changes from the source
21
+
22
+ - `no-global-process-runtime`: the message and description no longer name T3 Code's `HostProcess` services; they say to read the value through an Effect service.
23
+ - `no-native-title-tooltip`: the message names our `Tooltip` component without T3 Code's subcomponent names.
24
+ - The upstream rule tests aren't copied. They run in T3 Code's CI at the source commit; when updating, run them there or bring them over with their harness.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite-plus/lint/plugins").Plugin;
2
+ export { _default as default };
@@ -0,0 +1,20 @@
1
+ import no_global_process_runtime_default from "./rules/no-global-process-runtime.mjs";
2
+ import no_inline_schema_compile_default from "./rules/no-inline-schema-compile.mjs";
3
+ import no_manual_effect_runtime_in_tests_default from "./rules/no-manual-effect-runtime-in-tests.mjs";
4
+ import no_native_title_tooltip_default from "./rules/no-native-title-tooltip.mjs";
5
+ import no_test_in_loop_default from "./rules/no-test-in-loop.mjs";
6
+ import no_unscoped_has_default from "./rules/no-unscoped-has.mjs";
7
+ import { definePlugin } from "vite-plus/lint/plugins";
8
+ // src/lint/t3code/plugin.ts
9
+ var plugin_default = definePlugin({
10
+ meta: { name: "t3code" },
11
+ rules: {
12
+ "no-global-process-runtime": no_global_process_runtime_default,
13
+ "no-inline-schema-compile": no_inline_schema_compile_default,
14
+ "no-manual-effect-runtime-in-tests": no_manual_effect_runtime_in_tests_default,
15
+ "no-native-title-tooltip": no_native_title_tooltip_default,
16
+ "no-test-in-loop": no_test_in_loop_default,
17
+ "no-unscoped-has": no_unscoped_has_default
18
+ }
19
+ });
20
+ export { plugin_default as default };