@collective-intelligence/lint 0.2.0 → 0.2.2
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 +42 -16
- package/dist/index.js +103 -50
- package/dist/rule.d.ts +2 -0
- package/dist/rules/effect-writes/effect-writes.d.ts +2 -0
- package/dist/rules/index.d.ts +1 -0
- package/dist/workspace/layout.d.ts +1 -0
- package/package.json +2 -2
- package/skills/ci-solution-structure/references/enforcement.md +2 -1
package/README.md
CHANGED
|
@@ -73,15 +73,16 @@ the `collective-intelligence` pack installs the skill and adds the plugin with
|
|
|
73
73
|
|
|
74
74
|
## Rules
|
|
75
75
|
|
|
76
|
-
| Rule | Enforces
|
|
77
|
-
| -------------------------------- |
|
|
78
|
-
| `ci-solution/package-entrypoint` | An import of another package targets an entrypoint declared in its `package.json` exports.
|
|
79
|
-
| `ci-solution/subpath-imports` | Imports between subpath folders follow the allowed direction.
|
|
80
|
-
| `ci-solution/subpath-entrypoint` | An import from another subpath folder targets the folder or its index file.
|
|
81
|
-
| `ci-solution/subpath-index` | Every subpath folder has an `index.ts` or `index.tsx`.
|
|
82
|
-
| `ci-solution/effect-subpath` | An SDK Effect API comes from the SDK's `/effect` subpath;
|
|
83
|
-
| `ci-solution/no-run-in-view` | A view module calls no `fetch` and runs no Effect.
|
|
84
|
-
| `ci-solution/effect-actors` | XState side-effect actors are `fromEffect` actors.
|
|
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; removed 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 |
|
|
85
|
+
| `ci-solution/effect-writes` | No module takes TanStack Query `useMutation`; writes run in `fromEffect` actors. | Effect convention |
|
|
85
86
|
|
|
86
87
|
### Package boundaries
|
|
87
88
|
|
|
@@ -156,7 +157,8 @@ The rule reports each file in a folder that has neither.
|
|
|
156
157
|
### Effect convention
|
|
157
158
|
|
|
158
159
|
An app keeps its side effects in XState machines: each side effect is a
|
|
159
|
-
`fromEffect` actor,
|
|
160
|
+
`fromEffect` actor, views read data through TanStack Query, and writes refresh
|
|
161
|
+
those reads through the SDK `QueryCache`. These rules
|
|
160
162
|
check the parts of that convention that imports and calls show.
|
|
161
163
|
|
|
162
164
|
#### `effect-subpath`
|
|
@@ -164,10 +166,10 @@ check the parts of that convention that imports and calls show.
|
|
|
164
166
|
A Collective Intelligence SDK (`@collective-intelligence/*`) exposes its Effect
|
|
165
167
|
API at `<sdk>/effect` and `<sdk>/effect/<adapter>`. The rule reports an SDK path
|
|
166
168
|
that names Effect elsewhere: a `<sdk>-effect` package, or an `effect` segment
|
|
167
|
-
below another subpath. It also reports each
|
|
168
|
-
replacement:
|
|
169
|
+
below another subpath. It also reports each SDK path that the release after 0.2.0
|
|
170
|
+
removes, with its replacement:
|
|
169
171
|
|
|
170
|
-
|
|
|
172
|
+
| Removed path | Replacement |
|
|
171
173
|
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
172
174
|
| `@collective-intelligence/external-apps-server-sdk/runtime/effect` | `@collective-intelligence/external-apps-server-sdk/effect` |
|
|
173
175
|
| `@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` |
|
|
@@ -178,7 +180,7 @@ replacement:
|
|
|
178
180
|
import { CiClient } from "@collective-intelligence/external-apps-client-sdk/effect" // valid
|
|
179
181
|
import { createClient } from "@collective-intelligence/external-apps-client-sdk" // valid
|
|
180
182
|
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:
|
|
183
|
+
import { CiRuntime } from "@collective-intelligence/external-apps-server-sdk/runtime/effect" // reported: removed
|
|
182
184
|
```
|
|
183
185
|
|
|
184
186
|
#### `no-run-in-view`
|
|
@@ -207,13 +209,37 @@ entry.
|
|
|
207
209
|
|
|
208
210
|
The rule reports each `fromPromise`, `fromCallback`, `fromObservable` and
|
|
209
211
|
`fromEventObservable` that an import, a re-export or a namespace import
|
|
210
|
-
(`XState.fromPromise`, `XState["fromPromise"]
|
|
211
|
-
`xstate/*`. Make side-effect actors with `fromEffect` from
|
|
212
|
+
(`XState.fromPromise`, `XState["fromPromise"]`,
|
|
213
|
+
`const { fromPromise } = XState`) takes from `xstate` or `xstate/*`. Make side-effect actors with `fromEffect` from
|
|
212
214
|
`@collective-intelligence/external-apps-client-sdk-react/effect`. Machines and
|
|
213
215
|
`fromTransition` actors have no side effects and are not reported. A local name
|
|
214
216
|
that shadows the namespace import, such as a parameter named `XState`, is not
|
|
215
217
|
reported.
|
|
216
218
|
|
|
219
|
+
#### `effect-writes`
|
|
220
|
+
|
|
221
|
+
The rule reports each `useMutation` that an import, a re-export or a namespace
|
|
222
|
+
import (`ReactQuery.useMutation`, `ReactQuery["useMutation"]`,
|
|
223
|
+
`const { useMutation } = ReactQuery`) takes from `@tanstack/react-query`. Write through a `fromEffect` actor from
|
|
224
|
+
`@collective-intelligence/external-apps-client-sdk-react/effect`; after the
|
|
225
|
+
write, the actor refreshes reads through `QueryCache` (`invalidate`, `setData`).
|
|
226
|
+
|
|
227
|
+
The rule checks every module. `useMutation` runs only during a React render,
|
|
228
|
+
so a module that takes it is a view, a hook or a helper of one of them.
|
|
229
|
+
|
|
230
|
+
`useQuery` and the other reads are not reported, and neither are
|
|
231
|
+
`useMutationState` and `useIsMutating`: they only read the state of a
|
|
232
|
+
`useMutation`. A `useMutation` from another library, such as
|
|
233
|
+
`@apollo/client`, is not reported. The entity hooks of
|
|
234
|
+
`@collective-intelligence/external-apps-client-sdk-react/resources`
|
|
235
|
+
(`useEntityCreate`, `useEntityUpdate`, `useEntityDelete`) are not reported:
|
|
236
|
+
the SDK writes and refreshes its own entity reads.
|
|
237
|
+
|
|
238
|
+
The rule checks no query key. An app that builds the SDK's `"ci-entities"`
|
|
239
|
+
key by hand, for example in `invalidateQueries`, is not reported: the SDK
|
|
240
|
+
owns that key for its entity reads but exports no key or refresh function for
|
|
241
|
+
them yet, so a report would have no supported fix.
|
|
242
|
+
|
|
217
243
|
## Adding a rule
|
|
218
244
|
|
|
219
245
|
Each rule is a plain Oxlint rule in its own folder, `src/rules/<rule>/`:
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,48 @@ var moduleSpecifiers = (check) => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
+
var moduleExportName = (node) => node.type === "Literal" ? node.value : node.name;
|
|
57
|
+
var moduleMembers = (sourceCode, isModule, check) => {
|
|
58
|
+
const isNamespace = (node) => {
|
|
59
|
+
if (node?.type !== "Identifier") {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const variable = declaredVariable(sourceCode, node);
|
|
63
|
+
return variable !== null && variable.defs.some(({ node: definition }) => definition.type === "ImportNamespaceSpecifier" && definition.parent.type === "ImportDeclaration" && isModule(definition.parent.source.value));
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
ExportNamedDeclaration: (node) => {
|
|
67
|
+
if (node.source !== null && isModule(node.source.value)) {
|
|
68
|
+
for (const specifier of node.specifiers) {
|
|
69
|
+
check(specifier, moduleExportName(specifier.local));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
ImportDeclaration: (node) => {
|
|
74
|
+
if (isModule(node.source.value)) {
|
|
75
|
+
for (const specifier of node.specifiers) {
|
|
76
|
+
if (specifier.type === "ImportSpecifier") {
|
|
77
|
+
check(specifier, moduleExportName(specifier.imported));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
MemberExpression: (node) => {
|
|
83
|
+
if (isNamespace(node.object)) {
|
|
84
|
+
check(node, staticPropertyName(node.property, node.computed));
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
VariableDeclarator: (node) => {
|
|
88
|
+
if (node.id.type === "ObjectPattern" && isNamespace(node.init)) {
|
|
89
|
+
for (const property of node.id.properties) {
|
|
90
|
+
if (property.type === "Property") {
|
|
91
|
+
check(property, staticPropertyName(property.key, property.computed));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
56
98
|
|
|
57
99
|
// src/rules/effect-actors/effect-actors.ts
|
|
58
100
|
var SIDE_EFFECT_ACTORS = new Set([
|
|
@@ -65,8 +107,6 @@ var messages = {
|
|
|
65
107
|
sideEffectActor: "`{{name}}` makes XState actor logic outside Effect. Make the actor with `fromEffect` from `@collective-intelligence/external-apps-client-sdk-react/effect`."
|
|
66
108
|
};
|
|
67
109
|
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
110
|
var effectActors = {
|
|
71
111
|
group: "effect-convention",
|
|
72
112
|
rule: defineRule({
|
|
@@ -80,29 +120,7 @@ var effectActors = {
|
|
|
80
120
|
});
|
|
81
121
|
}
|
|
82
122
|
};
|
|
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
|
-
};
|
|
123
|
+
return moduleMembers(context.sourceCode, isXState, check);
|
|
106
124
|
},
|
|
107
125
|
meta: {
|
|
108
126
|
docs: {
|
|
@@ -161,7 +179,7 @@ var declaresEntrypoint = (target, subpath) => {
|
|
|
161
179
|
// src/rules/effect-subpath/effect-subpath.ts
|
|
162
180
|
var SCOPE = "@collective-intelligence/";
|
|
163
181
|
var EFFECT_PACKAGE_SUFFIX = "-effect";
|
|
164
|
-
var
|
|
182
|
+
var REMOVED = new Map([
|
|
165
183
|
[
|
|
166
184
|
"@collective-intelligence/external-apps-server-sdk/runtime/effect",
|
|
167
185
|
"@collective-intelligence/external-apps-server-sdk/effect"
|
|
@@ -189,9 +207,9 @@ var MOVED = new Map([
|
|
|
189
207
|
]
|
|
190
208
|
]);
|
|
191
209
|
var messages2 = {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
210
|
+
outsideEffect: "`{{specifier}}` imports an SDK Effect API from outside its `/effect` subpath. Import `{{replacement}}`.",
|
|
211
|
+
removed: "`{{specifier}}` is removed after 0.2.0. Import `{{replacement}}`.",
|
|
212
|
+
removedMoved: "`{{specifier}}` is removed after 0.2.0. Import {{names}} from `{{moved}}`, and each other name from `{{replacement}}`."
|
|
195
213
|
};
|
|
196
214
|
var effectSubpathFor = (specifier) => {
|
|
197
215
|
const parsed = parsePackageSpecifier(specifier);
|
|
@@ -211,31 +229,31 @@ var effectSubpath = {
|
|
|
211
229
|
create(context) {
|
|
212
230
|
return moduleSpecifiers((node) => {
|
|
213
231
|
const specifier = node.value;
|
|
214
|
-
const
|
|
232
|
+
const removed = REMOVED.get(specifier);
|
|
215
233
|
const moved = MOVED.get(specifier);
|
|
216
|
-
if (
|
|
234
|
+
if (removed !== undefined && moved !== undefined) {
|
|
217
235
|
context.report({
|
|
218
236
|
data: {
|
|
219
237
|
moved: moved.path,
|
|
220
238
|
names: moved.names,
|
|
221
|
-
replacement:
|
|
239
|
+
replacement: removed,
|
|
222
240
|
specifier
|
|
223
241
|
},
|
|
224
|
-
messageId: "
|
|
242
|
+
messageId: "removedMoved",
|
|
225
243
|
node
|
|
226
244
|
});
|
|
227
245
|
return;
|
|
228
246
|
}
|
|
229
|
-
const replacement =
|
|
247
|
+
const replacement = removed ?? effectSubpathFor(specifier);
|
|
230
248
|
if (replacement !== null) {
|
|
231
|
-
const messageId =
|
|
249
|
+
const messageId = removed === undefined ? "outsideEffect" : "removed";
|
|
232
250
|
context.report({ data: { replacement, specifier }, messageId, node });
|
|
233
251
|
}
|
|
234
252
|
});
|
|
235
253
|
},
|
|
236
254
|
meta: {
|
|
237
255
|
docs: {
|
|
238
|
-
description: "Require the Effect API of a Collective Intelligence SDK to come from its `/effect` subpath, and report
|
|
256
|
+
description: "Require the Effect API of a Collective Intelligence SDK to come from its `/effect` subpath, and report removed SDK paths."
|
|
239
257
|
},
|
|
240
258
|
messages: messages2,
|
|
241
259
|
type: "problem"
|
|
@@ -243,8 +261,42 @@ var effectSubpath = {
|
|
|
243
261
|
})
|
|
244
262
|
};
|
|
245
263
|
|
|
246
|
-
// src/rules/
|
|
264
|
+
// src/rules/effect-writes/effect-writes.ts
|
|
247
265
|
import { defineRule as defineRule3 } from "@oxlint/plugins";
|
|
266
|
+
var messages3 = {
|
|
267
|
+
mutationHook: "`useMutation` writes outside Effect. Write through a `fromEffect` actor from `@collective-intelligence/external-apps-client-sdk-react/effect`; refresh reads through `QueryCache`."
|
|
268
|
+
};
|
|
269
|
+
var isTanStackQuery = (source) => source === "@tanstack/react-query";
|
|
270
|
+
var takesTanStackQuery = (statement) => (statement.type === "ImportDeclaration" || statement.type === "ExportNamedDeclaration") && statement.source !== null && isTanStackQuery(statement.source.value);
|
|
271
|
+
var effectWrites = {
|
|
272
|
+
group: "effect-convention",
|
|
273
|
+
rule: defineRule3({
|
|
274
|
+
create(context) {
|
|
275
|
+
const program = context.sourceCode.ast;
|
|
276
|
+
if (!program.body.some(takesTanStackQuery)) {
|
|
277
|
+
return {};
|
|
278
|
+
}
|
|
279
|
+
return moduleMembers(context.sourceCode, isTanStackQuery, (node, name) => {
|
|
280
|
+
if (name === "useMutation") {
|
|
281
|
+
context.report({
|
|
282
|
+
messageId: "mutationHook",
|
|
283
|
+
node
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
meta: {
|
|
289
|
+
docs: {
|
|
290
|
+
description: "Disallow TanStack Query `useMutation`; writes run in `fromEffect` actors."
|
|
291
|
+
},
|
|
292
|
+
messages: messages3,
|
|
293
|
+
type: "problem"
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// src/rules/no-run-in-view/no-run-in-view.ts
|
|
299
|
+
import { defineRule as defineRule4 } from "@oxlint/plugins";
|
|
248
300
|
|
|
249
301
|
// src/workspace/layout.ts
|
|
250
302
|
import path2 from "node:path";
|
|
@@ -312,21 +364,21 @@ var layoutFile = (filename) => {
|
|
|
312
364
|
const subpath = segments && segments.length > 1 ? subpathOfSegments(segments) : null;
|
|
313
365
|
return owner && subpath ? { owner, subpath } : null;
|
|
314
366
|
};
|
|
367
|
+
var JSX_FILE = /\.[jt]sx$/u;
|
|
368
|
+
var isViewModule = (filename) => JSX_FILE.test(filename) || layoutFile(filename)?.subpath === "views";
|
|
315
369
|
|
|
316
370
|
// src/rules/no-run-in-view/no-run-in-view.ts
|
|
317
|
-
var JSX_FILE = /\.[jt]sx$/u;
|
|
318
371
|
var RUN_FUNCTION = /^run(?:Callback|Fork|Promise|PromiseExit|Sync|SyncExit)(?:With)?$/u;
|
|
319
372
|
var FETCH_OBJECTS = ["globalThis", "window"];
|
|
320
373
|
var isRunFunction = (name) => name !== null && RUN_FUNCTION.test(name);
|
|
321
374
|
var isEffectModule = (source) => source === "effect" || source.startsWith("effect/") || source.startsWith("@effect/");
|
|
322
|
-
var
|
|
375
|
+
var messages4 = {
|
|
323
376
|
fetch: "A view module calls `fetch`. Read data with TanStack Query, or call the API in a `fromEffect` actor.",
|
|
324
377
|
run: "A view module runs an Effect with `{{name}}`. Run the Effect in a `fromEffect` actor."
|
|
325
378
|
};
|
|
326
|
-
var isViewModule = (filename) => JSX_FILE.test(filename) || layoutFile(filename)?.subpath === "views";
|
|
327
379
|
var noRunInView = {
|
|
328
380
|
group: "effect-convention",
|
|
329
|
-
rule:
|
|
381
|
+
rule: defineRule4({
|
|
330
382
|
create(context) {
|
|
331
383
|
if (!isViewModule(context.filename)) {
|
|
332
384
|
return {};
|
|
@@ -384,19 +436,19 @@ var noRunInView = {
|
|
|
384
436
|
docs: {
|
|
385
437
|
description: "Disallow `fetch` calls and Effect run functions in view modules; side effects run in `fromEffect` actors."
|
|
386
438
|
},
|
|
387
|
-
messages:
|
|
439
|
+
messages: messages4,
|
|
388
440
|
type: "problem"
|
|
389
441
|
}
|
|
390
442
|
})
|
|
391
443
|
};
|
|
392
444
|
|
|
393
445
|
// src/rules/package-entrypoint/package-entrypoint.ts
|
|
394
|
-
import { defineRule as
|
|
446
|
+
import { defineRule as defineRule5 } from "@oxlint/plugins";
|
|
395
447
|
import path3 from "node:path";
|
|
396
448
|
var packageName = (target) => target.name ?? path3.basename(target.root);
|
|
397
449
|
var packageEntrypoint = {
|
|
398
450
|
group: "package-boundaries",
|
|
399
|
-
rule:
|
|
451
|
+
rule: defineRule5({
|
|
400
452
|
create(context) {
|
|
401
453
|
const directory = path3.dirname(context.filename);
|
|
402
454
|
const owner = packageOf(directory);
|
|
@@ -444,11 +496,11 @@ var packageEntrypoint = {
|
|
|
444
496
|
};
|
|
445
497
|
|
|
446
498
|
// src/rules/subpath-entrypoint/subpath-entrypoint.ts
|
|
447
|
-
import { defineRule as
|
|
499
|
+
import { defineRule as defineRule6 } from "@oxlint/plugins";
|
|
448
500
|
import path4 from "node:path";
|
|
449
501
|
var subpathEntrypoint = {
|
|
450
502
|
group: "solution-layout",
|
|
451
|
-
rule:
|
|
503
|
+
rule: defineRule6({
|
|
452
504
|
create(context) {
|
|
453
505
|
const directory = path4.dirname(context.filename);
|
|
454
506
|
const owner = packageOf(directory);
|
|
@@ -485,7 +537,7 @@ var subpathEntrypoint = {
|
|
|
485
537
|
};
|
|
486
538
|
|
|
487
539
|
// src/rules/subpath-imports/subpath-imports.ts
|
|
488
|
-
import { defineRule as
|
|
540
|
+
import { defineRule as defineRule7 } from "@oxlint/plugins";
|
|
489
541
|
import path5 from "node:path";
|
|
490
542
|
var FORBIDDEN_IMPORTS = {
|
|
491
543
|
api: [],
|
|
@@ -497,7 +549,7 @@ var FORBIDDEN_IMPORTS = {
|
|
|
497
549
|
};
|
|
498
550
|
var subpathImports = {
|
|
499
551
|
group: "solution-layout",
|
|
500
|
-
rule:
|
|
552
|
+
rule: defineRule7({
|
|
501
553
|
create(context) {
|
|
502
554
|
const file = layoutFile(context.filename);
|
|
503
555
|
if (file === null) {
|
|
@@ -542,13 +594,13 @@ var subpathImports = {
|
|
|
542
594
|
};
|
|
543
595
|
|
|
544
596
|
// src/rules/subpath-index/subpath-index.ts
|
|
545
|
-
import { defineRule as
|
|
597
|
+
import { defineRule as defineRule8 } from "@oxlint/plugins";
|
|
546
598
|
import { existsSync as existsSync2 } from "node:fs";
|
|
547
599
|
import path6 from "node:path";
|
|
548
600
|
var INDEX_FILES = ["index.ts", "index.tsx"];
|
|
549
601
|
var subpathIndex = {
|
|
550
602
|
group: "solution-layout",
|
|
551
|
-
rule:
|
|
603
|
+
rule: defineRule8({
|
|
552
604
|
create(context) {
|
|
553
605
|
const file = layoutFile(context.filename);
|
|
554
606
|
if (file === null) {
|
|
@@ -584,6 +636,7 @@ var subpathIndex = {
|
|
|
584
636
|
var rules = {
|
|
585
637
|
"effect-actors": effectActors,
|
|
586
638
|
"effect-subpath": effectSubpath,
|
|
639
|
+
"effect-writes": effectWrites,
|
|
587
640
|
"no-run-in-view": noRunInView,
|
|
588
641
|
"package-entrypoint": packageEntrypoint,
|
|
589
642
|
"subpath-entrypoint": subpathEntrypoint,
|
package/dist/rule.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export interface LintRule {
|
|
|
7
7
|
export declare const staticPropertyName: (key: ESTree.PropertyKey, computed: boolean) => string | null;
|
|
8
8
|
export declare const declaredVariable: (sourceCode: SourceCode, node: ESTree.IdentifierReference) => Variable | null;
|
|
9
9
|
export declare const moduleSpecifiers: (check: (literal: ESTree.StringLiteral) => void) => Visitor;
|
|
10
|
+
export declare const moduleExportName: (node: ESTree.ModuleExportName) => string;
|
|
11
|
+
export declare const moduleMembers: (sourceCode: SourceCode, isModule: (source: string) => boolean, check: (node: ESTree.Node, name: string | null) => void) => Visitor;
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { LintRule } from "../rule.ts";
|
|
|
2
2
|
export declare const rules: {
|
|
3
3
|
readonly "effect-actors": LintRule;
|
|
4
4
|
readonly "effect-subpath": LintRule;
|
|
5
|
+
readonly "effect-writes": LintRule;
|
|
5
6
|
readonly "no-run-in-view": LintRule;
|
|
6
7
|
readonly "package-entrypoint": LintRule;
|
|
7
8
|
readonly "subpath-entrypoint": LintRule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/lint",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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": "
|
|
51
|
+
"gitHead": "1e9b53d62a76652e6e3ba98991ec281c26c2c25a"
|
|
52
52
|
}
|
|
@@ -89,9 +89,10 @@ XState machines and out of views:
|
|
|
89
89
|
| `ci-solution/subpath-imports` | The [subpath direction](package-shape.md#subpath-direction). |
|
|
90
90
|
| `ci-solution/subpath-entrypoint` | An import into another subpath targets the folder or its `index` file. |
|
|
91
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`;
|
|
92
|
+
| `ci-solution/effect-subpath` | An SDK Effect API comes from `<sdk>/effect`; removed SDK paths are errors. |
|
|
93
93
|
| `ci-solution/no-run-in-view` | A view module (`.tsx`, `.jsx`, `views/`) calls no `fetch` and runs no Effect. |
|
|
94
94
|
| `ci-solution/effect-actors` | XState side-effect actors are `fromEffect`, not `fromPromise` or `fromCallback`. |
|
|
95
|
+
| `ci-solution/effect-writes` | No module takes TanStack Query `useMutation`; writes are `fromEffect` actors. |
|
|
95
96
|
|
|
96
97
|
`package-entrypoint` finds each package through `node_modules`, so the package manager must link the
|
|
97
98
|
workspace packages. The package documentation is the authority for rule options.
|