@collective-intelligence/lint 0.1.26 → 0.1.28

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.
package/README.md CHANGED
@@ -73,12 +73,15 @@ the `collective-intelligence` pack installs the skill and adds the plugin with
73
73
 
74
74
  ## Rules
75
75
 
76
- | Rule | Enforces | Group |
77
- | -------------------------------- | ------------------------------------------------------------------------------------------ | ------------------ |
78
- | `ci-solution/package-entrypoint` | An import of another package targets an entrypoint declared in its `package.json` exports. | Package boundaries |
79
- | `ci-solution/subpath-imports` | Imports between subpath folders follow the allowed direction. | Solution layout |
80
- | `ci-solution/subpath-entrypoint` | An import from another subpath folder targets the folder or its index file. | Solution layout |
81
- | `ci-solution/subpath-index` | Every subpath folder has an `index.ts` or `index.tsx`. | Solution layout |
76
+ | Rule | Enforces | Group |
77
+ | -------------------------------- | -------------------------------------------------------------------------------------------- | ------------------ |
78
+ | `ci-solution/package-entrypoint` | An import of another package targets an entrypoint declared in its `package.json` exports. | Package boundaries |
79
+ | `ci-solution/subpath-imports` | Imports between subpath folders follow the allowed direction. | Solution layout |
80
+ | `ci-solution/subpath-entrypoint` | An import from another subpath folder targets the folder or its index file. | Solution layout |
81
+ | `ci-solution/subpath-index` | Every subpath folder has an `index.ts` or `index.tsx`. | Solution layout |
82
+ | `ci-solution/effect-subpath` | An SDK Effect API comes from the SDK's `/effect` subpath; deprecated SDK paths are reported. | Effect convention |
83
+ | `ci-solution/no-run-in-view` | A view module calls no `fetch` and runs no Effect. | Effect convention |
84
+ | `ci-solution/effect-actors` | XState side-effect actors are `fromEffect` actors. | Effect convention |
82
85
 
83
86
  ### Package boundaries
84
87
 
@@ -150,6 +153,67 @@ import { rate } from "../domain/rates" // reported
150
153
  Every subpath folder under `src/` has an `index.ts` or `index.tsx` entrypoint.
151
154
  The rule reports each file in a folder that has neither.
152
155
 
