@foldkit/oxlint-plugin 0.10.0 → 0.11.0-canary.0053b7691fcd
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/all.json +26 -2
- package/dist/guards.d.ts +13 -9
- package/dist/guards.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +947 -168
- package/dist/message.d.ts.map +1 -1
- package/dist/rules/mount-factory-must-use-element.d.ts +1 -1
- package/dist/rules/mount-factory-must-use-element.d.ts.map +1 -1
- package/dist/rules/no-empty-commands-array.d.ts.map +1 -1
- package/dist/rules/no-empty-to-parent-out-message.d.ts.map +1 -1
- package/dist/rules/no-impure-call-at-decision-time.d.ts +7 -0
- package/dist/rules/no-impure-call-at-decision-time.d.ts.map +1 -0
- package/dist/rules/no-nonportable-server-globals.d.ts.map +1 -1
- package/dist/rules/prefer-effect-module-names.d.ts +3 -0
- package/dist/rules/prefer-effect-module-names.d.ts.map +1 -0
- package/package.json +7 -6
- package/recommended.json +26 -2
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __export = (target, all5) => {
|
|
|
4
4
|
__defProp(target, name, { get: all5[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// ../../node_modules/.pnpm/effect-oxlint@0.3.
|
|
7
|
+
// ../../node_modules/.pnpm/effect-oxlint@0.3.4_effect@4.0.0-rc.112/node_modules/effect-oxlint/dist/rolldown-runtime.js
|
|
8
8
|
var __defProp2 = Object.defineProperty;
|
|
9
9
|
var __exportAll = (all5, no_symbols) => {
|
|
10
10
|
let target = {};
|
|
@@ -7399,7 +7399,7 @@ var flatMapEager2 = flatMapEager;
|
|
|
7399
7399
|
var catchEager2 = catchEager;
|
|
7400
7400
|
var fnUntracedEager2 = fnUntracedEager;
|
|
7401
7401
|
|
|
7402
|
-
// ../../node_modules/.pnpm/effect-oxlint@0.3.
|
|
7402
|
+
// ../../node_modules/.pnpm/effect-oxlint@0.3.4_effect@4.0.0-rc.112/node_modules/effect-oxlint/dist/RuleContext.js
|
|
7403
7403
|
var RuleContextBase = Service()("effect-oxlint/RuleContext");
|
|
7404
7404
|
var RuleContext = class extends RuleContextBase {
|
|
7405
7405
|
};
|
|
@@ -8300,7 +8300,7 @@ var Objects = class _Objects extends Base2 {
|
|
|
8300
8300
|
if (!hasProperties && !indexCount) {
|
|
8301
8301
|
return fromRefinement(ast, isNotNullish);
|
|
8302
8302
|
}
|
|
8303
|
-
let
|
|
8303
|
+
let properties2;
|
|
8304
8304
|
let indexes;
|
|
8305
8305
|
const finishIndex = (s, key, k2, inputValue, exitValue) => {
|
|
8306
8306
|
if (exitValue._tag === "Failure") {
|
|
@@ -8339,8 +8339,8 @@ var Objects = class _Objects extends Base2 {
|
|
|
8339
8339
|
step: (_s, _, exit3) => exit3._tag === "Failure" ? exit3 : void 0
|
|
8340
8340
|
}) : void 0;
|
|
8341
8341
|
const compileMembers = () => {
|
|
8342
|
-
if (!
|
|
8343
|
-
|
|
8342
|
+
if (!properties2) {
|
|
8343
|
+
properties2 = ast.propertySignatures.map((ps) => ({
|
|
8344
8344
|
parser: compileConstructorDefault2(ps.type),
|
|
8345
8345
|
name: ps.name,
|
|
8346
8346
|
type: ps.type
|
|
@@ -8351,7 +8351,7 @@ var Objects = class _Objects extends Base2 {
|
|
|
8351
8351
|
parserValue: compileConstructorDefault2(is2.type)
|
|
8352
8352
|
})) : void 0;
|
|
8353
8353
|
}
|
|
8354
|
-
return
|
|
8354
|
+
return properties2;
|
|
8355
8355
|
};
|
|
8356
8356
|
const fallback = fnUntracedEager2(function* (input, options) {
|
|
8357
8357
|
if (input === missing) {
|
|
@@ -8401,7 +8401,7 @@ var Objects = class _Objects extends Base2 {
|
|
|
8401
8401
|
}
|
|
8402
8402
|
const concurrency = resolveConcurrency(options?.concurrency);
|
|
8403
8403
|
if (hasProperties) {
|
|
8404
|
-
const eff = parseProperties(state,
|
|
8404
|
+
const eff = parseProperties(state, properties2, concurrency);
|
|
8405
8405
|
if (eff) yield* eff;
|
|
8406
8406
|
}
|
|
8407
8407
|
if (indexCount && !concurrency) {
|
|
@@ -8444,12 +8444,12 @@ var Objects = class _Objects extends Base2 {
|
|
|
8444
8444
|
});
|
|
8445
8445
|
if (indexCount) return fallback;
|
|
8446
8446
|
const resume = (state, index, pending) => {
|
|
8447
|
-
const property =
|
|
8447
|
+
const property = properties2[index];
|
|
8448
8448
|
return flatMap5(exit2(pending), (exit3) => {
|
|
8449
8449
|
const terminal = stepProperty(state, property, exit3);
|
|
8450
8450
|
if (terminal) return terminal;
|
|
8451
8451
|
const done4 = () => succeed6(state.out);
|
|
8452
|
-
const eff = parseProperties(state,
|
|
8452
|
+
const eff = parseProperties(state, properties2.slice(index + 1));
|
|
8453
8453
|
return eff ? flatMapEager2(eff, done4) : done4();
|
|
8454
8454
|
});
|
|
8455
8455
|
};
|
|
@@ -9594,6 +9594,7 @@ function decodeUnknownSync(schema, options) {
|
|
|
9594
9594
|
return runSchemaErrorSync(parser(input, options2));
|
|
9595
9595
|
};
|
|
9596
9596
|
}
|
|
9597
|
+
var decodeSync2 = decodeUnknownSync;
|
|
9597
9598
|
var make13 = make12;
|
|
9598
9599
|
function Literal2(literal) {
|
|
9599
9600
|
const out = make13(new Literal(literal), {
|
|
@@ -10014,7 +10015,7 @@ var updateSomeAndGet = /* @__PURE__ */ dual(2, (self, pf) => sync2(() => {
|
|
|
10014
10015
|
}));
|
|
10015
10016
|
var getUnsafe3 = (self) => self.ref.current;
|
|
10016
10017
|
|
|
10017
|
-
// ../../node_modules/.pnpm/effect-oxlint@0.3.
|
|
10018
|
+
// ../../node_modules/.pnpm/effect-oxlint@0.3.4_effect@4.0.0-rc.112/node_modules/effect-oxlint/dist/index.js
|
|
10018
10019
|
var AST_exports = /* @__PURE__ */ __exportAll({
|
|
10019
10020
|
calleeIdentifier: () => calleeIdentifier,
|
|
10020
10021
|
calleeName: () => calleeName,
|
|
@@ -10218,10 +10219,11 @@ var define = (config) => ({
|
|
|
10218
10219
|
const decodeOptions = () => {
|
|
10219
10220
|
const schema = config.options;
|
|
10220
10221
|
if (schema === void 0) return void 0;
|
|
10221
|
-
return
|
|
10222
|
+
return decodeSync2(schema)(oxlintContext.options[0]);
|
|
10222
10223
|
};
|
|
10223
10224
|
const options = run2(sync2(decodeOptions));
|
|
10224
|
-
|
|
10225
|
+
const effectVisitor = run2(gen4(() => config.create(options)));
|
|
10226
|
+
return toOxlintVisitor(effectVisitor, run2);
|
|
10225
10227
|
}
|
|
10226
10228
|
});
|
|
10227
10229
|
var meta = (opts) => ({
|
|
@@ -10385,11 +10387,13 @@ var isPunctuator = dual(2, (token, value) => token.type === "Punctuator" && toke
|
|
|
10385
10387
|
|
|
10386
10388
|
// src/guards.ts
|
|
10387
10389
|
var isIdentifier = (node, name) => typeof node === "object" && node !== null && "type" in node && node.type === "Identifier" && "name" in node && typeof node.name === "string" && (name === void 0 || node.name === name);
|
|
10390
|
+
var isIdentifierReference = (node) => isIdentifier(node);
|
|
10388
10391
|
var isStringLiteral = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Literal" && "value" in node && typeof node.value === "string";
|
|
10389
10392
|
var isTemplateLiteral = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "TemplateLiteral";
|
|
10390
10393
|
var isCallExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "CallExpression";
|
|
10391
10394
|
var isMemberExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "MemberExpression";
|
|
10392
10395
|
var isObjectExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "ObjectExpression";
|
|
10396
|
+
var isObjectProperty = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Property";
|
|
10393
10397
|
var isArrayExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "ArrayExpression";
|
|
10394
10398
|
var isSpreadElement = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "SpreadElement";
|
|
10395
10399
|
var helperCalleeName = (callee) => {
|
|
@@ -10414,6 +10418,34 @@ var staticStringValue = (node) => {
|
|
|
10414
10418
|
}
|
|
10415
10419
|
return Option_exports.none();
|
|
10416
10420
|
};
|
|
10421
|
+
var staticMemberName = (node) => {
|
|
10422
|
+
if (!node.computed && isIdentifier(node.property)) {
|
|
10423
|
+
return Option_exports.some(node.property.name);
|
|
10424
|
+
}
|
|
10425
|
+
return staticStringValue(node.property);
|
|
10426
|
+
};
|
|
10427
|
+
var staticPropertyName = (property) => {
|
|
10428
|
+
if (!property.computed && isIdentifier(property.key)) {
|
|
10429
|
+
return Option_exports.some(property.key.name);
|
|
10430
|
+
}
|
|
10431
|
+
return staticStringValue(property.key);
|
|
10432
|
+
};
|
|
10433
|
+
var indexReferences = (scopes) => {
|
|
10434
|
+
const references = /* @__PURE__ */ new WeakMap();
|
|
10435
|
+
for (const scope3 of scopes) {
|
|
10436
|
+
for (const reference of scope3.references) {
|
|
10437
|
+
references.set(reference.identifier, reference);
|
|
10438
|
+
}
|
|
10439
|
+
}
|
|
10440
|
+
return references;
|
|
10441
|
+
};
|
|
10442
|
+
var isUnshadowedReference = (references, node) => {
|
|
10443
|
+
if (references === void 0) {
|
|
10444
|
+
return true;
|
|
10445
|
+
}
|
|
10446
|
+
const reference = references.get(node);
|
|
10447
|
+
return reference !== void 0 && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs));
|
|
10448
|
+
};
|
|
10417
10449
|
var isVariableDeclarator = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclarator";
|
|
10418
10450
|
var isVariableDeclaration = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclaration";
|
|
10419
10451
|
var isProgram = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Program";
|
|
@@ -10542,18 +10574,6 @@ var commandDefinePascalConst = Rule_exports.define({
|
|
|
10542
10574
|
|
|
10543
10575
|
// src/message.ts
|
|
10544
10576
|
var foldkitMessageModule = "foldkit/message";
|
|
10545
|
-
var staticPropertyName = (property) => {
|
|
10546
|
-
if (property.type !== "Property") {
|
|
10547
|
-
return Option_exports.none();
|
|
10548
|
-
}
|
|
10549
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
10550
|
-
return Option_exports.some({ name: property.key.name, node: property.key });
|
|
10551
|
-
}
|
|
10552
|
-
if (isStringLiteral(property.key)) {
|
|
10553
|
-
return Option_exports.some({ name: property.key.value, node: property.key });
|
|
10554
|
-
}
|
|
10555
|
-
return Option_exports.none();
|
|
10556
|
-
};
|
|
10557
10577
|
var recordFoldkitMessageUnionBindings = (bindings, node) => {
|
|
10558
10578
|
if (node.type !== "Program") {
|
|
10559
10579
|
return;
|
|
@@ -10578,14 +10598,17 @@ var messageCases = (node, bindings) => {
|
|
|
10578
10598
|
return [];
|
|
10579
10599
|
}
|
|
10580
10600
|
return casesByTag.properties.flatMap((property) => {
|
|
10601
|
+
if (property.type !== "Property") {
|
|
10602
|
+
return [];
|
|
10603
|
+
}
|
|
10581
10604
|
const maybeName = staticPropertyName(property);
|
|
10582
|
-
if (
|
|
10605
|
+
if (Option_exports.isNone(maybeName) || !isObjectExpression(property.value)) {
|
|
10583
10606
|
return [];
|
|
10584
10607
|
}
|
|
10585
10608
|
return [
|
|
10586
10609
|
{
|
|
10587
|
-
name: maybeName.value
|
|
10588
|
-
nameNode:
|
|
10610
|
+
name: maybeName.value,
|
|
10611
|
+
nameNode: property.key,
|
|
10589
10612
|
fields: property.value
|
|
10590
10613
|
}
|
|
10591
10614
|
];
|
|
@@ -11086,92 +11109,134 @@ var lazyViewStableReferences = Rule_exports.define({
|
|
|
11086
11109
|
|
|
11087
11110
|
// src/rules/mount-factory-must-use-element.ts
|
|
11088
11111
|
var MOUNT_DEFINITION_METHODS = ["define", "defineStream"];
|
|
11089
|
-
var
|
|
11090
|
-
var
|
|
11091
|
-
var
|
|
11092
|
-
var
|
|
11093
|
-
var
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
}
|
|
11097
|
-
if (call.callee.type === "CallExpression") {
|
|
11098
|
-
return isMountDefinitionChain(call.callee);
|
|
11099
|
-
}
|
|
11100
|
-
return false;
|
|
11101
|
-
};
|
|
11102
|
-
var returnedFactoryFunction = (statement) => {
|
|
11103
|
-
if (statement.type !== "ReturnStatement" || statement.argument === null) {
|
|
11104
|
-
return Option_exports.none();
|
|
11105
|
-
}
|
|
11106
|
-
return isFactoryFunction(statement.argument) ? Option_exports.some(statement.argument) : Option_exports.none();
|
|
11107
|
-
};
|
|
11108
|
-
var descendToElementFactory = (builder) => {
|
|
11109
|
-
const body = builder.body;
|
|
11110
|
-
if (body === null) return builder;
|
|
11111
|
-
if (isFactoryFunction(body)) return body;
|
|
11112
|
-
if (body.type === "BlockStatement") {
|
|
11113
|
-
return pipe(
|
|
11114
|
-
body.body,
|
|
11115
|
-
Array_exports.findFirst(returnedFactoryFunction),
|
|
11116
|
-
Option_exports.getOrElse(() => builder)
|
|
11117
|
-
);
|
|
11118
|
-
}
|
|
11119
|
-
return builder;
|
|
11120
|
-
};
|
|
11112
|
+
var ELEMENT_FIELD = "element";
|
|
11113
|
+
var NO_ELEMENT_BINDING_MESSAGE = `This Mount's \`execute\` never receives the element: it does not destructure \`element\` from its input. A Mount exists for element-caused, element-targeted work. If the element is irrelevant, use a Command, Subscription, or ManagedResource instead.`;
|
|
11114
|
+
var ignoredElementBindingMessage = (bindingName) => `The element binding \`${bindingName}\` is named as ignored. A Mount's \`execute\` must read or write its live element; if the element does not matter here, the side effect has a different cause and belongs in a Command, Subscription, or ManagedResource.`;
|
|
11115
|
+
var unusedElementBindingMessage = (bindingName) => `The element binding \`${bindingName}\` is never referenced in this Mount's \`execute\`. A Mount's \`execute\` must use its live element; work that does not need the element belongs in a Command, Subscription, or ManagedResource.`;
|
|
11116
|
+
var unreadElementFieldMessage = (bindingName) => `This Mount's \`execute\` reads other fields off \`${bindingName}\` but never its \`element\`. Destructure \`element\` from the input so the check can see the read, or if the element is irrelevant, use a Command, Subscription, or ManagedResource instead.`;
|
|
11117
|
+
var unusedInputMessage = (bindingName) => `This Mount's \`execute\` never references \`${bindingName}\`, so it never reaches the live element. Destructure \`element\` from the input so the check can see the read, or if the element is irrelevant, use a Command, Subscription, or ManagedResource instead.`;
|
|
11118
|
+
var isExecuteFunction = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
|
|
11121
11119
|
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
11122
|
-
var
|
|
11120
|
+
var shadowsBindingName = (functionNode, bindingName) => {
|
|
11123
11121
|
const parameters = functionNode.params;
|
|
11124
11122
|
if (!isRecord(parameters)) return false;
|
|
11125
11123
|
return Object.values(parameters).some(
|
|
11126
|
-
(parameter) => isRecord(parameter) && parameter.type === "Identifier" && parameter.name ===
|
|
11124
|
+
(parameter) => isRecord(parameter) && parameter.type === "Identifier" && parameter.name === bindingName
|
|
11127
11125
|
);
|
|
11128
11126
|
};
|
|
11129
|
-
var referencesName = (value,
|
|
11127
|
+
var referencesName = (value, bindingName) => {
|
|
11130
11128
|
if (!isRecord(value)) return false;
|
|
11131
|
-
if (value.type === "Identifier" && value.name ===
|
|
11132
|
-
if ((value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") &&
|
|
11129
|
+
if (value.type === "Identifier" && value.name === bindingName) return true;
|
|
11130
|
+
if ((value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") && shadowsBindingName(value, bindingName)) {
|
|
11133
11131
|
return false;
|
|
11134
11132
|
}
|
|
11133
|
+
if (value.type === "MemberExpression" && value.computed !== true) {
|
|
11134
|
+
return referencesName(value.object, bindingName);
|
|
11135
|
+
}
|
|
11135
11136
|
if (value.type === "Property") {
|
|
11136
|
-
const computedKeyReferences = value.computed === true && referencesName(value.key,
|
|
11137
|
-
return computedKeyReferences || referencesName(value.value,
|
|
11137
|
+
const computedKeyReferences = value.computed === true && referencesName(value.key, bindingName);
|
|
11138
|
+
return computedKeyReferences || referencesName(value.value, bindingName);
|
|
11138
11139
|
}
|
|
11139
11140
|
return Object.entries(value).some(
|
|
11140
|
-
([key, child]) => key !== "parent" && referencesName(child,
|
|
11141
|
+
([key, child]) => key !== "parent" && referencesName(child, bindingName)
|
|
11141
11142
|
);
|
|
11142
11143
|
};
|
|
11143
|
-
var
|
|
11144
|
-
|
|
11145
|
-
if (
|
|
11146
|
-
|
|
11144
|
+
var inputUses = (value, inputName) => {
|
|
11145
|
+
if (!isRecord(value)) return [];
|
|
11146
|
+
if (value.type === "MemberExpression" && isRecord(value.object) && value.object.type === "Identifier" && value.object.name === inputName) {
|
|
11147
|
+
if (value.computed === true) return ["MaybeElement"];
|
|
11148
|
+
return isRecord(value.property) && value.property.type === "Identifier" && value.property.name === ELEMENT_FIELD ? ["Element"] : ["OtherField"];
|
|
11149
|
+
}
|
|
11150
|
+
if (value.type === "MemberExpression" && value.computed !== true) {
|
|
11151
|
+
return inputUses(value.object, inputName);
|
|
11152
|
+
}
|
|
11153
|
+
if ((value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") && shadowsBindingName(value, inputName)) {
|
|
11154
|
+
return [];
|
|
11155
|
+
}
|
|
11156
|
+
if (value.type === "Property") {
|
|
11157
|
+
const keyUses = value.computed === true ? inputUses(value.key, inputName) : [];
|
|
11158
|
+
return [...keyUses, ...inputUses(value.value, inputName)];
|
|
11147
11159
|
}
|
|
11148
|
-
if (
|
|
11149
|
-
return
|
|
11160
|
+
if (value.type === "Identifier" && value.name === inputName) {
|
|
11161
|
+
return ["MaybeElement"];
|
|
11150
11162
|
}
|
|
11151
|
-
return
|
|
11163
|
+
return Object.entries(value).flatMap(
|
|
11164
|
+
([key, child]) => key === "parent" ? [] : inputUses(child, inputName)
|
|
11165
|
+
);
|
|
11152
11166
|
};
|
|
11167
|
+
var elementProperty = (pattern) => pipe(
|
|
11168
|
+
pattern.properties,
|
|
11169
|
+
Array_exports.findFirst(
|
|
11170
|
+
(property) => property.type === "Property" && (property.key.type === "Literal" ? property.key.value === ELEMENT_FIELD : !property.computed && property.key.type === "Identifier" && property.key.name === ELEMENT_FIELD)
|
|
11171
|
+
)
|
|
11172
|
+
);
|
|
11173
|
+
var restBindingName = (pattern) => pipe(
|
|
11174
|
+
pattern.properties,
|
|
11175
|
+
Array_exports.findFirst(
|
|
11176
|
+
(property) => property.type === "RestElement" && property.argument.type === "Identifier" ? Option_exports.some(property.argument.name) : Option_exports.none()
|
|
11177
|
+
)
|
|
11178
|
+
);
|
|
11179
|
+
var withoutDefault = (value) => value.type === "AssignmentPattern" ? value.left : value;
|
|
11180
|
+
var bindingDiagnostic = (execute, bindingName) => {
|
|
11181
|
+
if (bindingName.startsWith("_")) {
|
|
11182
|
+
return Option_exports.some(ignoredElementBindingMessage(bindingName));
|
|
11183
|
+
}
|
|
11184
|
+
return referencesName(execute.body, bindingName) ? Option_exports.none() : Option_exports.some(unusedElementBindingMessage(bindingName));
|
|
11185
|
+
};
|
|
11186
|
+
var unpackedDiagnostic = (execute, bindingName) => {
|
|
11187
|
+
const uses = inputUses(execute.body, bindingName);
|
|
11188
|
+
if (Array_exports.isReadonlyArrayEmpty(uses)) {
|
|
11189
|
+
return Option_exports.some(unusedInputMessage(bindingName));
|
|
11190
|
+
}
|
|
11191
|
+
return uses.every((use) => use === "OtherField") ? Option_exports.some(unreadElementFieldMessage(bindingName)) : Option_exports.none();
|
|
11192
|
+
};
|
|
11193
|
+
var executeDiagnostic = (execute) => {
|
|
11194
|
+
const [firstParameter] = execute.params;
|
|
11195
|
+
if (firstParameter === void 0) {
|
|
11196
|
+
return Option_exports.some(NO_ELEMENT_BINDING_MESSAGE);
|
|
11197
|
+
}
|
|
11198
|
+
if (firstParameter.type === "Identifier") {
|
|
11199
|
+
return unpackedDiagnostic(execute, firstParameter.name);
|
|
11200
|
+
}
|
|
11201
|
+
if (firstParameter.type !== "ObjectPattern") {
|
|
11202
|
+
return Option_exports.some(NO_ELEMENT_BINDING_MESSAGE);
|
|
11203
|
+
}
|
|
11204
|
+
return Option_exports.match(elementProperty(firstParameter), {
|
|
11205
|
+
onNone: () => Option_exports.match(restBindingName(firstParameter), {
|
|
11206
|
+
onNone: () => Option_exports.some(NO_ELEMENT_BINDING_MESSAGE),
|
|
11207
|
+
onSome: (restName) => unpackedDiagnostic(execute, restName)
|
|
11208
|
+
}),
|
|
11209
|
+
onSome: (property) => {
|
|
11210
|
+
const pattern = withoutDefault(property.value);
|
|
11211
|
+
return pattern.type === "Identifier" ? bindingDiagnostic(execute, pattern.name) : Option_exports.none();
|
|
11212
|
+
}
|
|
11213
|
+
});
|
|
11214
|
+
};
|
|
11215
|
+
var executeFunction = (node) => pipe(
|
|
11216
|
+
Array_exports.get(node.arguments, 1),
|
|
11217
|
+
Option_exports.filter(isObjectExpression),
|
|
11218
|
+
Option_exports.flatMap((config) => AST_exports.objectGetValue(config, "execute")),
|
|
11219
|
+
Option_exports.filter(isExecuteFunction)
|
|
11220
|
+
);
|
|
11153
11221
|
var mountFactoryMustUseElement = Rule_exports.define({
|
|
11154
11222
|
name: "mount-factory-must-use-element",
|
|
11155
11223
|
meta: Rule_exports.meta({
|
|
11156
11224
|
type: "suggestion",
|
|
11157
|
-
description: "Require Mount
|
|
11225
|
+
description: "Require a Mount's execute to use its live element."
|
|
11158
11226
|
}),
|
|
11159
11227
|
create: function* () {
|
|
11160
11228
|
const ctx = yield* RuleContext;
|
|
11161
11229
|
return {
|
|
11162
11230
|
CallExpression: (node) => {
|
|
11163
|
-
if (!isCallExpression(node)
|
|
11164
|
-
if (node.callee.type !== "CallExpression" || !isMountDefinitionChain(node.callee)) {
|
|
11165
|
-
return Effect_exports.void;
|
|
11166
|
-
}
|
|
11167
|
-
const [factoryArgument] = node.arguments;
|
|
11168
|
-
if (factoryArgument === void 0 || !isFactoryFunction(factoryArgument)) {
|
|
11231
|
+
if (!isCallExpression(node) || !AST_exports.isCallOf(node, "Mount", MOUNT_DEFINITION_METHODS)) {
|
|
11169
11232
|
return Effect_exports.void;
|
|
11170
11233
|
}
|
|
11171
|
-
|
|
11172
|
-
return Option_exports.match(elementFactoryDiagnostic(elementFactory), {
|
|
11234
|
+
return Option_exports.match(executeFunction(node), {
|
|
11173
11235
|
onNone: () => Effect_exports.void,
|
|
11174
|
-
onSome: (
|
|
11236
|
+
onSome: (execute) => Option_exports.match(executeDiagnostic(execute), {
|
|
11237
|
+
onNone: () => Effect_exports.void,
|
|
11238
|
+
onSome: (message) => ctx.report(Diagnostic_exports.make({ node: execute, message }))
|
|
11239
|
+
})
|
|
11175
11240
|
});
|
|
11176
11241
|
}
|
|
11177
11242
|
};
|
|
@@ -11456,7 +11521,7 @@ var noDisablingDevGuardrails = Rule_exports.define({
|
|
|
11456
11521
|
});
|
|
11457
11522
|
|
|
11458
11523
|
// src/rules/no-duplicate-onmount-per-element.ts
|
|
11459
|
-
var DUPLICATE_ON_MOUNT_MESSAGE = "Only one OnMount attribute can attach to an element. Foldkit installs a single insert hook and tracks a single Mount fiber per element, so a later OnMount replaces the earlier one and its
|
|
11524
|
+
var DUPLICATE_ON_MOUNT_MESSAGE = "Only one OnMount attribute can attach to an element. Foldkit installs a single insert hook and tracks a single Mount fiber per element, so a later OnMount replaces the earlier one and its `execute` never runs. Combine the behaviors into one Mount definition.";
|
|
11460
11525
|
var isOnMountCallee = (callee) => {
|
|
11461
11526
|
if (callee.type === "Identifier") {
|
|
11462
11527
|
return callee.name === "OnMount";
|
|
@@ -11784,14 +11849,7 @@ var noEmptyChildrenArray = Rule_exports.define({
|
|
|
11784
11849
|
|
|
11785
11850
|
// src/rules/no-empty-commands-array.ts
|
|
11786
11851
|
var COMMANDS_PROPERTY = "commands";
|
|
11787
|
-
var
|
|
11788
|
-
var staticPropertyName2 = (property) => {
|
|
11789
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
11790
|
-
return Option_exports.some(property.key.name);
|
|
11791
|
-
}
|
|
11792
|
-
return staticStringValue(property.key);
|
|
11793
|
-
};
|
|
11794
|
-
var isEmptyCommandsProperty = (property) => Option_exports.contains(staticPropertyName2(property), COMMANDS_PROPERTY) && isArrayExpression(property.value) && Array_exports.isReadonlyArrayEmpty(property.value.elements);
|
|
11852
|
+
var isEmptyCommandsProperty = (property) => Option_exports.contains(staticPropertyName(property), COMMANDS_PROPERTY) && isArrayExpression(property.value) && Array_exports.isReadonlyArrayEmpty(property.value.elements);
|
|
11795
11853
|
var removalRange = (sourceText, object, property, index) => {
|
|
11796
11854
|
const maybePrevious = Array_exports.get(object.properties, index - 1);
|
|
11797
11855
|
if (Option_exports.isSome(maybePrevious)) {
|
|
@@ -11832,11 +11890,11 @@ var noEmptyCommandsArray = Rule_exports.define({
|
|
|
11832
11890
|
);
|
|
11833
11891
|
const hasDynamicComputedProperty = Array_exports.some(
|
|
11834
11892
|
node.properties,
|
|
11835
|
-
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(
|
|
11893
|
+
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(staticPropertyName(property))
|
|
11836
11894
|
);
|
|
11837
11895
|
const commandProperties = Array_exports.filter(
|
|
11838
11896
|
node.properties,
|
|
11839
|
-
(property) => isObjectProperty(property) && Option_exports.contains(
|
|
11897
|
+
(property) => isObjectProperty(property) && Option_exports.contains(staticPropertyName(property), COMMANDS_PROPERTY)
|
|
11840
11898
|
);
|
|
11841
11899
|
const hasComments = Array_exports.isReadonlyArrayNonEmpty(
|
|
11842
11900
|
ctx.sourceCode.getCommentsInside(node)
|
|
@@ -11952,35 +12010,14 @@ var noEmptyObjectTaggedCall = Rule_exports.define({
|
|
|
11952
12010
|
|
|
11953
12011
|
// src/rules/no-empty-to-parent-out-message.ts
|
|
11954
12012
|
var TO_PARENT_OUT_MESSAGE_PROPERTY = "toParentOutMessage";
|
|
11955
|
-
var isObjectProperty2 = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Property";
|
|
11956
|
-
var staticPropertyName3 = (property) => {
|
|
11957
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
11958
|
-
return Option_exports.some(property.key.name);
|
|
11959
|
-
}
|
|
11960
|
-
return staticStringValue(property.key);
|
|
11961
|
-
};
|
|
11962
12013
|
var isArrowFunctionExpression3 = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "ArrowFunctionExpression";
|
|
11963
12014
|
var isFunctionExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "FunctionExpression";
|
|
11964
12015
|
var isMapperFunction = (node) => isArrowFunctionExpression3(node) && !node.async || isFunctionExpression(node) && !node.async && !node.generator;
|
|
11965
|
-
var isIdentifierReference = (node) => isIdentifier(node);
|
|
11966
|
-
var indexReferences = (scopes) => {
|
|
11967
|
-
const references = /* @__PURE__ */ new WeakMap();
|
|
11968
|
-
for (const scope3 of scopes) {
|
|
11969
|
-
for (const reference of scope3.references) {
|
|
11970
|
-
references.set(reference.identifier, reference);
|
|
11971
|
-
}
|
|
11972
|
-
}
|
|
11973
|
-
return references;
|
|
11974
|
-
};
|
|
11975
12016
|
var isUnshadowedUndefined = (references, node) => {
|
|
11976
12017
|
if (!isIdentifierReference(node) || node.name !== "undefined") {
|
|
11977
12018
|
return false;
|
|
11978
12019
|
}
|
|
11979
|
-
|
|
11980
|
-
return true;
|
|
11981
|
-
}
|
|
11982
|
-
const reference = references.get(node);
|
|
11983
|
-
return reference !== void 0 && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs));
|
|
12020
|
+
return isUnshadowedReference(references, node);
|
|
11984
12021
|
};
|
|
11985
12022
|
var directlyReturnsUndefined = (references, mapper) => {
|
|
11986
12023
|
if (mapper.body === null) {
|
|
@@ -11993,7 +12030,7 @@ var directlyReturnsUndefined = (references, mapper) => {
|
|
|
11993
12030
|
return firstStatement?.type === "ReturnStatement" && secondStatement === void 0 && isUnshadowedUndefined(references, firstStatement.argument);
|
|
11994
12031
|
};
|
|
11995
12032
|
var isEmptyMapperProperty = (references, property) => property.kind === "init" && Option_exports.contains(
|
|
11996
|
-
|
|
12033
|
+
staticPropertyName(property),
|
|
11997
12034
|
TO_PARENT_OUT_MESSAGE_PROPERTY
|
|
11998
12035
|
) && isMapperFunction(property.value) && directlyReturnsUndefined(references, property.value);
|
|
11999
12036
|
var removalRange2 = (sourceText, object, property, index) => {
|
|
@@ -12038,12 +12075,12 @@ var noEmptyToParentOutMessage = Rule_exports.define({
|
|
|
12038
12075
|
);
|
|
12039
12076
|
const hasDynamicComputedProperty = Array_exports.some(
|
|
12040
12077
|
node.properties,
|
|
12041
|
-
(property) =>
|
|
12078
|
+
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(staticPropertyName(property))
|
|
12042
12079
|
);
|
|
12043
12080
|
const mapperProperties = Array_exports.filter(
|
|
12044
12081
|
node.properties,
|
|
12045
|
-
(property) =>
|
|
12046
|
-
|
|
12082
|
+
(property) => isObjectProperty(property) && Option_exports.contains(
|
|
12083
|
+
staticPropertyName(property),
|
|
12047
12084
|
TO_PARENT_OUT_MESSAGE_PROPERTY
|
|
12048
12085
|
)
|
|
12049
12086
|
);
|
|
@@ -12053,7 +12090,7 @@ var noEmptyToParentOutMessage = Rule_exports.define({
|
|
|
12053
12090
|
return Effect_exports.forEach(
|
|
12054
12091
|
node.properties.entries(),
|
|
12055
12092
|
([index, property]) => {
|
|
12056
|
-
if (!
|
|
12093
|
+
if (!isObjectProperty(property) || !isEmptyMapperProperty(references, property)) {
|
|
12057
12094
|
return Effect_exports.void;
|
|
12058
12095
|
}
|
|
12059
12096
|
const diagnostic = Diagnostic_exports.make({
|
|
@@ -12216,6 +12253,628 @@ var noHardcodedRouteStrings = Rule_exports.define({
|
|
|
12216
12253
|
}
|
|
12217
12254
|
});
|
|
12218
12255
|
|
|
12256
|
+
// src/rules/no-impure-call-at-decision-time.ts
|
|
12257
|
+
var globalContainers = /* @__PURE__ */ new Set(["globalThis", "self", "window"]);
|
|
12258
|
+
var impureCallByPath = /* @__PURE__ */ new Map([
|
|
12259
|
+
[
|
|
12260
|
+
"Date",
|
|
12261
|
+
{
|
|
12262
|
+
display: "Date()",
|
|
12263
|
+
guidance: "Use Clock.currentTimeMillis and construct the Date from that value."
|
|
12264
|
+
}
|
|
12265
|
+
],
|
|
12266
|
+
[
|
|
12267
|
+
"Date.now",
|
|
12268
|
+
{
|
|
12269
|
+
display: "Date.now()",
|
|
12270
|
+
guidance: "Use Clock.currentTimeMillis."
|
|
12271
|
+
}
|
|
12272
|
+
],
|
|
12273
|
+
[
|
|
12274
|
+
"Math.random",
|
|
12275
|
+
{
|
|
12276
|
+
display: "Math.random()",
|
|
12277
|
+
guidance: "Use Random."
|
|
12278
|
+
}
|
|
12279
|
+
],
|
|
12280
|
+
[
|
|
12281
|
+
"performance.now",
|
|
12282
|
+
{
|
|
12283
|
+
display: "performance.now()",
|
|
12284
|
+
guidance: "Use Clock."
|
|
12285
|
+
}
|
|
12286
|
+
],
|
|
12287
|
+
[
|
|
12288
|
+
"crypto.randomUUID",
|
|
12289
|
+
{
|
|
12290
|
+
display: "crypto.randomUUID()",
|
|
12291
|
+
guidance: "Use Crypto.Crypto's randomUUIDv4 Effect with a platform Crypto layer."
|
|
12292
|
+
}
|
|
12293
|
+
],
|
|
12294
|
+
[
|
|
12295
|
+
"crypto.getRandomValues",
|
|
12296
|
+
{
|
|
12297
|
+
display: "crypto.getRandomValues()",
|
|
12298
|
+
guidance: "Use Random or Crypto.Crypto with a platform Crypto layer."
|
|
12299
|
+
}
|
|
12300
|
+
]
|
|
12301
|
+
]);
|
|
12302
|
+
var newDateOperation = {
|
|
12303
|
+
display: "new Date()",
|
|
12304
|
+
guidance: "Use Clock.currentTimeMillis and construct the Date from that value."
|
|
12305
|
+
};
|
|
12306
|
+
var isFunction2 = (node) => typeof node === "object" && node !== null && "type" in node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration");
|
|
12307
|
+
var isTransparentExpression = (node) => {
|
|
12308
|
+
if (typeof node !== "object" || node === null || !("type" in node)) {
|
|
12309
|
+
return false;
|
|
12310
|
+
}
|
|
12311
|
+
return node.type === "ChainExpression" || node.type === "ParenthesizedExpression" || node.type === "TSAsExpression" || node.type === "TSInstantiationExpression" || node.type === "TSNonNullExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSTypeAssertion";
|
|
12312
|
+
};
|
|
12313
|
+
var innermostExpression = (node) => isTransparentExpression(node) ? innermostExpression(node.expression) : node;
|
|
12314
|
+
var outermostExpression = (node) => {
|
|
12315
|
+
const parent = node.parent;
|
|
12316
|
+
return isTransparentExpression(parent) && parent.expression === node ? outermostExpression(parent) : node;
|
|
12317
|
+
};
|
|
12318
|
+
var staticPath = (node) => {
|
|
12319
|
+
const expression = innermostExpression(node);
|
|
12320
|
+
if (isIdentifierReference(expression)) {
|
|
12321
|
+
return Option_exports.some({ root: expression, members: [] });
|
|
12322
|
+
}
|
|
12323
|
+
if (!isMemberExpression(expression)) {
|
|
12324
|
+
return Option_exports.none();
|
|
12325
|
+
}
|
|
12326
|
+
return Option_exports.flatMap(
|
|
12327
|
+
staticPath(expression.object),
|
|
12328
|
+
(path) => Option_exports.map(staticMemberName(expression), (member) => ({
|
|
12329
|
+
root: path.root,
|
|
12330
|
+
members: [...path.members, member]
|
|
12331
|
+
}))
|
|
12332
|
+
);
|
|
12333
|
+
};
|
|
12334
|
+
var globalPathKey = (references, node) => Option_exports.flatMap(staticPath(node), (path) => {
|
|
12335
|
+
if (!isUnshadowedReference(references, path.root)) {
|
|
12336
|
+
return Option_exports.none();
|
|
12337
|
+
}
|
|
12338
|
+
const members = globalContainers.has(path.root.name) ? path.members : [path.root.name, ...path.members];
|
|
12339
|
+
return Option_exports.some(members.join("."));
|
|
12340
|
+
});
|
|
12341
|
+
var importedName = (node) => node.imported.type === "Identifier" ? Option_exports.some(node.imported.name) : Option_exports.some(node.imported.value);
|
|
12342
|
+
var importedPath = (references, node) => Option_exports.flatMap(staticPath(node), (path) => {
|
|
12343
|
+
if (references === void 0) {
|
|
12344
|
+
return Option_exports.some({
|
|
12345
|
+
source: "",
|
|
12346
|
+
members: [path.root.name, ...path.members]
|
|
12347
|
+
});
|
|
12348
|
+
}
|
|
12349
|
+
const reference = references.get(path.root);
|
|
12350
|
+
const maybeDefinition = Option_exports.flatMap(
|
|
12351
|
+
Option_exports.fromNullishOr(reference?.resolved),
|
|
12352
|
+
(variable) => Array_exports.findFirst(
|
|
12353
|
+
variable.defs,
|
|
12354
|
+
(definition) => definition.type === "ImportBinding"
|
|
12355
|
+
)
|
|
12356
|
+
);
|
|
12357
|
+
return Option_exports.flatMap(maybeDefinition, (definition) => {
|
|
12358
|
+
if (definition.parent?.type !== "ImportDeclaration") {
|
|
12359
|
+
return Option_exports.none();
|
|
12360
|
+
}
|
|
12361
|
+
const source = definition.parent.source.value;
|
|
12362
|
+
if (definition.node.type === "ImportNamespaceSpecifier") {
|
|
12363
|
+
return Option_exports.some({ source, members: path.members });
|
|
12364
|
+
}
|
|
12365
|
+
if (definition.node.type !== "ImportSpecifier") {
|
|
12366
|
+
return Option_exports.none();
|
|
12367
|
+
}
|
|
12368
|
+
return Option_exports.map(importedName(definition.node), (name) => ({
|
|
12369
|
+
source,
|
|
12370
|
+
members: [name, ...path.members]
|
|
12371
|
+
}));
|
|
12372
|
+
});
|
|
12373
|
+
});
|
|
12374
|
+
var normalizedApiPath = (path) => {
|
|
12375
|
+
if (path.source === "" || path.source === "effect" || path.source === "foldkit") {
|
|
12376
|
+
return Option_exports.some(path.members);
|
|
12377
|
+
}
|
|
12378
|
+
if (path.source === "effect/Effect") {
|
|
12379
|
+
return Option_exports.some(["Effect", ...path.members]);
|
|
12380
|
+
}
|
|
12381
|
+
if (path.source === "effect/Stream") {
|
|
12382
|
+
return Option_exports.some(["Stream", ...path.members]);
|
|
12383
|
+
}
|
|
12384
|
+
if (path.source === "foldkit/command") {
|
|
12385
|
+
return Option_exports.some(["Command", ...path.members]);
|
|
12386
|
+
}
|
|
12387
|
+
if (path.source === "foldkit/managedResource") {
|
|
12388
|
+
return Option_exports.some(["ManagedResource", ...path.members]);
|
|
12389
|
+
}
|
|
12390
|
+
if (path.source === "foldkit/mount") {
|
|
12391
|
+
return Option_exports.some(["Mount", ...path.members]);
|
|
12392
|
+
}
|
|
12393
|
+
if (path.source === "foldkit/subscription") {
|
|
12394
|
+
return Option_exports.some(["Subscription", ...path.members]);
|
|
12395
|
+
}
|
|
12396
|
+
return Option_exports.none();
|
|
12397
|
+
};
|
|
12398
|
+
var headCall = (node) => node.callee.type === "CallExpression" ? headCall(node.callee) : node;
|
|
12399
|
+
var apiCallKey = (references, node) => Option_exports.flatMap(
|
|
12400
|
+
importedPath(references, headCall(node).callee),
|
|
12401
|
+
(path) => Option_exports.map(normalizedApiPath(path), (members) => members.join("."))
|
|
12402
|
+
);
|
|
12403
|
+
var enclosingCallArgument = (node) => {
|
|
12404
|
+
const argument = outermostExpression(node);
|
|
12405
|
+
const parent = argument.parent;
|
|
12406
|
+
return parent?.type === "CallExpression" && parent.arguments.some((candidate) => candidate === argument) ? Option_exports.some({ call: parent, argument }) : Option_exports.none();
|
|
12407
|
+
};
|
|
12408
|
+
var enclosingPropertyValue = (node) => {
|
|
12409
|
+
const value = outermostExpression(node);
|
|
12410
|
+
const parent = value.parent;
|
|
12411
|
+
return isObjectProperty(parent) && parent.value === value ? Option_exports.some(parent) : Option_exports.none();
|
|
12412
|
+
};
|
|
12413
|
+
var effectFunctionFactories = /* @__PURE__ */ new Set(["Effect.fn", "Effect.fnUntraced"]);
|
|
12414
|
+
var directByArity = (...entries) => new Map(
|
|
12415
|
+
entries.map(([arity, ...argumentIndices]) => [
|
|
12416
|
+
arity,
|
|
12417
|
+
new Set(argumentIndices)
|
|
12418
|
+
])
|
|
12419
|
+
);
|
|
12420
|
+
var propertiesByArity = (...entries) => {
|
|
12421
|
+
const properties2 = /* @__PURE__ */ new Map();
|
|
12422
|
+
for (const [arity, argumentIndex, ...propertyNames] of entries) {
|
|
12423
|
+
const byArgument = properties2.get(arity) ?? /* @__PURE__ */ new Map();
|
|
12424
|
+
byArgument.set(
|
|
12425
|
+
argumentIndex,
|
|
12426
|
+
Array_exports.isArrayEmpty(propertyNames) ? true : new Set(propertyNames)
|
|
12427
|
+
);
|
|
12428
|
+
properties2.set(arity, byArgument);
|
|
12429
|
+
}
|
|
12430
|
+
return properties2;
|
|
12431
|
+
};
|
|
12432
|
+
var direct = (...entries) => ({ direct: directByArity(...entries) });
|
|
12433
|
+
var properties = (...entries) => ({
|
|
12434
|
+
properties: propertiesByArity(...entries)
|
|
12435
|
+
});
|
|
12436
|
+
var unaryCallback = direct([1, 0]);
|
|
12437
|
+
var unaryDualCallback = direct([1, 0], [2, 1]);
|
|
12438
|
+
var unaryDualCallbackWithOptions = direct([1, 0], [2, 0, 1], [3, 1]);
|
|
12439
|
+
var binaryDualCallback = direct([2, 1], [3, 2]);
|
|
12440
|
+
var binaryDualCallbackWithOptions = direct([2, 1], [3, 1, 2], [4, 2]);
|
|
12441
|
+
var successAndFailureProperties = properties(
|
|
12442
|
+
[1, 0, "onFailure", "onSuccess"],
|
|
12443
|
+
[2, 1, "onFailure", "onSuccess"]
|
|
12444
|
+
);
|
|
12445
|
+
var taggedCallback = direct([2, 1], [3, 1, 2], [4, 2, 3]);
|
|
12446
|
+
var taggedCallbackMap = {
|
|
12447
|
+
direct: directByArity([2, 1], [3, 2]),
|
|
12448
|
+
properties: propertiesByArity([1, 0], [2, 0], [2, 1], [3, 1])
|
|
12449
|
+
};
|
|
12450
|
+
var reasonCallback = direct([3, 2], [4, 2, 3], [5, 3, 4]);
|
|
12451
|
+
var reasonCallbackMap = {
|
|
12452
|
+
direct: directByArity([3, 2], [4, 3]),
|
|
12453
|
+
properties: propertiesByArity([2, 1], [3, 1], [3, 2], [4, 2])
|
|
12454
|
+
};
|
|
12455
|
+
var predicateAndCallback = direct([2, 0, 1], [3, 0, 1, 2], [4, 1, 2, 3]);
|
|
12456
|
+
var deferredCallbackByApi = /* @__PURE__ */ new Map([
|
|
12457
|
+
["Effect.acquireRelease", direct([2, 1], [3, 1])],
|
|
12458
|
+
["Effect.acquireUseRelease", direct([3, 1, 2])],
|
|
12459
|
+
["Effect.addFinalizer", unaryCallback],
|
|
12460
|
+
["Effect.andThen", unaryDualCallback],
|
|
12461
|
+
["Effect.bind", binaryDualCallback],
|
|
12462
|
+
["Effect.callback", unaryCallback],
|
|
12463
|
+
["Effect.catch", unaryDualCallback],
|
|
12464
|
+
["Effect.catchCause", unaryDualCallback],
|
|
12465
|
+
["Effect.catchCauseFilter", predicateAndCallback],
|
|
12466
|
+
["Effect.catchCauseIf", predicateAndCallback],
|
|
12467
|
+
["Effect.catchDefect", unaryDualCallback],
|
|
12468
|
+
["Effect.catchFilter", predicateAndCallback],
|
|
12469
|
+
["Effect.catchIf", predicateAndCallback],
|
|
12470
|
+
["Effect.catchReason", reasonCallback],
|
|
12471
|
+
["Effect.catchReasons", reasonCallbackMap],
|
|
12472
|
+
["Effect.catchTag", taggedCallback],
|
|
12473
|
+
["Effect.catchTags", taggedCallbackMap],
|
|
12474
|
+
["Effect.clockWith", unaryCallback],
|
|
12475
|
+
["Effect.contextWith", unaryCallback],
|
|
12476
|
+
["Effect.effectify", direct([1, 0], [2, 0, 1], [3, 0, 1, 2])],
|
|
12477
|
+
["Effect.failCauseSync", unaryCallback],
|
|
12478
|
+
["Effect.failSync", unaryCallback],
|
|
12479
|
+
["Effect.filter", unaryDualCallbackWithOptions],
|
|
12480
|
+
["Effect.filterMap", unaryDualCallback],
|
|
12481
|
+
["Effect.filterMapEffect", unaryDualCallbackWithOptions],
|
|
12482
|
+
["Effect.filterMapOrElse", direct([2, 0, 1], [3, 1, 2])],
|
|
12483
|
+
["Effect.filterMapOrFail", direct([1, 0], [2, 0, 1], [3, 1, 2])],
|
|
12484
|
+
["Effect.filterOrElse", direct([2, 0, 1], [3, 1, 2])],
|
|
12485
|
+
["Effect.filterOrFail", direct([1, 0], [2, 0, 1], [3, 1, 2])],
|
|
12486
|
+
["Effect.findFirst", unaryDualCallback],
|
|
12487
|
+
["Effect.findFirstFilter", unaryDualCallback],
|
|
12488
|
+
["Effect.flatMap", unaryDualCallback],
|
|
12489
|
+
["Effect.forEach", unaryDualCallbackWithOptions],
|
|
12490
|
+
["Effect.gen", direct([1, 0], [2, 1])],
|
|
12491
|
+
["Effect.interruptibleMask", unaryCallback],
|
|
12492
|
+
["Effect.let", binaryDualCallback],
|
|
12493
|
+
["Effect.map", unaryDualCallback],
|
|
12494
|
+
["Effect.mapBoth", successAndFailureProperties],
|
|
12495
|
+
["Effect.mapError", unaryDualCallback],
|
|
12496
|
+
["Effect.match", successAndFailureProperties],
|
|
12497
|
+
["Effect.matchCause", successAndFailureProperties],
|
|
12498
|
+
["Effect.matchCauseEffect", successAndFailureProperties],
|
|
12499
|
+
["Effect.matchEffect", successAndFailureProperties],
|
|
12500
|
+
["Effect.onError", unaryDualCallback],
|
|
12501
|
+
["Effect.onErrorFilter", predicateAndCallback],
|
|
12502
|
+
["Effect.onErrorIf", predicateAndCallback],
|
|
12503
|
+
["Effect.onExit", unaryDualCallback],
|
|
12504
|
+
["Effect.onExitFilter", predicateAndCallback],
|
|
12505
|
+
["Effect.onExitIf", predicateAndCallback],
|
|
12506
|
+
["Effect.onExitPrimitive", direct([2, 1], [3, 1])],
|
|
12507
|
+
["Effect.onInterrupt", unaryDualCallback],
|
|
12508
|
+
["Effect.orElseSucceed", unaryDualCallback],
|
|
12509
|
+
["Effect.partition", unaryDualCallbackWithOptions],
|
|
12510
|
+
["Effect.promise", unaryCallback],
|
|
12511
|
+
["Effect.reduce", direct([2, 0, 1], [3, 1, 2])],
|
|
12512
|
+
[
|
|
12513
|
+
"Effect.repeat",
|
|
12514
|
+
properties([1, 0, "while", "until"], [2, 1, "while", "until"])
|
|
12515
|
+
],
|
|
12516
|
+
["Effect.repeatOrElse", binaryDualCallback],
|
|
12517
|
+
[
|
|
12518
|
+
"Effect.retry",
|
|
12519
|
+
properties([1, 0, "while", "until"], [2, 1, "while", "until"])
|
|
12520
|
+
],
|
|
12521
|
+
["Effect.retryOrElse", binaryDualCallback],
|
|
12522
|
+
["Effect.scopedWith", unaryCallback],
|
|
12523
|
+
["Effect.suspend", unaryCallback],
|
|
12524
|
+
["Effect.sync", unaryCallback],
|
|
12525
|
+
["Effect.tap", unaryDualCallback],
|
|
12526
|
+
["Effect.tapCause", unaryDualCallback],
|
|
12527
|
+
["Effect.tapCauseFilter", predicateAndCallback],
|
|
12528
|
+
["Effect.tapCauseIf", predicateAndCallback],
|
|
12529
|
+
["Effect.tapDefect", unaryDualCallback],
|
|
12530
|
+
["Effect.tapError", unaryDualCallback],
|
|
12531
|
+
["Effect.tapErrorTag", taggedCallback],
|
|
12532
|
+
["Effect.timeoutOrElse", properties([1, 0, "orElse"], [2, 1, "orElse"])],
|
|
12533
|
+
["Effect.track", direct([2, 1], [3, 2])],
|
|
12534
|
+
["Effect.trackDefects", direct([2, 1], [3, 2])],
|
|
12535
|
+
["Effect.trackDuration", direct([2, 1], [3, 2])],
|
|
12536
|
+
["Effect.trackErrors", direct([2, 1], [3, 2])],
|
|
12537
|
+
["Effect.trackSuccesses", direct([2, 1], [3, 2])],
|
|
12538
|
+
[
|
|
12539
|
+
"Effect.try",
|
|
12540
|
+
{
|
|
12541
|
+
direct: directByArity([1, 0]),
|
|
12542
|
+
properties: propertiesByArity([1, 0, "try", "catch"])
|
|
12543
|
+
}
|
|
12544
|
+
],
|
|
12545
|
+
[
|
|
12546
|
+
"Effect.tryPromise",
|
|
12547
|
+
{
|
|
12548
|
+
direct: directByArity([1, 0]),
|
|
12549
|
+
properties: propertiesByArity([1, 0, "try", "catch"])
|
|
12550
|
+
}
|
|
12551
|
+
],
|
|
12552
|
+
["Effect.uninterruptibleMask", unaryCallback],
|
|
12553
|
+
["Effect.updateContext", unaryDualCallback],
|
|
12554
|
+
["Effect.updateService", binaryDualCallback],
|
|
12555
|
+
[
|
|
12556
|
+
"Effect.updateServiceScoped",
|
|
12557
|
+
{
|
|
12558
|
+
direct: directByArity([2, 1], [3, 1]),
|
|
12559
|
+
properties: propertiesByArity([3, 2, "reset"])
|
|
12560
|
+
}
|
|
12561
|
+
],
|
|
12562
|
+
["Effect.useSpan", direct([2, 1], [3, 2])],
|
|
12563
|
+
["Effect.validate", unaryDualCallbackWithOptions],
|
|
12564
|
+
["Effect.whileLoop", properties([1, 0, "while", "body", "step"])],
|
|
12565
|
+
[
|
|
12566
|
+
"Effect.withExecutionPlan",
|
|
12567
|
+
properties([2, 1, "onEvent"], [3, 2, "onEvent"])
|
|
12568
|
+
],
|
|
12569
|
+
["Effect.withFiber", unaryCallback],
|
|
12570
|
+
["Effect.zipWith", binaryDualCallbackWithOptions],
|
|
12571
|
+
["Effect.race", properties([2, 1, "onWinner"], [3, 2, "onWinner"])],
|
|
12572
|
+
["Effect.raceFirst", properties([2, 1, "onWinner"], [3, 2, "onWinner"])],
|
|
12573
|
+
["Effect.raceAll", properties([2, 1, "onWinner"])],
|
|
12574
|
+
["Effect.raceAllFirst", properties([2, 1, "onWinner"])],
|
|
12575
|
+
["Stream.bind", binaryDualCallbackWithOptions],
|
|
12576
|
+
["Stream.bindEffect", binaryDualCallbackWithOptions],
|
|
12577
|
+
["Stream.callback", unaryCallback],
|
|
12578
|
+
["Stream.catch", unaryDualCallback],
|
|
12579
|
+
["Stream.catchCause", unaryDualCallback],
|
|
12580
|
+
["Stream.catchCauseFilter", predicateAndCallback],
|
|
12581
|
+
["Stream.catchCauseIf", predicateAndCallback],
|
|
12582
|
+
["Stream.catchFilter", predicateAndCallback],
|
|
12583
|
+
["Stream.catchIf", predicateAndCallback],
|
|
12584
|
+
["Stream.catchReason", reasonCallback],
|
|
12585
|
+
["Stream.catchReasons", reasonCallbackMap],
|
|
12586
|
+
["Stream.catchTag", taggedCallback],
|
|
12587
|
+
["Stream.catchTags", taggedCallbackMap],
|
|
12588
|
+
["Stream.changesWith", unaryDualCallback],
|
|
12589
|
+
["Stream.changesWithEffect", unaryDualCallback],
|
|
12590
|
+
["Stream.combine", direct([3, 1, 2], [4, 2, 3])],
|
|
12591
|
+
["Stream.combineArray", direct([3, 1, 2], [4, 2, 3])],
|
|
12592
|
+
["Stream.crossWith", binaryDualCallback],
|
|
12593
|
+
["Stream.dropUntil", unaryDualCallback],
|
|
12594
|
+
["Stream.dropUntilEffect", unaryDualCallback],
|
|
12595
|
+
["Stream.dropWhile", unaryDualCallback],
|
|
12596
|
+
["Stream.dropWhileEffect", unaryDualCallback],
|
|
12597
|
+
["Stream.dropWhileFilter", unaryDualCallback],
|
|
12598
|
+
["Stream.failCauseSync", unaryCallback],
|
|
12599
|
+
["Stream.failSync", unaryCallback],
|
|
12600
|
+
["Stream.filter", unaryDualCallback],
|
|
12601
|
+
["Stream.filterEffect", unaryDualCallback],
|
|
12602
|
+
["Stream.filterMap", unaryDualCallback],
|
|
12603
|
+
["Stream.filterMapEffect", unaryDualCallback],
|
|
12604
|
+
["Stream.flatMap", unaryDualCallbackWithOptions],
|
|
12605
|
+
["Stream.fromAsyncIterable", direct([2, 1])],
|
|
12606
|
+
["Stream.fromReadableStream", properties([1, 0, "evaluate", "onError"])],
|
|
12607
|
+
["Stream.groupAdjacentBy", unaryDualCallback],
|
|
12608
|
+
["Stream.groupBy", unaryDualCallbackWithOptions],
|
|
12609
|
+
["Stream.groupByKey", unaryDualCallbackWithOptions],
|
|
12610
|
+
["Stream.iterate", direct([2, 1])],
|
|
12611
|
+
["Stream.limitBytes", direct([2, 1], [3, 2])],
|
|
12612
|
+
["Stream.map", unaryDualCallback],
|
|
12613
|
+
[
|
|
12614
|
+
"Stream.mapAccum",
|
|
12615
|
+
{
|
|
12616
|
+
direct: directByArity([2, 0, 1], [3, 0, 1, 2], [4, 1, 2]),
|
|
12617
|
+
properties: propertiesByArity([3, 2, "onHalt"], [4, 3, "onHalt"])
|
|
12618
|
+
}
|
|
12619
|
+
],
|
|
12620
|
+
[
|
|
12621
|
+
"Stream.mapAccumArray",
|
|
12622
|
+
{
|
|
12623
|
+
direct: directByArity([2, 0, 1], [3, 0, 1, 2], [4, 1, 2]),
|
|
12624
|
+
properties: propertiesByArity([3, 2, "onHalt"], [4, 3, "onHalt"])
|
|
12625
|
+
}
|
|
12626
|
+
],
|
|
12627
|
+
[
|
|
12628
|
+
"Stream.mapAccumArrayEffect",
|
|
12629
|
+
{
|
|
12630
|
+
direct: directByArity([2, 0, 1], [3, 0, 1, 2], [4, 1, 2]),
|
|
12631
|
+
properties: propertiesByArity([3, 2, "onHalt"], [4, 3, "onHalt"])
|
|
12632
|
+
}
|
|
12633
|
+
],
|
|
12634
|
+
[
|
|
12635
|
+
"Stream.mapAccumEffect",
|
|
12636
|
+
{
|
|
12637
|
+
direct: directByArity([2, 0, 1], [3, 0, 1, 2], [4, 1, 2]),
|
|
12638
|
+
properties: propertiesByArity([3, 2, "onHalt"], [4, 3, "onHalt"])
|
|
12639
|
+
}
|
|
12640
|
+
],
|
|
12641
|
+
["Stream.mapArray", unaryDualCallback],
|
|
12642
|
+
["Stream.mapArrayEffect", unaryDualCallback],
|
|
12643
|
+
["Stream.mapBoth", successAndFailureProperties],
|
|
12644
|
+
["Stream.mapEffect", unaryDualCallbackWithOptions],
|
|
12645
|
+
["Stream.mapError", unaryDualCallback],
|
|
12646
|
+
["Stream.let", binaryDualCallback],
|
|
12647
|
+
["Stream.onError", unaryDualCallback],
|
|
12648
|
+
["Stream.onExit", unaryDualCallback],
|
|
12649
|
+
["Stream.onFirst", unaryDualCallback],
|
|
12650
|
+
["Stream.orElseIfEmpty", unaryDualCallback],
|
|
12651
|
+
["Stream.orElseSucceed", unaryDualCallback],
|
|
12652
|
+
["Stream.paginate", direct([2, 1])],
|
|
12653
|
+
["Stream.partition", unaryDualCallbackWithOptions],
|
|
12654
|
+
["Stream.partitionEffect", unaryDualCallbackWithOptions],
|
|
12655
|
+
["Stream.partitionQueue", unaryDualCallbackWithOptions],
|
|
12656
|
+
["Stream.runFold", direct([2, 0, 1], [3, 1, 2])],
|
|
12657
|
+
["Stream.runFoldEffect", direct([2, 0, 1], [3, 1, 2])],
|
|
12658
|
+
["Stream.runForEach", unaryDualCallback],
|
|
12659
|
+
["Stream.runForEachArray", unaryDualCallback],
|
|
12660
|
+
["Stream.runForEachWhile", unaryDualCallback],
|
|
12661
|
+
["Stream.scan", direct([2, 1], [3, 2])],
|
|
12662
|
+
["Stream.scanEffect", direct([2, 1], [3, 2])],
|
|
12663
|
+
["Stream.split", unaryDualCallback],
|
|
12664
|
+
["Stream.suspend", unaryCallback],
|
|
12665
|
+
["Stream.switchMap", unaryDualCallbackWithOptions],
|
|
12666
|
+
["Stream.sync", unaryCallback],
|
|
12667
|
+
["Stream.takeUntil", unaryDualCallbackWithOptions],
|
|
12668
|
+
["Stream.takeUntilEffect", unaryDualCallbackWithOptions],
|
|
12669
|
+
["Stream.takeWhile", unaryDualCallback],
|
|
12670
|
+
["Stream.takeWhileEffect", unaryDualCallback],
|
|
12671
|
+
["Stream.takeWhileFilter", unaryDualCallback],
|
|
12672
|
+
["Stream.tap", unaryDualCallbackWithOptions],
|
|
12673
|
+
[
|
|
12674
|
+
"Stream.tapBoth",
|
|
12675
|
+
properties([1, 0, "onElement", "onError"], [2, 1, "onElement", "onError"])
|
|
12676
|
+
],
|
|
12677
|
+
["Stream.tapCause", unaryDualCallback],
|
|
12678
|
+
["Stream.tapError", unaryDualCallback],
|
|
12679
|
+
["Stream.throttle", properties([1, 0, "cost"], [2, 1, "cost"])],
|
|
12680
|
+
["Stream.throttleEffect", properties([1, 0, "cost"], [2, 1, "cost"])],
|
|
12681
|
+
["Stream.timeoutOrElse", properties([1, 0, "orElse"], [2, 1, "orElse"])],
|
|
12682
|
+
["Stream.transformPull", direct([2, 1])],
|
|
12683
|
+
["Stream.transformPullBracket", direct([2, 1])],
|
|
12684
|
+
["Stream.unfold", direct([2, 1])],
|
|
12685
|
+
["Stream.updateContext", unaryDualCallback],
|
|
12686
|
+
["Stream.updateService", binaryDualCallback],
|
|
12687
|
+
[
|
|
12688
|
+
"Stream.withExecutionPlan",
|
|
12689
|
+
properties([2, 1, "onEvent"], [3, 2, "onEvent"])
|
|
12690
|
+
],
|
|
12691
|
+
["Stream.zipLatestWith", binaryDualCallback],
|
|
12692
|
+
["Stream.zipWith", binaryDualCallback],
|
|
12693
|
+
["Stream.zipWithArray", binaryDualCallback]
|
|
12694
|
+
]);
|
|
12695
|
+
var isEffectFunctionBody = (argument, call) => {
|
|
12696
|
+
const maybeFirstArgument = Array_exports.head(call.arguments);
|
|
12697
|
+
if (Option_exports.contains(maybeFirstArgument, argument)) {
|
|
12698
|
+
return true;
|
|
12699
|
+
}
|
|
12700
|
+
return Option_exports.exists(
|
|
12701
|
+
maybeFirstArgument,
|
|
12702
|
+
(argument2) => isObjectExpression(innermostExpression(argument2))
|
|
12703
|
+
) && Option_exports.contains(Array_exports.get(call.arguments, 1), argument);
|
|
12704
|
+
};
|
|
12705
|
+
var isDeferredDirectEffectApiCallback = (argument, call, key) => {
|
|
12706
|
+
if (effectFunctionFactories.has(key)) {
|
|
12707
|
+
return isEffectFunctionBody(argument, call);
|
|
12708
|
+
}
|
|
12709
|
+
const maybeArgumentIndex = Array_exports.findFirstIndex(
|
|
12710
|
+
call.arguments,
|
|
12711
|
+
(candidate) => candidate === argument
|
|
12712
|
+
);
|
|
12713
|
+
const maybePositions = Option_exports.fromNullishOr(
|
|
12714
|
+
deferredCallbackByApi.get(key)?.direct?.get(call.arguments.length)
|
|
12715
|
+
);
|
|
12716
|
+
return Option_exports.exists(
|
|
12717
|
+
maybeArgumentIndex,
|
|
12718
|
+
(argumentIndex) => Option_exports.exists(maybePositions, (positions) => positions.has(argumentIndex))
|
|
12719
|
+
);
|
|
12720
|
+
};
|
|
12721
|
+
var isDeferredObjectEffectApiCallback = (property, argument, call, key) => {
|
|
12722
|
+
const maybeArgumentIndex = Array_exports.findFirstIndex(
|
|
12723
|
+
call.arguments,
|
|
12724
|
+
(candidate) => candidate === argument
|
|
12725
|
+
);
|
|
12726
|
+
const maybePropertyName = staticPropertyName(property);
|
|
12727
|
+
const propertiesByArgument = deferredCallbackByApi.get(key)?.properties?.get(call.arguments.length);
|
|
12728
|
+
return Option_exports.exists(maybeArgumentIndex, (argumentIndex) => {
|
|
12729
|
+
const propertyNames = propertiesByArgument?.get(argumentIndex);
|
|
12730
|
+
return propertyNames === true || propertyNames !== void 0 && Option_exports.exists(
|
|
12731
|
+
maybePropertyName,
|
|
12732
|
+
(propertyName) => propertyNames.has(propertyName)
|
|
12733
|
+
);
|
|
12734
|
+
});
|
|
12735
|
+
};
|
|
12736
|
+
var isEffectOrStreamCallback = (references, fn3) => {
|
|
12737
|
+
const maybeDirectCall = enclosingCallArgument(fn3);
|
|
12738
|
+
if (Option_exports.isSome(maybeDirectCall)) {
|
|
12739
|
+
return Option_exports.exists(
|
|
12740
|
+
apiCallKey(references, maybeDirectCall.value.call),
|
|
12741
|
+
(key) => isDeferredDirectEffectApiCallback(
|
|
12742
|
+
maybeDirectCall.value.argument,
|
|
12743
|
+
maybeDirectCall.value.call,
|
|
12744
|
+
key
|
|
12745
|
+
)
|
|
12746
|
+
);
|
|
12747
|
+
}
|
|
12748
|
+
const maybeProperty = enclosingPropertyValue(fn3);
|
|
12749
|
+
if (Option_exports.isNone(maybeProperty)) {
|
|
12750
|
+
return false;
|
|
12751
|
+
}
|
|
12752
|
+
const property = maybeProperty.value;
|
|
12753
|
+
const object = property.parent;
|
|
12754
|
+
if (object.type !== "ObjectExpression") {
|
|
12755
|
+
return false;
|
|
12756
|
+
}
|
|
12757
|
+
const maybeCall = enclosingCallArgument(object);
|
|
12758
|
+
if (Option_exports.isNone(maybeCall)) {
|
|
12759
|
+
return false;
|
|
12760
|
+
}
|
|
12761
|
+
const { argument, call } = maybeCall.value;
|
|
12762
|
+
return Option_exports.exists(
|
|
12763
|
+
apiCallKey(references, call),
|
|
12764
|
+
(key) => isDeferredObjectEffectApiCallback(property, argument, call, key)
|
|
12765
|
+
);
|
|
12766
|
+
};
|
|
12767
|
+
var isInlineConfigFunction = (references, fn3, propertyNames, factoryKeys) => {
|
|
12768
|
+
const maybeProperty = enclosingPropertyValue(fn3);
|
|
12769
|
+
if (Option_exports.isNone(maybeProperty)) {
|
|
12770
|
+
return false;
|
|
12771
|
+
}
|
|
12772
|
+
const property = maybeProperty.value;
|
|
12773
|
+
if (property.parent.type !== "ObjectExpression" || !Option_exports.exists(
|
|
12774
|
+
staticPropertyName(property),
|
|
12775
|
+
(name) => propertyNames.has(name)
|
|
12776
|
+
)) {
|
|
12777
|
+
return false;
|
|
12778
|
+
}
|
|
12779
|
+
const maybeCall = enclosingCallArgument(property.parent);
|
|
12780
|
+
if (Option_exports.isNone(maybeCall)) {
|
|
12781
|
+
return false;
|
|
12782
|
+
}
|
|
12783
|
+
return Option_exports.exists(
|
|
12784
|
+
apiCallKey(references, maybeCall.value.call),
|
|
12785
|
+
(key) => factoryKeys.has(key)
|
|
12786
|
+
);
|
|
12787
|
+
};
|
|
12788
|
+
var hasFactoryAncestor = (references, node, factoryKey) => {
|
|
12789
|
+
const parent = node.parent;
|
|
12790
|
+
if (parent === null) {
|
|
12791
|
+
return false;
|
|
12792
|
+
}
|
|
12793
|
+
if (parent.type === "CallExpression" && Option_exports.contains(apiCallKey(references, parent), factoryKey)) {
|
|
12794
|
+
return true;
|
|
12795
|
+
}
|
|
12796
|
+
return hasFactoryAncestor(references, parent, factoryKey);
|
|
12797
|
+
};
|
|
12798
|
+
var isNestedLifecycleFunction = (references, fn3) => {
|
|
12799
|
+
const maybeProperty = enclosingPropertyValue(fn3);
|
|
12800
|
+
if (Option_exports.isNone(maybeProperty)) {
|
|
12801
|
+
return false;
|
|
12802
|
+
}
|
|
12803
|
+
const property = maybeProperty.value;
|
|
12804
|
+
if (property.parent.type !== "ObjectExpression") {
|
|
12805
|
+
return false;
|
|
12806
|
+
}
|
|
12807
|
+
if (Option_exports.isNone(enclosingCallArgument(property.parent))) {
|
|
12808
|
+
return false;
|
|
12809
|
+
}
|
|
12810
|
+
const maybePropertyName = staticPropertyName(property);
|
|
12811
|
+
const isSubscriptionEffect = Option_exports.contains(
|
|
12812
|
+
maybePropertyName,
|
|
12813
|
+
"dependenciesToStream"
|
|
12814
|
+
);
|
|
12815
|
+
if (isSubscriptionEffect && hasFactoryAncestor(references, fn3, "Subscription.make")) {
|
|
12816
|
+
return true;
|
|
12817
|
+
}
|
|
12818
|
+
const isManagedResourceEffect = Option_exports.exists(
|
|
12819
|
+
maybePropertyName,
|
|
12820
|
+
(name) => name === "acquire" || name === "release"
|
|
12821
|
+
);
|
|
12822
|
+
return isManagedResourceEffect && hasFactoryAncestor(references, fn3, "ManagedResource.make");
|
|
12823
|
+
};
|
|
12824
|
+
var commandAndMountEffectProperties = /* @__PURE__ */ new Set(["execute"]);
|
|
12825
|
+
var commandAndMountFactories = /* @__PURE__ */ new Set([
|
|
12826
|
+
"Command.define",
|
|
12827
|
+
"Mount.define",
|
|
12828
|
+
"Mount.defineStream"
|
|
12829
|
+
]);
|
|
12830
|
+
var isDeferredFunction = (references, fn3) => isEffectOrStreamCallback(references, fn3) || isInlineConfigFunction(
|
|
12831
|
+
references,
|
|
12832
|
+
fn3,
|
|
12833
|
+
commandAndMountEffectProperties,
|
|
12834
|
+
commandAndMountFactories
|
|
12835
|
+
) || isNestedLifecycleFunction(references, fn3);
|
|
12836
|
+
var isInsideEffectBoundary = (references, node) => {
|
|
12837
|
+
const parent = node.parent;
|
|
12838
|
+
if (parent === null) {
|
|
12839
|
+
return false;
|
|
12840
|
+
}
|
|
12841
|
+
if (isFunction2(parent) && isDeferredFunction(references, parent)) {
|
|
12842
|
+
return true;
|
|
12843
|
+
}
|
|
12844
|
+
return isInsideEffectBoundary(references, parent);
|
|
12845
|
+
};
|
|
12846
|
+
var callOperation = (references, node) => Option_exports.flatMap(
|
|
12847
|
+
globalPathKey(references, node.callee),
|
|
12848
|
+
(key) => Option_exports.fromNullishOr(impureCallByPath.get(key))
|
|
12849
|
+
);
|
|
12850
|
+
var newOperation = (references, node) => Array_exports.isArrayEmpty(node.arguments) && Option_exports.contains(globalPathKey(references, node.callee), "Date") ? Option_exports.some(newDateOperation) : Option_exports.none();
|
|
12851
|
+
var diagnosticMessage2 = ({ display, guidance }) => `${display} is outside a recognized callback that Effect or Foldkit defers until execution. ${guidance} Obtain the value in a deferred Effect or lifecycle execution callback and return it in a Message. Assigning it to a local variable or passing it as a Command argument does not defer the call.`;
|
|
12852
|
+
var noImpureCallAtDecisionTime = Rule_exports.define({
|
|
12853
|
+
name: "no-impure-call-at-decision-time",
|
|
12854
|
+
meta: Rule_exports.meta({
|
|
12855
|
+
type: "problem",
|
|
12856
|
+
description: "Keep direct time and randomness calls inside deferred Effect and lifecycle execution callbacks."
|
|
12857
|
+
}),
|
|
12858
|
+
create: function* () {
|
|
12859
|
+
const ctx = yield* RuleContext;
|
|
12860
|
+
const scopes = ctx.sourceCode.scopeManager?.scopes;
|
|
12861
|
+
const references = scopes === void 0 ? void 0 : indexReferences(scopes);
|
|
12862
|
+
const report = (node, maybeOperation) => Option_exports.match(maybeOperation, {
|
|
12863
|
+
onNone: () => Effect_exports.void,
|
|
12864
|
+
onSome: (operation) => isInsideEffectBoundary(references, node) ? Effect_exports.void : ctx.report(
|
|
12865
|
+
Diagnostic_exports.make({
|
|
12866
|
+
node,
|
|
12867
|
+
message: diagnosticMessage2(operation)
|
|
12868
|
+
})
|
|
12869
|
+
)
|
|
12870
|
+
});
|
|
12871
|
+
return {
|
|
12872
|
+
CallExpression: (node) => node.type === "CallExpression" ? report(node, callOperation(references, node)) : Effect_exports.void,
|
|
12873
|
+
NewExpression: (node) => node.type === "NewExpression" ? report(node, newOperation(references, node)) : Effect_exports.void
|
|
12874
|
+
};
|
|
12875
|
+
}
|
|
12876
|
+
});
|
|
12877
|
+
|
|
12219
12878
|
// src/rules/no-module-level-mutable-state.ts
|
|
12220
12879
|
var isMutableDeclaration = (node) => (node.kind === "let" || node.kind === "var") && node.declare !== true;
|
|
12221
12880
|
var topLevelMutableDeclarations = (program) => program.body.flatMap((statement) => {
|
|
@@ -12285,24 +12944,6 @@ var isInsideTypeQuery = (node) => {
|
|
|
12285
12944
|
}
|
|
12286
12945
|
return false;
|
|
12287
12946
|
};
|
|
12288
|
-
var staticMemberName = (node) => {
|
|
12289
|
-
if (!node.computed && node.property.type === "Identifier") {
|
|
12290
|
-
return node.property.name;
|
|
12291
|
-
}
|
|
12292
|
-
if (node.computed && node.property.type === "Literal" && typeof node.property.value === "string") {
|
|
12293
|
-
return node.property.value;
|
|
12294
|
-
}
|
|
12295
|
-
return void 0;
|
|
12296
|
-
};
|
|
12297
|
-
var staticPropertyName4 = (property) => {
|
|
12298
|
-
if (property.key.type === "Identifier") {
|
|
12299
|
-
return property.key.name;
|
|
12300
|
-
}
|
|
12301
|
-
if (property.key.type === "Literal" && typeof property.key.value === "string") {
|
|
12302
|
-
return property.key.value;
|
|
12303
|
-
}
|
|
12304
|
-
return void 0;
|
|
12305
|
-
};
|
|
12306
12947
|
var destructuringSource = (node) => {
|
|
12307
12948
|
const parent = node.parent;
|
|
12308
12949
|
if (parent.type === "VariableDeclarator" && parent.id === node) {
|
|
@@ -12321,19 +12962,6 @@ var restrictedGlobalDiagnostic = (node, name) => Diagnostic_exports.make({
|
|
|
12321
12962
|
node,
|
|
12322
12963
|
message: `Global \`${name}\` is not portable across Foldkit server targets. Use a server API available everywhere you deploy or pass the value into the entry.`
|
|
12323
12964
|
});
|
|
12324
|
-
var indexReferences2 = (scopes) => {
|
|
12325
|
-
const references = /* @__PURE__ */ new WeakMap();
|
|
12326
|
-
for (const scope3 of scopes) {
|
|
12327
|
-
for (const reference of scope3.references) {
|
|
12328
|
-
references.set(reference.identifier, reference);
|
|
12329
|
-
}
|
|
12330
|
-
}
|
|
12331
|
-
return references;
|
|
12332
|
-
};
|
|
12333
|
-
var isUnshadowedGlobalReference = (references, node) => {
|
|
12334
|
-
const reference = references.get(node);
|
|
12335
|
-
return reference !== void 0 && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs));
|
|
12336
|
-
};
|
|
12337
12965
|
var noNonportableServerGlobals = Rule_exports.define({
|
|
12338
12966
|
name: "no-nonportable-server-globals",
|
|
12339
12967
|
meta: Rule_exports.meta({
|
|
@@ -12342,23 +12970,23 @@ var noNonportableServerGlobals = Rule_exports.define({
|
|
|
12342
12970
|
}),
|
|
12343
12971
|
create: function* () {
|
|
12344
12972
|
const ctx = yield* RuleContext;
|
|
12345
|
-
const references =
|
|
12973
|
+
const references = indexReferences(ctx.sourceCode.scopeManager.scopes);
|
|
12346
12974
|
return {
|
|
12347
12975
|
Identifier: (node) => {
|
|
12348
12976
|
if (node.type !== "Identifier" || !restrictedGlobalNames.has(node.name) || isInsideTypeQuery(node)) {
|
|
12349
12977
|
return Effect_exports.void;
|
|
12350
12978
|
}
|
|
12351
|
-
return
|
|
12979
|
+
return isUnshadowedReference(references, node) ? ctx.report(restrictedGlobalDiagnostic(node, node.name)) : Effect_exports.void;
|
|
12352
12980
|
},
|
|
12353
12981
|
MemberExpression: (node) => {
|
|
12354
12982
|
if (node.type !== "MemberExpression" || node.object.type !== "Identifier" || node.object.name !== "globalThis") {
|
|
12355
12983
|
return Effect_exports.void;
|
|
12356
12984
|
}
|
|
12357
|
-
const
|
|
12358
|
-
if (
|
|
12985
|
+
const maybeMemberName = staticMemberName(node);
|
|
12986
|
+
if (Option_exports.isNone(maybeMemberName) || !restrictedGlobalNames.has(maybeMemberName.value)) {
|
|
12359
12987
|
return Effect_exports.void;
|
|
12360
12988
|
}
|
|
12361
|
-
return
|
|
12989
|
+
return isUnshadowedReference(references, node.object) ? ctx.report(restrictedGlobalDiagnostic(node, maybeMemberName.value)) : Effect_exports.void;
|
|
12362
12990
|
},
|
|
12363
12991
|
ObjectPattern: (node) => {
|
|
12364
12992
|
if (node.type !== "ObjectPattern") {
|
|
@@ -12372,10 +13000,10 @@ var noNonportableServerGlobals = Rule_exports.define({
|
|
|
12372
13000
|
if (property.type !== "Property") {
|
|
12373
13001
|
return [];
|
|
12374
13002
|
}
|
|
12375
|
-
const
|
|
12376
|
-
return
|
|
13003
|
+
const maybeName = staticPropertyName(property);
|
|
13004
|
+
return Option_exports.isSome(maybeName) && restrictedGlobalNames.has(maybeName.value) ? [{ name: maybeName.value, property }] : [];
|
|
12377
13005
|
});
|
|
12378
|
-
return
|
|
13006
|
+
return isUnshadowedReference(references, source) ? Effect_exports.forEach(
|
|
12379
13007
|
restrictedProperties,
|
|
12380
13008
|
({ name, property }) => ctx.report(restrictedGlobalDiagnostic(property, name)),
|
|
12381
13009
|
{ discard: true }
|
|
@@ -12732,6 +13360,139 @@ var preferCallableMessageConstructor = Rule_exports.define({
|
|
|
12732
13360
|
}
|
|
12733
13361
|
});
|
|
12734
13362
|
|
|
13363
|
+
// src/rules/prefer-effect-module-names.ts
|
|
13364
|
+
var EFFECT_MODULE_NAME = /^[A-Z]/;
|
|
13365
|
+
var isSemanticConflictAlias = (name, localName) => localName === `Effect${name}`;
|
|
13366
|
+
var importedName2 = (specifier) => {
|
|
13367
|
+
if (isIdentifier(specifier.imported)) {
|
|
13368
|
+
return Option_exports.some(specifier.imported.name);
|
|
13369
|
+
}
|
|
13370
|
+
if (isStringLiteral(specifier.imported)) {
|
|
13371
|
+
return Option_exports.some(specifier.imported.value);
|
|
13372
|
+
}
|
|
13373
|
+
return Option_exports.none();
|
|
13374
|
+
};
|
|
13375
|
+
var importVariable = (ctx, specifier) => {
|
|
13376
|
+
const scopeManager = ctx.sourceCode.scopeManager;
|
|
13377
|
+
if (scopeManager === void 0) {
|
|
13378
|
+
return void 0;
|
|
13379
|
+
}
|
|
13380
|
+
return Array_exports.findFirst(
|
|
13381
|
+
scopeManager.getDeclaredVariables(specifier),
|
|
13382
|
+
(variable) => variable.name === specifier.local.name
|
|
13383
|
+
).pipe(Option_exports.getOrUndefined);
|
|
13384
|
+
};
|
|
13385
|
+
var hasUnshadowedReference = (ctx, name) => Array_exports.some(
|
|
13386
|
+
ctx.sourceCode.scopeManager?.scopes ?? [],
|
|
13387
|
+
(scope3) => Array_exports.some(
|
|
13388
|
+
scope3.references,
|
|
13389
|
+
(reference) => reference.identifier.name === name && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs))
|
|
13390
|
+
)
|
|
13391
|
+
);
|
|
13392
|
+
var preservesObservableName = (node) => {
|
|
13393
|
+
const parent = node.parent;
|
|
13394
|
+
if (parent === null) {
|
|
13395
|
+
return true;
|
|
13396
|
+
}
|
|
13397
|
+
if (parent.type === "Property" && parent.shorthand) {
|
|
13398
|
+
return false;
|
|
13399
|
+
}
|
|
13400
|
+
return parent.type !== "ExportSpecifier";
|
|
13401
|
+
};
|
|
13402
|
+
var hasInterveningBinding = (scope3, importScope, name) => {
|
|
13403
|
+
if (scope3 === importScope) {
|
|
13404
|
+
return false;
|
|
13405
|
+
}
|
|
13406
|
+
if (scope3.set.get(name) !== void 0 || scope3.upper === null) {
|
|
13407
|
+
return true;
|
|
13408
|
+
}
|
|
13409
|
+
return hasInterveningBinding(scope3.upper, importScope, name);
|
|
13410
|
+
};
|
|
13411
|
+
var referenceCanBeRenamed = (reference, importScope, name) => preservesObservableName(reference.identifier) && !hasInterveningBinding(reference.from, importScope, name);
|
|
13412
|
+
var aliasedEffectModule = (specifier) => {
|
|
13413
|
+
if (specifier.type !== "ImportSpecifier" || specifier.importKind === "type") {
|
|
13414
|
+
return Option_exports.none();
|
|
13415
|
+
}
|
|
13416
|
+
return Option_exports.flatMap(
|
|
13417
|
+
importedName2(specifier),
|
|
13418
|
+
(name) => EFFECT_MODULE_NAME.test(name) && specifier.local.name !== name && !isSemanticConflictAlias(name, specifier.local.name) ? Option_exports.some({ specifier, name }) : Option_exports.none()
|
|
13419
|
+
);
|
|
13420
|
+
};
|
|
13421
|
+
var importsEffectModuleAsAlias = (variable, name) => Array_exports.some(variable.defs, (definition) => {
|
|
13422
|
+
if (definition.type !== "ImportBinding" || definition.node.type !== "ImportSpecifier") {
|
|
13423
|
+
return false;
|
|
13424
|
+
}
|
|
13425
|
+
const declaration = definition.node.parent;
|
|
13426
|
+
if (declaration.type !== "ImportDeclaration" || declaration.source.value !== "effect" || declaration.importKind === "type") {
|
|
13427
|
+
return false;
|
|
13428
|
+
}
|
|
13429
|
+
return Option_exports.match(aliasedEffectModule(definition.node), {
|
|
13430
|
+
onNone: () => false,
|
|
13431
|
+
onSome: (alias) => alias.name === name
|
|
13432
|
+
});
|
|
13433
|
+
});
|
|
13434
|
+
var hasCompetingRenameTarget = (variable, name) => Array_exports.some(
|
|
13435
|
+
variable.scope.variables,
|
|
13436
|
+
(candidate) => candidate !== variable && importsEffectModuleAsAlias(candidate, name)
|
|
13437
|
+
);
|
|
13438
|
+
var canRenameBinding = (ctx, variable, name) => variable.scope.set.get(name) === void 0 && !hasUnshadowedReference(ctx, name) && !hasCompetingRenameTarget(variable, name) && Array_exports.every(
|
|
13439
|
+
variable.references,
|
|
13440
|
+
(reference) => referenceCanBeRenamed(reference, variable.scope, name)
|
|
13441
|
+
);
|
|
13442
|
+
var fixesForAlias = (ctx, { specifier, name }) => {
|
|
13443
|
+
const variable = importVariable(ctx, specifier);
|
|
13444
|
+
if (variable === void 0 || Array_exports.isArrayNonEmpty(ctx.sourceCode.getCommentsInside(specifier)) || !canRenameBinding(ctx, variable, name)) {
|
|
13445
|
+
return [];
|
|
13446
|
+
}
|
|
13447
|
+
return [
|
|
13448
|
+
Diagnostic_exports.replaceText(specifier, name),
|
|
13449
|
+
...Array_exports.map(
|
|
13450
|
+
variable.references,
|
|
13451
|
+
(reference) => Diagnostic_exports.replaceText(reference.identifier, name)
|
|
13452
|
+
)
|
|
13453
|
+
];
|
|
13454
|
+
};
|
|
13455
|
+
var preferEffectModuleNames = Rule_exports.define({
|
|
13456
|
+
name: "prefer-effect-module-names",
|
|
13457
|
+
meta: Rule_exports.meta({
|
|
13458
|
+
type: "suggestion",
|
|
13459
|
+
description: "Use Effect module names without import aliases.",
|
|
13460
|
+
fixable: "code"
|
|
13461
|
+
}),
|
|
13462
|
+
create: function* () {
|
|
13463
|
+
const ctx = yield* RuleContext;
|
|
13464
|
+
return {
|
|
13465
|
+
ImportDeclaration: (node) => {
|
|
13466
|
+
if (node.type !== "ImportDeclaration" || node.source.value !== "effect" || node.importKind === "type") {
|
|
13467
|
+
return Effect_exports.void;
|
|
13468
|
+
}
|
|
13469
|
+
const aliases = Array_exports.flatMap(
|
|
13470
|
+
node.specifiers,
|
|
13471
|
+
(specifier) => Option_exports.match(aliasedEffectModule(specifier), {
|
|
13472
|
+
onNone: () => [],
|
|
13473
|
+
onSome: (alias) => [alias]
|
|
13474
|
+
})
|
|
13475
|
+
);
|
|
13476
|
+
if (Array_exports.isReadonlyArrayEmpty(aliases)) {
|
|
13477
|
+
return Effect_exports.void;
|
|
13478
|
+
}
|
|
13479
|
+
const replacements = Array_exports.map(
|
|
13480
|
+
aliases,
|
|
13481
|
+
({ specifier, name }) => `\`${name}\` instead of \`${specifier.local.name}\``
|
|
13482
|
+
);
|
|
13483
|
+
const diagnostic = Diagnostic_exports.make({
|
|
13484
|
+
node,
|
|
13485
|
+
message: `Use Effect module names without aliases: ${replacements.join(", ")}. Qualify same-named globals through \`globalThis\`.`
|
|
13486
|
+
});
|
|
13487
|
+
const fixes = Array_exports.flatMap(aliases, (alias) => fixesForAlias(ctx, alias));
|
|
13488
|
+
return ctx.report(
|
|
13489
|
+
Array_exports.isReadonlyArrayEmpty(fixes) ? diagnostic : Diagnostic_exports.withFix(diagnostic, Diagnostic_exports.composeFixes(...fixes))
|
|
13490
|
+
);
|
|
13491
|
+
}
|
|
13492
|
+
};
|
|
13493
|
+
}
|
|
13494
|
+
});
|
|
13495
|
+
|
|
12735
13496
|
// src/rules/require-rel-for-external-link.ts
|
|
12736
13497
|
var protectiveRelSubstrings = ["noopener", "noreferrer"];
|
|
12737
13498
|
var isTargetBlankElement = (element) => {
|
|
@@ -13117,12 +13878,14 @@ var basePlugin = Plugin_exports.define({
|
|
|
13117
13878
|
"no-empty-object-tagged-call": noEmptyObjectTaggedCall,
|
|
13118
13879
|
"no-hand-rolled-command-struct": noHandRolledCommandStruct,
|
|
13119
13880
|
"no-hardcoded-route-strings": noHardcodedRouteStrings,
|
|
13881
|
+
"no-impure-call-at-decision-time": noImpureCallAtDecisionTime,
|
|
13120
13882
|
"no-module-level-mutable-state": noModuleLevelMutableState,
|
|
13121
13883
|
"no-nonportable-server-globals": noNonportableServerGlobals,
|
|
13122
13884
|
"no-noop-message": noNoopMessage,
|
|
13123
13885
|
"no-raw-dom-event-attributes": noRawDomEventAttributes,
|
|
13124
13886
|
"no-spread-in-evo": noSpreadInEvo,
|
|
13125
13887
|
"prefer-callable-message-constructor": preferCallableMessageConstructor,
|
|
13888
|
+
"prefer-effect-module-names": preferEffectModuleNames,
|
|
13126
13889
|
"require-rel-for-external-link": requireRelForExternalLink,
|
|
13127
13890
|
"selection-submodel-factory-at-module-scope": selectionSubmodelFactoryAtModuleScope,
|
|
13128
13891
|
"wrap-child-output-in-got-message": wrapChildOutputInGotMessage
|
|
@@ -13139,22 +13902,38 @@ var serverFilePatterns = [
|
|
|
13139
13902
|
"**/entry.server.tsx",
|
|
13140
13903
|
"**/server/**/*.ts",
|
|
13141
13904
|
"**/server/**/*.tsx",
|
|
13142
|
-
"**/prerender.ts"
|
|
13905
|
+
"**/prerender.ts",
|
|
13906
|
+
"**/prerender.tsx"
|
|
13907
|
+
];
|
|
13908
|
+
var entryFilePatterns = [
|
|
13909
|
+
"**/entry.ts",
|
|
13910
|
+
"**/entry.tsx",
|
|
13911
|
+
"**/entry.client.ts",
|
|
13912
|
+
"**/entry.client.tsx",
|
|
13913
|
+
"**/entry.server.ts",
|
|
13914
|
+
"**/entry.server.tsx"
|
|
13143
13915
|
];
|
|
13916
|
+
var decisionTimeRuleId = "foldkit/no-impure-call-at-decision-time";
|
|
13144
13917
|
var serverOverride = {
|
|
13145
13918
|
files: serverFilePatterns,
|
|
13146
13919
|
excludeFiles: testFilePatterns,
|
|
13147
13920
|
rules: {
|
|
13148
|
-
"foldkit/no-nonportable-server-globals": "error"
|
|
13921
|
+
"foldkit/no-nonportable-server-globals": "error",
|
|
13922
|
+
[decisionTimeRuleId]: "off"
|
|
13923
|
+
}
|
|
13924
|
+
};
|
|
13925
|
+
var entryOverride = {
|
|
13926
|
+
files: entryFilePatterns,
|
|
13927
|
+
excludeFiles: testFilePatterns,
|
|
13928
|
+
rules: {
|
|
13929
|
+
[decisionTimeRuleId]: "off"
|
|
13149
13930
|
}
|
|
13150
13931
|
};
|
|
13932
|
+
var rulesApplicableToTests = /* @__PURE__ */ new Set(["foldkit/prefer-effect-module-names"]);
|
|
13151
13933
|
var testOverride = (config) => ({
|
|
13152
13934
|
files: testFilePatterns,
|
|
13153
13935
|
rules: Object.fromEntries(
|
|
13154
|
-
Object.keys(config.rules).map((id) => [
|
|
13155
|
-
id,
|
|
13156
|
-
"off"
|
|
13157
|
-
])
|
|
13936
|
+
Object.keys(config.rules).filter((id) => !rulesApplicableToTests.has(id)).map((id) => [id, "off"])
|
|
13158
13937
|
)
|
|
13159
13938
|
});
|
|
13160
13939
|
var withOverrides = (config) => ({
|
|
@@ -13163,7 +13942,7 @@ var withOverrides = (config) => ({
|
|
|
13163
13942
|
...config.rules,
|
|
13164
13943
|
"foldkit/no-nonportable-server-globals": "off"
|
|
13165
13944
|
},
|
|
13166
|
-
overrides: [serverOverride, testOverride(config)]
|
|
13945
|
+
overrides: [serverOverride, entryOverride, testOverride(config)]
|
|
13167
13946
|
});
|
|
13168
13947
|
var index_default = {
|
|
13169
13948
|
...basePlugin,
|