156
+ ### Effect convention
157
+
158
+ An app keeps its side effects in XState machines: each side effect is a
159
+ `fromEffect` actor, and views read data through TanStack Query. These rules
160
+ check the parts of that convention that imports and calls show.
161
+
162
+ #### `effect-subpath`
163
+
164
+ A Collective Intelligence SDK (`@collective-intelligence/*`) exposes its Effect
165
+ API at `<sdk>/effect` and `<sdk>/effect/<adapter>`. The rule reports an SDK path
166
+ that names Effect elsewhere: a `<sdk>-effect` package, or an `effect` segment
167
+ below another subpath. It also reports each deprecated SDK path with its
168
+ replacement:
169
+
170
+ | Deprecated path | Replacement |
171
+ | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
172
+ | `@collective-intelligence/external-apps-server-sdk/runtime/effect` | `@collective-intelligence/external-apps-server-sdk/effect` |
173
+ | `@collective-intelligence/external-apps-server-sdk/persistence/drizzle/effect` | `@collective-intelligence/external-apps-server-sdk/effect`; `layerNodePostgres` and `NodePostgresLayerOptions` from `@collective-intelligence/external-apps-server-sdk/effect/node-postgres` |
174
+ | `@collective-intelligence/external-apps-server-sdk/runtime/next` | `@collective-intelligence/external-apps-server-sdk/next` |
175
+ | `@collective-intelligence/extensions-sdk-backend-effect` | `@collective-intelligence/extensions-sdk-backend/effect` |
176
+
177
+ ```ts
178
+ import { CiClient } from "@collective-intelligence/external-apps-client-sdk/effect" // valid
179
+ import { createClient } from "@collective-intelligence/external-apps-client-sdk" // valid
180
+ import { Realtime } from "@collective-intelligence/external-apps-client-sdk/realtime/effect" // reported
181
+ import { CiRuntime } from "@collective-intelligence/external-apps-server-sdk/runtime/effect" // reported: deprecated
182
+ ```
183
+
184
+ #### `no-run-in-view`
185
+
186
+ A view module is a `.tsx` or `.jsx` file, or a file in the `views/` subpath of a
187
+ solution package. The rule reports a call of the global `fetch` (also
188
+ `globalThis.fetch` and `window.fetch`) and each use of an Effect run function
189
+ (`runPromise`, `runSync`, `runFork` and the other `run*` functions of `Effect`
190
+ and `ManagedRuntime`):
191
+
192
+ - a read from any object, called or passed as a value: `Effect.runPromise(x)`,
193
+ `runtime.runSync(x)`, `x.pipe(Effect.runPromise)`;
194
+ - a key in a destructuring pattern: `const { runFork } = runtime`;
195
+ - a named import from `effect`, `effect/*` or `@effect/*`:
196
+ `import { runPromise } from "effect/Effect"`.
197
+
198
+ A constant name in brackets or quotes counts too: `window["fetch"](url)`,
199
+ ``Effect[`runSync`](x)`` and `const { "runFork": fork } = runtime` are reported.
200
+ A local binding named `fetch`, `globalThis` or `window`, a method such as
201
+ `cache.fetch`, a name in brackets that only runtime gives (`Effect[key]`) and an
202
+ object literal key such as `{ runPromise: run }` are not reported. To allow the
203
+ calls in view tests, turn the rule off for the test files in an `overrides`
204
+ entry.
205
+
206
+ #### `effect-actors`
207
+
208
+ The rule reports each `fromPromise`, `fromCallback`, `fromObservable` and
209
+ `fromEventObservable` that an import, a re-export or a namespace import
210
+ (`XState.fromPromise`, `XState["fromPromise"]`) takes from `xstate` or
211
+ `xstate/*`. Make side-effect actors with `fromEffect` from
212
+ `@collective-intelligence/external-apps-client-sdk-react/effect`. Machines and
213
+ `fromTransition` actors have no side effects and are not reported. A local name
214
+ that shadows the namespace import, such as a parameter named `XState`, is not
215
+ reported.
216
+
153
217
  ## Adding a rule
154
218
 
155
219
  Each rule is a plain Oxlint rule in its own folder, `src/rules/<rule>/`:
@@ -159,8 +223,10 @@ Each rule is a plain Oxlint rule in its own folder, `src/rules/<rule>/`:
159
223
  - `group`: the rule group in the table above (add a group to `RuleGroup`
160
224
  when no group fits);
161
225
  - `rule`: the rule from `defineRule` of `@oxlint/plugins`, with a
162
- `messages` entry in `meta` for each finding. `moduleSpecifiers`
163
- (`src/rule.ts`) builds a visitor that checks every module specifier.
226
+ `messages` entry in `meta` for each finding. `src/rule.ts` holds the
227
+ shared helpers: `moduleSpecifiers` builds a visitor that checks every
228
+ module specifier, `staticPropertyName` reads a constant property name, and
229
+ `declaredVariable` finds the variable that a name refers to.
164
230
 
165
231
  A rule reads the workspace through `src/workspace/`: `packageOf` and
166
232
  `installedPackage` find package manifests, `declaresEntrypoint` checks
package/dist/index.js CHANGED
@@ -1,12 +1,32 @@
1
1
  // src/index.ts
2
2
  import { definePlugin } from "@oxlint/plugins";
3
3
 
4
- // src/rules/package-entrypoint/package-entrypoint.ts
4
+ // src/rules/effect-actors/effect-actors.ts
5
5
  import { defineRule } from "@oxlint/plugins";
6
- import path2 from "node:path";
7
6
 
8
7
  // src/rule.ts
9
8
  var isStringLiteral = (node) => node?.type === "Literal" && String(node.value) === node.value;
9
+ var staticPropertyName = (key, computed) => {
10
+ if (key.type === "Identifier") {
11
+ return computed ? null : key.name;
12
+ }
13
+ if (isStringLiteral(key)) {
14
+ return key.value;
15
+ }
16
+ if (key.type === "TemplateLiteral" && key.expressions.length === 0) {
17
+ return key.quasis[0]?.value.cooked ?? null;
18
+ }
19
+ return null;
20
+ };
21
+ var declaredVariable = (sourceCode, node) => {
22
+ for (let scope = sourceCode.getScope(node);scope !== null; scope = scope.upper) {
23
+ const variable = scope.set.get(node.name);
24
+ if (variable !== undefined && variable.defs.length > 0) {
25
+ return variable;
26
+ }
27
+ }
28
+ return null;
29
+ };
10
30
  var moduleSpecifiers = (check) => {
11
31
  const visit = (node) => {
12
32
  if (isStringLiteral(node)) {
@@ -34,6 +54,69 @@ var moduleSpecifiers = (check) => {
34
54
  };
35
55
  };
36
56
 
57
+ // src/rules/effect-actors/effect-actors.ts
58
+ var SIDE_EFFECT_ACTORS = new Set([
59
+ "fromCallback",
60
+ "fromEventObservable",
61
+ "fromObservable",
62
+ "fromPromise"
63
+ ]);
64
+ var messages = {
65
+ sideEffectActor: "`{{name}}` makes XState actor logic outside Effect. Make the actor with `fromEffect` from `@collective-intelligence/external-apps-client-sdk-react/effect`."
66
+ };
67
+ var isXState = (source) => source === "xstate" || source.startsWith("xstate/");
68
+ var nameOf = (node) => node.type === "Literal" ? node.value : node.name;
69
+ var isXStateNamespace = (variable) => variable !== null && variable.defs.some(({ node }) => node.type === "ImportNamespaceSpecifier" && node.parent.type === "ImportDeclaration" && isXState(node.parent.source.value));
70
+ var effectActors = {
71
+ group: "effect-convention",
72
+ rule: defineRule({
73
+ create(context) {
74
+ const check = (node, name) => {
75
+ if (name !== null && SIDE_EFFECT_ACTORS.has(name)) {
76
+ context.report({
77
+ data: { name },
78
+ messageId: "sideEffectActor",
79
+ node
80
+ });
81
+ }
82
+ };
83
+ return {
84
+ ExportNamedDeclaration: (node) => {
85
+ if (node.source !== null && isXState(node.source.value)) {
86
+ for (const specifier of node.specifiers) {
87
+ check(specifier, nameOf(specifier.local));
88
+ }
89
+ }
90
+ },
91
+ ImportDeclaration: (node) => {
92
+ if (isXState(node.source.value)) {
93
+ for (const specifier of node.specifiers) {
94
+ if (specifier.type === "ImportSpecifier") {
95
+ check(specifier, nameOf(specifier.imported));
96
+ }
97
+ }
98
+ }
99
+ },
100
+ MemberExpression: (node) => {
101
+ if (node.object.type === "Identifier" && isXStateNamespace(declaredVariable(context.sourceCode, node.object))) {
102
+ check(node, staticPropertyName(node.property, node.computed));
103
+ }
104
+ }
105
+ };
106
+ },
107
+ meta: {
108
+ docs: {
109
+ description: "Require XState side-effect actors to be `fromEffect` actors: no `fromPromise`, `fromCallback` or observable actor logic."
110
+ },
111
+ messages,
112
+ type: "problem"
113
+ }
114
+ })
115
+ };
116
+
117
+ // src/rules/effect-subpath/effect-subpath.ts
118
+ import { defineRule as defineRule2 } from "@oxlint/plugins";
119
+
37
120
  // src/workspace/package-exports.ts
38
121
  var parseExports = (exports) => {
39
122
  const subpaths = exports instanceof Object && !Array.isArray(exports) ? Object.entries(exports) : [];
@@ -75,6 +158,97 @@ var declaresEntrypoint = (target, subpath) => {
75
158
  return target.exports.get(key) ?? matchPattern(target.exports, key);
76
159
  };
77
160
 
161
+ // src/rules/effect-subpath/effect-subpath.ts
162
+ var SCOPE = "@collective-intelligence/";
163
+ var EFFECT_PACKAGE_SUFFIX = "-effect";
164
+ var DEPRECATED = new Map([
165
+ [
166
+ "@collective-intelligence/external-apps-server-sdk/runtime/effect",
167
+ "@collective-intelligence/external-apps-server-sdk/effect"
168
+ ],
169
+ [
170
+ "@collective-intelligence/external-apps-server-sdk/persistence/drizzle/effect",
171
+ "@collective-intelligence/external-apps-server-sdk/effect"
172
+ ],
173
+ [
174
+ "@collective-intelligence/external-apps-server-sdk/runtime/next",
175
+ "@collective-intelligence/external-apps-server-sdk/next"
176
+ ],
177
+ [
178
+ "@collective-intelligence/extensions-sdk-backend-effect",
179
+ "@collective-intelligence/extensions-sdk-backend/effect"
180
+ ]
181
+ ]);
182
+ var MOVED = new Map([
183
+ [
184
+ "@collective-intelligence/external-apps-server-sdk/persistence/drizzle/effect",
185
+ {
186
+ names: "`layerNodePostgres` and `NodePostgresLayerOptions`",
187
+ path: "@collective-intelligence/external-apps-server-sdk/effect/node-postgres"
188
+ }
189
+ ]
190
+ ]);
191
+ var messages2 = {
192
+ deprecated: "`{{specifier}}` is deprecated. Import `{{replacement}}`.",
193
+ deprecatedMoved: "`{{specifier}}` is deprecated. Import {{names}} from `{{moved}}`, and each other name from `{{replacement}}`.",
194
+ outsideEffect: "`{{specifier}}` imports an SDK Effect API from outside its `/effect` subpath. Import `{{replacement}}`."
195
+ };
196
+ var effectSubpathFor = (specifier) => {
197
+ const parsed = parsePackageSpecifier(specifier);
198
+ if (parsed === null || !parsed.name.startsWith(SCOPE)) {
199
+ return null;
200
+ }
201
+ const { name, subpath } = parsed;
202
+ if (name.endsWith(EFFECT_PACKAGE_SUFFIX)) {
203
+ return `${name.slice(0, -EFFECT_PACKAGE_SUFFIX.length)}/effect`;
204
+ }
205
+ const [first, ...rest] = subpath.split("/");
206
+ return first !== "effect" && rest.includes("effect") ? `${name}/effect` : null;
207
+ };
208
+ var effectSubpath = {
209
+ group: "effect-convention",
210
+ rule: defineRule2({
211
+ create(context) {
212
+ return moduleSpecifiers((node) => {
213
+ const specifier = node.value;
214
+ const deprecated = DEPRECATED.get(specifier);
215
+ const moved = MOVED.get(specifier);
216
+ if (deprecated !== undefined && moved !== undefined) {
217
+ context.report({
218
+ data: {
219
+ moved: moved.path,
220
+ names: moved.names,
221
+ replacement: deprecated,
222
+ specifier
223
+ },
224
+ messageId: "deprecatedMoved",
225
+ node
226
+ });
227
+ return;
228
+ }
229
+ const replacement = deprecated ?? effectSubpathFor(specifier);
230
+ if (replacement !== null) {
231
+ const messageId = deprecated === undefined ? "outsideEffect" : "deprecated";
232
+ context.report({ data: { replacement, specifier }, messageId, node });
233
+ }
234
+ });
235
+ },
236
+ meta: {
237
+ docs: {
238
+ description: "Require the Effect API of a Collective Intelligence SDK to come from its `/effect` subpath, and report deprecated SDK paths."
239
+ },
240
+ messages: messages2,
241
+ type: "problem"
242
+ }
243
+ })
244
+ };
245
+
246
+ // src/rules/no-run-in-view/no-run-in-view.ts
247
+ import { defineRule as defineRule3 } from "@oxlint/plugins";
248
+
249
+ // src/workspace/layout.ts
250
+ import path2 from "node:path";
251
+
78
252
  // src/workspace/workspace.ts
79
253
  import { existsSync, readFileSync } from "node:fs";
80
254
  import path from "node:path";
@@ -110,13 +284,121 @@ var installedPackage = (directory, name) => {
110
284
  return found;
111
285
  };
112
286
 
287
+ // src/workspace/layout.ts
288
+ var SUBPATHS = [
289
+ "ci",
290
+ "domain",
291
+ "api",
292
+ "server",
293
+ "headless",
294
+ "views"
295
+ ];
296
+ var isSubpath = (folder) => SUBPATHS.some((subpath) => subpath === folder);
297
+ var subpathOfSegments = (segments) => {
298
+ const [folder] = segments ?? [];
299
+ return isSubpath(folder) ? folder : null;
300
+ };
301
+ var sourceSegments = (root, target) => {
302
+ const relative = path2.relative(path2.join(root, "src"), target);
303
+ return relative === "" || relative.startsWith("..") || path2.isAbsolute(relative) ? null : relative.split(path2.sep);
304
+ };
305
+ var isSubpathEntrypoint = (segments) => {
306
+ const [, file] = segments;
307
+ return segments.length === 1 || segments.length === 2 && path2.parse(file ?? "").name === "index";
308
+ };
309
+ var layoutFile = (filename) => {
310
+ const owner = packageOf(path2.dirname(filename));
311
+ const segments = owner && sourceSegments(owner.root, filename);
312
+ const subpath = segments && segments.length > 1 ? subpathOfSegments(segments) : null;
313
+ return owner && subpath ? { owner, subpath } : null;
314
+ };
315
+
316
+ // src/rules/no-run-in-view/no-run-in-view.ts
317
+ var JSX_FILE = /\.[jt]sx$/u;
318
+ var RUN_FUNCTION = /^run(?:Callback|Fork|Promise|PromiseExit|Sync|SyncExit)(?:With)?$/u;
319
+ var FETCH_OBJECTS = ["globalThis", "window"];
320
+ var isRunFunction = (name) => name !== null && RUN_FUNCTION.test(name);
321
+ var isEffectModule = (source) => source === "effect" || source.startsWith("effect/") || source.startsWith("@effect/");
322
+ var messages3 = {
323
+ fetch: "A view module calls `fetch`. Read data with TanStack Query, or call the API in a `fromEffect` actor.",
324
+ run: "A view module runs an Effect with `{{name}}`. Run the Effect in a `fromEffect` actor."
325
+ };
326
+ var isViewModule = (filename) => JSX_FILE.test(filename) || layoutFile(filename)?.subpath === "views";
327
+ var noRunInView = {
328
+ group: "effect-convention",
329
+ rule: defineRule3({
330
+ create(context) {
331
+ if (!isViewModule(context.filename)) {
332
+ return {};
333
+ }
334
+ const isGlobal = (node, names) => node.type === "Identifier" && names.includes(node.name) && declaredVariable(context.sourceCode, node) === null;
335
+ const isFetch = (callee) => callee.type === "MemberExpression" ? staticPropertyName(callee.property, callee.computed) === "fetch" && isGlobal(callee.object, FETCH_OBJECTS) : isGlobal(callee, ["fetch"]);
336
+ const reportRun = (node, name) => {
337
+ context.report({
338
+ data: { name },
339
+ messageId: "run",
340
+ node
341
+ });
342
+ };
343
+ return {
344
+ CallExpression: (node) => {
345
+ if (isFetch(node.callee)) {
346
+ context.report({
347
+ messageId: "fetch",
348
+ node
349
+ });
350
+ }
351
+ },
352
+ ImportDeclaration: (node) => {
353
+ if (!isEffectModule(node.source.value)) {
354
+ return;
355
+ }
356
+ for (const specifier of node.specifiers) {
357
+ if (specifier.type === "ImportSpecifier") {
358
+ const { imported } = specifier;
359
+ const name = imported.type === "Literal" ? imported.value : imported.name;
360
+ if (RUN_FUNCTION.test(name)) {
361
+ reportRun(specifier, name);
362
+ }
363
+ }
364
+ }
365
+ },
366
+ MemberExpression: (node) => {
367
+ if (isRunFunction(staticPropertyName(node.property, node.computed))) {
368
+ reportRun(node, context.sourceCode.getText(node));
369
+ }
370
+ },
371
+ ObjectPattern: (node) => {
372
+ for (const property of node.properties) {
373
+ if (property.type === "Property") {
374
+ const name = staticPropertyName(property.key, property.computed);
375
+ if (isRunFunction(name)) {
376
+ reportRun(property, name);
377
+ }
378
+ }
379
+ }
380
+ }
381
+ };
382
+ },
383
+ meta: {
384
+ docs: {
385
+ description: "Disallow `fetch` calls and Effect run functions in view modules; side effects run in `fromEffect` actors."
386
+ },
387
+ messages: messages3,
388
+ type: "problem"
389
+ }
390
+ })
391
+ };
392
+
113
393
  // src/rules/package-entrypoint/package-entrypoint.ts
114
- var packageName = (target) => target.name ?? path2.basename(target.root);
394
+ import { defineRule as defineRule4 } from "@oxlint/plugins";
395
+ import path3 from "node:path";
396
+ var packageName = (target) => target.name ?? path3.basename(target.root);
115
397
  var packageEntrypoint = {
116
398
  group: "package-boundaries",
117
- rule: defineRule({
399
+ rule: defineRule4({
118
400
  create(context) {
119
- const directory = path2.dirname(context.filename);
401
+ const directory = path3.dirname(context.filename);
120
402
  const owner = packageOf(directory);
121
403
  if (owner === null) {
122
404
  return {};
@@ -124,7 +406,7 @@ var packageEntrypoint = {
124
406
  return moduleSpecifiers((node) => {
125
407
  const specifier = node.value;
126
408
  if (specifier.startsWith(".")) {
127
- const target = packageOf(path2.resolve(directory, specifier));
409
+ const target = packageOf(path3.resolve(directory, specifier));
128
410
  if (target !== null && target.root !== owner.root) {
129
411
  context.report({
130
412
  data: { name: packageName(target), specifier },
@@ -162,43 +444,11 @@ var packageEntrypoint = {
162
444
  };
163
445
 
164
446
  // src/rules/subpath-entrypoint/subpath-entrypoint.ts
165
- import { defineRule as defineRule2 } from "@oxlint/plugins";
447
+ import { defineRule as defineRule5 } from "@oxlint/plugins";
166
448
  import path4 from "node:path";
167
-
168
- // src/workspace/layout.ts
169
- import path3 from "node:path";
170
- var SUBPATHS = [
171
- "ci",
172
- "domain",
173
- "api",
174
- "server",
175
- "headless",
176
- "views"
177
- ];
178
- var isSubpath = (folder) => SUBPATHS.some((subpath) => subpath === folder);
179
- var subpathOfSegments = (segments) => {
180
- const [folder] = segments ?? [];
181
- return isSubpath(folder) ? folder : null;
182
- };
183
- var sourceSegments = (root, target) => {
184
- const relative = path3.relative(path3.join(root, "src"), target);
185
- return relative === "" || relative.startsWith("..") || path3.isAbsolute(relative) ? null : relative.split(path3.sep);
186
- };
187
- var isSubpathEntrypoint = (segments) => {
188
- const [, file] = segments;
189
- return segments.length === 1 || segments.length === 2 && path3.parse(file ?? "").name === "index";
190
- };
191
- var layoutFile = (filename) => {
192
- const owner = packageOf(path3.dirname(filename));
193
- const segments = owner && sourceSegments(owner.root, filename);
194
- const subpath = segments && segments.length > 1 ? subpathOfSegments(segments) : null;
195
- return owner && subpath ? { owner, subpath } : null;
196
- };
197
-
198
- // src/rules/subpath-entrypoint/subpath-entrypoint.ts
199
449
  var subpathEntrypoint = {
200
450
  group: "solution-layout",
201
- rule: defineRule2({
451
+ rule: defineRule5({
202
452
  create(context) {
203
453
  const directory = path4.dirname(context.filename);
204
454
  const owner = packageOf(directory);
@@ -235,7 +485,7 @@ var subpathEntrypoint = {
235
485
  };
236
486
 
237
487
  // src/rules/subpath-imports/subpath-imports.ts
238
- import { defineRule as defineRule3 } from "@oxlint/plugins";
488
+ import { defineRule as defineRule6 } from "@oxlint/plugins";
239
489
  import path5 from "node:path";
240
490
  var FORBIDDEN_IMPORTS = {
241
491
  api: [],
@@ -247,7 +497,7 @@ var FORBIDDEN_IMPORTS = {
247
497
  };
248
498
  var subpathImports = {
249
499
  group: "solution-layout",
250
- rule: defineRule3({
500
+ rule: defineRule6({
251
501
  create(context) {
252
502
  const file = layoutFile(context.filename);
253
503
  if (file === null) {
@@ -292,13 +542,13 @@ var subpathImports = {
292
542
  };
293
543
 
294
544
  // src/rules/subpath-index/subpath-index.ts
295
- import { defineRule as defineRule4 } from "@oxlint/plugins";
545
+ import { defineRule as defineRule7 } from "@oxlint/plugins";
296
546
  import { existsSync as existsSync2 } from "node:fs";
297
547
  import path6 from "node:path";
298
548
  var INDEX_FILES = ["index.ts", "index.tsx"];
299
549
  var subpathIndex = {
300
550
  group: "solution-layout",
301
- rule: defineRule4({
551
+ rule: defineRule7({
302
552
  create(context) {
303
553
  const file = layoutFile(context.filename);
304
554
  if (file === null) {
@@ -332,6 +582,9 @@ var subpathIndex = {
332
582
 
333
583
  // src/rules/index.ts
334
584
  var rules = {
585
+ "effect-actors": effectActors,
586
+ "effect-subpath": effectSubpath,
587
+ "no-run-in-view": noRunInView,
335
588
  "package-entrypoint": packageEntrypoint,
336
589
  "subpath-entrypoint": subpathEntrypoint,
337
590
  "subpath-imports": subpathImports,
package/dist/rule.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import type { ESTree, Rule, Visitor } from "@oxlint/plugins";
2
- export type RuleGroup = "package-boundaries" | "solution-layout";
1
+ import type { ESTree, Rule, SourceCode, Variable, Visitor } from "@oxlint/plugins";
2
+ export type RuleGroup = "effect-convention" | "package-boundaries" | "solution-layout";
3
3
  export interface LintRule {
4
4
  readonly group: RuleGroup;
5
5
  readonly rule: Rule;
6
6
  }
7
+ export declare const staticPropertyName: (key: ESTree.PropertyKey, computed: boolean) => string | null;
8
+ export declare const declaredVariable: (sourceCode: SourceCode, node: ESTree.IdentifierReference) => Variable | null;
7
9
  export declare const moduleSpecifiers: (check: (literal: ESTree.StringLiteral) => void) => Visitor;
@@ -0,0 +1,2 @@
1
+ import type { LintRule } from "../../rule.ts";
2
+ export declare const effectActors: LintRule;
@@ -0,0 +1,2 @@
1
+ import type { LintRule } from "../../rule.ts";
2
+ export declare const effectSubpath: LintRule;
@@ -1,5 +1,8 @@
1
1
  import type { LintRule } from "../rule.ts";
2
2
  export declare const rules: {
3
+ readonly "effect-actors": LintRule;
4
+ readonly "effect-subpath": LintRule;
5
+ readonly "no-run-in-view": LintRule;
3
6
  readonly "package-entrypoint": LintRule;
4
7
  readonly "subpath-entrypoint": LintRule;
5
8
  readonly "subpath-imports": LintRule;
@@ -0,0 +1,2 @@
1
+ import type { LintRule } from "../../rule.ts";
2
+ export declare const noRunInView: LintRule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/lint",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Oxlint plugin with the Collective Intelligence lint rules: package boundaries and solution package layout.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,5 +48,5 @@
48
48
  "typescript": "7.0.2",
49
49
  "ultracite": "7.10.7"
50
50
  },
51
- "gitHead": "02f5d1b5a00cf4cfb8575f6cc556c7c6b844577d"
51
+ "gitHead": "f94130c9ae9ded5a9ac66b2a2997fc992b6f3712"
52
52
  }
@@ -74,20 +74,24 @@ export default defineConfig({ extends: [recommended] })
74
74
  ```
75
75
 
76
76
  In a repository that Harness Intelligence manages, the `collective-intelligence` pack adds the plugin
77
- and `ci-solution/package-entrypoint` to the managed lint config of every scope, so apps need no
78
- plugin setup. Each solution package (`packages/<tier>/<name>`) still extends `recommended` in its
79
- `oxlint.local.ts` for the three solution-layout rules. Outside Harness Intelligence, extend
80
- `recommended` as shown.
81
-
82
- `recommended` enables every rule as an error. Each rule enforces one part of the
83
- [package shape](package-shape.md):
84
-
85
- | Rule | Enforces |
86
- | -------------------------------- | ---------------------------------------------------------------------- |
87
- | `ci-solution/package-entrypoint` | Cross-package imports target an exported subpath. |
88
- | `ci-solution/subpath-imports` | The [subpath direction](package-shape.md#subpath-direction). |
89
- | `ci-solution/subpath-entrypoint` | An import into another subpath targets the folder or its `index` file. |
90
- | `ci-solution/subpath-index` | Every subpath folder under `src/` has an `index.ts` or `index.tsx`. |
77
+ and `ci-solution/package-entrypoint` to the managed lint config of every scope. Each solution
78
+ package (`packages/<tier>/<name>`) and each app still extends `recommended` in its
79
+ `oxlint.local.ts`, which adds the solution-layout rules and the Effect rules. Outside Harness
80
+ Intelligence, extend `recommended` as shown.
81
+
82
+ `recommended` enables every rule as an error. The package rules enforce the
83
+ [package shape](package-shape.md); the Effect rules keep side effects in `fromEffect` actors of
84
+ XState machines and out of views:
85
+
86
+ | Rule | Enforces |
87
+ | -------------------------------- | -------------------------------------------------------------------------------- |
88
+ | `ci-solution/package-entrypoint` | Cross-package imports target an exported subpath. |
89
+ | `ci-solution/subpath-imports` | The [subpath direction](package-shape.md#subpath-direction). |
90
+ | `ci-solution/subpath-entrypoint` | An import into another subpath targets the folder or its `index` file. |
91
+ | `ci-solution/subpath-index` | Every subpath folder under `src/` has an `index.ts` or `index.tsx`. |
92
+ | `ci-solution/effect-subpath` | An SDK Effect API comes from `<sdk>/effect`; deprecated SDK paths are errors. |
93
+ | `ci-solution/no-run-in-view` | A view module (`.tsx`, `.jsx`, `views/`) calls no `fetch` and runs no Effect. |
94
+ | `ci-solution/effect-actors` | XState side-effect actors are `fromEffect`, not `fromPromise` or `fromCallback`. |
91
95
 
92
96
  `package-entrypoint` finds each package through `node_modules`, so the package manager must link the
93
97
  workspace packages. The package documentation is the authority for rule options.