@foldkit/oxlint-plugin 0.11.0-canary.00c836c7927f → 0.11.0-canary.21d56b2de3cd
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 +25 -2
- package/dist/guards.d.ts +11 -7
- package/dist/guards.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +704 -101
- package/dist/message.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/package.json +1 -1
- package/recommended.json +25 -2
package/all.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"foldkit/no-empty-object-tagged-call": "error",
|
|
25
25
|
"foldkit/no-hand-rolled-command-struct": "error",
|
|
26
26
|
"foldkit/no-hardcoded-route-strings": "error",
|
|
27
|
+
"foldkit/no-impure-call-at-decision-time": "error",
|
|
27
28
|
"foldkit/no-module-level-mutable-state": "error",
|
|
28
29
|
"foldkit/no-nonportable-server-globals": "off",
|
|
29
30
|
"foldkit/no-noop-message": "error",
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
"**/entry.server.tsx",
|
|
42
43
|
"**/server/**/*.ts",
|
|
43
44
|
"**/server/**/*.tsx",
|
|
44
|
-
"**/prerender.ts"
|
|
45
|
+
"**/prerender.ts",
|
|
46
|
+
"**/prerender.tsx"
|
|
45
47
|
],
|
|
46
48
|
"excludeFiles": [
|
|
47
49
|
"**/*.test.ts",
|
|
@@ -50,7 +52,27 @@
|
|
|
50
52
|
"**/*.spec.tsx"
|
|
51
53
|
],
|
|
52
54
|
"rules": {
|
|
53
|
-
"foldkit/no-nonportable-server-globals": "error"
|
|
55
|
+
"foldkit/no-nonportable-server-globals": "error",
|
|
56
|
+
"foldkit/no-impure-call-at-decision-time": "off"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"files": [
|
|
61
|
+
"**/entry.ts",
|
|
62
|
+
"**/entry.tsx",
|
|
63
|
+
"**/entry.client.ts",
|
|
64
|
+
"**/entry.client.tsx",
|
|
65
|
+
"**/entry.server.ts",
|
|
66
|
+
"**/entry.server.tsx"
|
|
67
|
+
],
|
|
68
|
+
"excludeFiles": [
|
|
69
|
+
"**/*.test.ts",
|
|
70
|
+
"**/*.test.tsx",
|
|
71
|
+
"**/*.spec.ts",
|
|
72
|
+
"**/*.spec.tsx"
|
|
73
|
+
],
|
|
74
|
+
"rules": {
|
|
75
|
+
"foldkit/no-impure-call-at-decision-time": "off"
|
|
54
76
|
}
|
|
55
77
|
},
|
|
56
78
|
{
|
|
@@ -79,6 +101,7 @@
|
|
|
79
101
|
"foldkit/no-empty-object-tagged-call": "off",
|
|
80
102
|
"foldkit/no-hand-rolled-command-struct": "off",
|
|
81
103
|
"foldkit/no-hardcoded-route-strings": "off",
|
|
104
|
+
"foldkit/no-impure-call-at-decision-time": "off",
|
|
82
105
|
"foldkit/no-module-level-mutable-state": "off",
|
|
83
106
|
"foldkit/no-nonportable-server-globals": "off",
|
|
84
107
|
"foldkit/no-noop-message": "off",
|
package/dist/guards.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { Option } from 'effect';
|
|
2
|
-
import { type ESTree } from 'effect-oxlint';
|
|
2
|
+
import { type ESTree, type OxlintScope, type Reference } from 'effect-oxlint';
|
|
3
3
|
export declare const isIdentifier: (node: unknown, name?: string) => node is Readonly<{
|
|
4
4
|
type: 'Identifier';
|
|
5
5
|
name: string;
|
|
6
6
|
}>;
|
|
7
|
+
export declare const isIdentifierReference: (node: unknown) => node is ESTree.IdentifierReference;
|
|
7
8
|
export declare const isStringLiteral: (node: unknown) => node is ESTree.StringLiteral;
|
|
8
9
|
export declare const isTemplateLiteral: (node: unknown) => node is ESTree.TemplateLiteral;
|
|
9
10
|
export declare const isCallExpression: (node: unknown) => node is ESTree.CallExpression;
|
|
10
|
-
export declare const isMemberExpression: (node: unknown) => node is
|
|
11
|
-
type: 'MemberExpression';
|
|
12
|
-
object: unknown;
|
|
13
|
-
property: unknown;
|
|
14
|
-
computed?: boolean;
|
|
15
|
-
}>;
|
|
11
|
+
export declare const isMemberExpression: (node: unknown) => node is ESTree.MemberExpression;
|
|
16
12
|
export declare const isObjectExpression: (node: unknown) => node is ESTree.ObjectExpression;
|
|
13
|
+
export declare const isObjectProperty: (node: unknown) => node is ESTree.ObjectProperty;
|
|
17
14
|
export declare const isArrayExpression: (node: unknown) => node is Readonly<{
|
|
18
15
|
type: 'ArrayExpression';
|
|
19
16
|
elements: ReadonlyArray<unknown>;
|
|
@@ -22,6 +19,13 @@ export declare const isSpreadElement: (node: unknown) => boolean;
|
|
|
22
19
|
export declare const helperCalleeName: (callee: unknown) => Option.Option<string>;
|
|
23
20
|
export declare const calleeMatchesHelperName: (callee: unknown, helperName: string) => boolean;
|
|
24
21
|
export declare const staticStringValue: (node: unknown) => Option.Option<string>;
|
|
22
|
+
export declare const staticMemberName: (node: ESTree.MemberExpression) => Option.Option<string>;
|
|
23
|
+
export declare const staticPropertyName: (property: Readonly<{
|
|
24
|
+
computed?: boolean;
|
|
25
|
+
key: ESTree.PropertyKey;
|
|
26
|
+
}>) => Option.Option<string>;
|
|
27
|
+
export declare const indexReferences: (scopes: ReadonlyArray<OxlintScope>) => WeakMap<ESTree.Node, Reference>;
|
|
28
|
+
export declare const isUnshadowedReference: (references: WeakMap<ESTree.Node, Reference> | undefined, node: ESTree.Node) => boolean;
|
|
25
29
|
export declare const isVariableDeclarator: (node: unknown) => node is ESTree.VariableDeclarator;
|
|
26
30
|
export declare const isVariableDeclaration: (node: unknown) => node is ESTree.VariableDeclaration;
|
|
27
31
|
export declare const isProgram: (node: unknown) => node is ESTree.Program;
|
package/dist/guards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAE7E,eAAO,MAAM,YAAY,SACjB,OAAO,SACN,MAAM,KACZ,IAAI,IAAI,QAAQ,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAOZ,CAAA;AAE5C,eAAO,MAAM,qBAAqB,SAC1B,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,mBAAyC,CAAA;AAE3D,eAAO,MAAM,eAAe,SAAU,OAAO,KAAG,IAAI,IAAI,MAAM,CAAC,aAM/B,CAAA;AAEhC,eAAO,MAAM,iBAAiB,SACtB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,eAIe,CAAA;AAEjC,eAAO,MAAM,gBAAgB,SACrB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,cAIc,CAAA;AAEhC,eAAO,MAAM,kBAAkB,SACvB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,gBAIgB,CAAA;AAElC,eAAO,MAAM,kBAAkB,SACvB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,gBAIgB,CAAA;AAElC,eAAO,MAAM,gBAAgB,SACrB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,cAIQ,CAAA;AAE1B,eAAO,MAAM,iBAAiB,SACtB,OAAO,KACZ,IAAI,IAAI,QAAQ,CAAC;IAClB,IAAI,EAAE,iBAAiB,CAAA;IACvB,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CACjC,CAIgC,CAAA;AAEjC,eAAO,MAAM,eAAe,SAAU,OAAO,KAAG,OAIjB,CAAA;AAE/B,eAAO,MAAM,gBAAgB,WAAY,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAYtE,CAAA;AAED,eAAO,MAAM,uBAAuB,WAC1B,OAAO,cACH,MAAM,KACjB,OACmE,CAAA;AAEtE,eAAO,MAAM,iBAAiB,SAAU,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAUrE,CAAA;AAED,eAAO,MAAM,gBAAgB,SACrB,MAAM,CAAC,gBAAgB,KAC5B,MAAM,CAAC,MAAM,CAAC,MAAM,CAKtB,CAAA;AAED,eAAO,MAAM,kBAAkB,aACnB,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,EAAE,MAAM,CAAC,WAAW,CAAA;CACxB,CAAC,KACD,MAAM,CAAC,MAAM,CAAC,MAAM,CAKtB,CAAA;AAED,eAAO,MAAM,eAAe,WAClB,aAAa,CAAC,WAAW,CAAC,KACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAShC,CAAA;AAED,eAAO,MAAM,qBAAqB,eACpB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,SAAS,QACjD,MAAM,CAAC,IAAI,KAChB,OAUF,CAAA;AAED,eAAO,MAAM,oBAAoB,SACzB,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,kBAIkB,CAAA;AAEpC,eAAO,MAAM,qBAAqB,SAC1B,OAAO,KACZ,IAAI,IAAI,MAAM,CAAC,mBAImB,CAAA;AAErC,eAAO,MAAM,SAAS,SAAU,OAAO,KAAG,IAAI,IAAI,MAAM,CAAC,OAIhC,CAAA;AAEzB,eAAO,MAAM,mBAAmB,SACxB,MAAM,CAAC,cAAc,KAC1B,MAAM,CAAC,aAAa,GAAG,SAGzB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare const _default: {
|
|
|
30
30
|
readonly 'no-empty-object-tagged-call': import("effect-oxlint").CreateRule;
|
|
31
31
|
readonly 'no-hand-rolled-command-struct': import("effect-oxlint").CreateRule;
|
|
32
32
|
readonly 'no-hardcoded-route-strings': import("effect-oxlint").CreateRule;
|
|
33
|
+
readonly 'no-impure-call-at-decision-time': import("effect-oxlint").CreateRule;
|
|
33
34
|
readonly 'no-module-level-mutable-state': import("effect-oxlint").CreateRule;
|
|
34
35
|
readonly 'no-nonportable-server-globals': import("effect-oxlint").CreateRule;
|
|
35
36
|
readonly 'no-noop-message': import("effect-oxlint").CreateRule;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAmEtC,KAAK,QAAQ,GAAG,QAAQ,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;CAC3C,CAAC,CAAA;AAEF,KAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,GAAG;IAC5C,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;CAC3B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyEG,WAAW;QACX,GAAG"}
|
package/dist/index.js
CHANGED
|
@@ -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
|
};
|
|
@@ -10387,11 +10387,13 @@ var isPunctuator = dual(2, (token, value) => token.type === "Punctuator" && toke
|
|
|
10387
10387
|
|
|
10388
10388
|
// src/guards.ts
|
|
10389
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);
|
|
10390
10391
|
var isStringLiteral = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Literal" && "value" in node && typeof node.value === "string";
|
|
10391
10392
|
var isTemplateLiteral = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "TemplateLiteral";
|
|
10392
10393
|
var isCallExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "CallExpression";
|
|
10393
10394
|
var isMemberExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "MemberExpression";
|
|
10394
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";
|
|
10395
10397
|
var isArrayExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "ArrayExpression";
|
|
10396
10398
|
var isSpreadElement = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "SpreadElement";
|
|
10397
10399
|
var helperCalleeName = (callee) => {
|
|
@@ -10416,6 +10418,34 @@ var staticStringValue = (node) => {
|
|
|
10416
10418
|
}
|
|
10417
10419
|
return Option_exports.none();
|
|
10418
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
|
+
};
|
|
10419
10449
|
var isVariableDeclarator = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclarator";
|
|
10420
10450
|
var isVariableDeclaration = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclaration";
|
|
10421
10451
|
var isProgram = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Program";
|
|
@@ -10544,18 +10574,6 @@ var commandDefinePascalConst = Rule_exports.define({
|
|
|
10544
10574
|
|
|
10545
10575
|
// src/message.ts
|
|
10546
10576
|
var foldkitMessageModule = "foldkit/message";
|
|
10547
|
-
var staticPropertyName = (property) => {
|
|
10548
|
-
if (property.type !== "Property") {
|
|
10549
|
-
return Option_exports.none();
|
|
10550
|
-
}
|
|
10551
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
10552
|
-
return Option_exports.some({ name: property.key.name, node: property.key });
|
|
10553
|
-
}
|
|
10554
|
-
if (isStringLiteral(property.key)) {
|
|
10555
|
-
return Option_exports.some({ name: property.key.value, node: property.key });
|
|
10556
|
-
}
|
|
10557
|
-
return Option_exports.none();
|
|
10558
|
-
};
|
|
10559
10577
|
var recordFoldkitMessageUnionBindings = (bindings, node) => {
|
|
10560
10578
|
if (node.type !== "Program") {
|
|
10561
10579
|
return;
|
|
@@ -10580,14 +10598,17 @@ var messageCases = (node, bindings) => {
|
|
|
10580
10598
|
return [];
|
|
10581
10599
|
}
|
|
10582
10600
|
return casesByTag.properties.flatMap((property) => {
|
|
10601
|
+
if (property.type !== "Property") {
|
|
10602
|
+
return [];
|
|
10603
|
+
}
|
|
10583
10604
|
const maybeName = staticPropertyName(property);
|
|
10584
|
-
if (
|
|
10605
|
+
if (Option_exports.isNone(maybeName) || !isObjectExpression(property.value)) {
|
|
10585
10606
|
return [];
|
|
10586
10607
|
}
|
|
10587
10608
|
return [
|
|
10588
10609
|
{
|
|
10589
|
-
name: maybeName.value
|
|
10590
|
-
nameNode:
|
|
10610
|
+
name: maybeName.value,
|
|
10611
|
+
nameNode: property.key,
|
|
10591
10612
|
fields: property.value
|
|
10592
10613
|
}
|
|
10593
10614
|
];
|
|
@@ -11828,14 +11849,7 @@ var noEmptyChildrenArray = Rule_exports.define({
|
|
|
11828
11849
|
|
|
11829
11850
|
// src/rules/no-empty-commands-array.ts
|
|
11830
11851
|
var COMMANDS_PROPERTY = "commands";
|
|
11831
|
-
var
|
|
11832
|
-
var staticPropertyName2 = (property) => {
|
|
11833
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
11834
|
-
return Option_exports.some(property.key.name);
|
|
11835
|
-
}
|
|
11836
|
-
return staticStringValue(property.key);
|
|
11837
|
-
};
|
|
11838
|
-
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);
|
|
11839
11853
|
var removalRange = (sourceText, object, property, index) => {
|
|
11840
11854
|
const maybePrevious = Array_exports.get(object.properties, index - 1);
|
|
11841
11855
|
if (Option_exports.isSome(maybePrevious)) {
|
|
@@ -11876,11 +11890,11 @@ var noEmptyCommandsArray = Rule_exports.define({
|
|
|
11876
11890
|
);
|
|
11877
11891
|
const hasDynamicComputedProperty = Array_exports.some(
|
|
11878
11892
|
node.properties,
|
|
11879
|
-
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(
|
|
11893
|
+
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(staticPropertyName(property))
|
|
11880
11894
|
);
|
|
11881
11895
|
const commandProperties = Array_exports.filter(
|
|
11882
11896
|
node.properties,
|
|
11883
|
-
(property) => isObjectProperty(property) && Option_exports.contains(
|
|
11897
|
+
(property) => isObjectProperty(property) && Option_exports.contains(staticPropertyName(property), COMMANDS_PROPERTY)
|
|
11884
11898
|
);
|
|
11885
11899
|
const hasComments = Array_exports.isReadonlyArrayNonEmpty(
|
|
11886
11900
|
ctx.sourceCode.getCommentsInside(node)
|
|
@@ -11996,35 +12010,14 @@ var noEmptyObjectTaggedCall = Rule_exports.define({
|
|
|
11996
12010
|
|
|
11997
12011
|
// src/rules/no-empty-to-parent-out-message.ts
|
|
11998
12012
|
var TO_PARENT_OUT_MESSAGE_PROPERTY = "toParentOutMessage";
|
|
11999
|
-
var isObjectProperty2 = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "Property";
|
|
12000
|
-
var staticPropertyName3 = (property) => {
|
|
12001
|
-
if (!property.computed && isIdentifier(property.key)) {
|
|
12002
|
-
return Option_exports.some(property.key.name);
|
|
12003
|
-
}
|
|
12004
|
-
return staticStringValue(property.key);
|
|
12005
|
-
};
|
|
12006
12013
|
var isArrowFunctionExpression3 = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "ArrowFunctionExpression";
|
|
12007
12014
|
var isFunctionExpression = (node) => typeof node === "object" && node !== null && "type" in node && node.type === "FunctionExpression";
|
|
12008
12015
|
var isMapperFunction = (node) => isArrowFunctionExpression3(node) && !node.async || isFunctionExpression(node) && !node.async && !node.generator;
|
|
12009
|
-
var isIdentifierReference = (node) => isIdentifier(node);
|
|
12010
|
-
var indexReferences = (scopes) => {
|
|
12011
|
-
const references = /* @__PURE__ */ new WeakMap();
|
|
12012
|
-
for (const scope3 of scopes) {
|
|
12013
|
-
for (const reference of scope3.references) {
|
|
12014
|
-
references.set(reference.identifier, reference);
|
|
12015
|
-
}
|
|
12016
|
-
}
|
|
12017
|
-
return references;
|
|
12018
|
-
};
|
|
12019
12016
|
var isUnshadowedUndefined = (references, node) => {
|
|
12020
12017
|
if (!isIdentifierReference(node) || node.name !== "undefined") {
|
|
12021
12018
|
return false;
|
|
12022
12019
|
}
|
|
12023
|
-
|
|
12024
|
-
return true;
|
|
12025
|
-
}
|
|
12026
|
-
const reference = references.get(node);
|
|
12027
|
-
return reference !== void 0 && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs));
|
|
12020
|
+
return isUnshadowedReference(references, node);
|
|
12028
12021
|
};
|
|
12029
12022
|
var directlyReturnsUndefined = (references, mapper) => {
|
|
12030
12023
|
if (mapper.body === null) {
|
|
@@ -12037,7 +12030,7 @@ var directlyReturnsUndefined = (references, mapper) => {
|
|
|
12037
12030
|
return firstStatement?.type === "ReturnStatement" && secondStatement === void 0 && isUnshadowedUndefined(references, firstStatement.argument);
|
|
12038
12031
|
};
|
|
12039
12032
|
var isEmptyMapperProperty = (references, property) => property.kind === "init" && Option_exports.contains(
|
|
12040
|
-
|
|
12033
|
+
staticPropertyName(property),
|
|
12041
12034
|
TO_PARENT_OUT_MESSAGE_PROPERTY
|
|
12042
12035
|
) && isMapperFunction(property.value) && directlyReturnsUndefined(references, property.value);
|
|
12043
12036
|
var removalRange2 = (sourceText, object, property, index) => {
|
|
@@ -12082,12 +12075,12 @@ var noEmptyToParentOutMessage = Rule_exports.define({
|
|
|
12082
12075
|
);
|
|
12083
12076
|
const hasDynamicComputedProperty = Array_exports.some(
|
|
12084
12077
|
node.properties,
|
|
12085
|
-
(property) =>
|
|
12078
|
+
(property) => isObjectProperty(property) && property.computed && Option_exports.isNone(staticPropertyName(property))
|
|
12086
12079
|
);
|
|
12087
12080
|
const mapperProperties = Array_exports.filter(
|
|
12088
12081
|
node.properties,
|
|
12089
|
-
(property) =>
|
|
12090
|
-
|
|
12082
|
+
(property) => isObjectProperty(property) && Option_exports.contains(
|
|
12083
|
+
staticPropertyName(property),
|
|
12091
12084
|
TO_PARENT_OUT_MESSAGE_PROPERTY
|
|
12092
12085
|
)
|
|
12093
12086
|
);
|
|
@@ -12097,7 +12090,7 @@ var noEmptyToParentOutMessage = Rule_exports.define({
|
|
|
12097
12090
|
return Effect_exports.forEach(
|
|
12098
12091
|
node.properties.entries(),
|
|
12099
12092
|
([index, property]) => {
|
|
12100
|
-
if (!
|
|
12093
|
+
if (!isObjectProperty(property) || !isEmptyMapperProperty(references, property)) {
|
|
12101
12094
|
return Effect_exports.void;
|
|
12102
12095
|
}
|
|
12103
12096
|
const diagnostic = Diagnostic_exports.make({
|
|
@@ -12260,6 +12253,628 @@ var noHardcodedRouteStrings = Rule_exports.define({
|
|
|
12260
12253
|
}
|
|
12261
12254
|
});
|
|
12262
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
|
+
|
|
12263
12878
|
// src/rules/no-module-level-mutable-state.ts
|
|
12264
12879
|
var isMutableDeclaration = (node) => (node.kind === "let" || node.kind === "var") && node.declare !== true;
|
|
12265
12880
|
var topLevelMutableDeclarations = (program) => program.body.flatMap((statement) => {
|
|
@@ -12329,24 +12944,6 @@ var isInsideTypeQuery = (node) => {
|
|
|
12329
12944
|
}
|
|
12330
12945
|
return false;
|
|
12331
12946
|
};
|
|
12332
|
-
var staticMemberName = (node) => {
|
|
12333
|
-
if (!node.computed && node.property.type === "Identifier") {
|
|
12334
|
-
return node.property.name;
|
|
12335
|
-
}
|
|
12336
|
-
if (node.computed && node.property.type === "Literal" && typeof node.property.value === "string") {
|
|
12337
|
-
return node.property.value;
|
|
12338
|
-
}
|
|
12339
|
-
return void 0;
|
|
12340
|
-
};
|
|
12341
|
-
var staticPropertyName4 = (property) => {
|
|
12342
|
-
if (property.key.type === "Identifier") {
|
|
12343
|
-
return property.key.name;
|
|
12344
|
-
}
|
|
12345
|
-
if (property.key.type === "Literal" && typeof property.key.value === "string") {
|
|
12346
|
-
return property.key.value;
|
|
12347
|
-
}
|
|
12348
|
-
return void 0;
|
|
12349
|
-
};
|
|
12350
12947
|
var destructuringSource = (node) => {
|
|
12351
12948
|
const parent = node.parent;
|
|
12352
12949
|
if (parent.type === "VariableDeclarator" && parent.id === node) {
|
|
@@ -12365,19 +12962,6 @@ var restrictedGlobalDiagnostic = (node, name) => Diagnostic_exports.make({
|
|
|
12365
12962
|
node,
|
|
12366
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.`
|
|
12367
12964
|
});
|
|
12368
|
-
var indexReferences2 = (scopes) => {
|
|
12369
|
-
const references = /* @__PURE__ */ new WeakMap();
|
|
12370
|
-
for (const scope3 of scopes) {
|
|
12371
|
-
for (const reference of scope3.references) {
|
|
12372
|
-
references.set(reference.identifier, reference);
|
|
12373
|
-
}
|
|
12374
|
-
}
|
|
12375
|
-
return references;
|
|
12376
|
-
};
|
|
12377
|
-
var isUnshadowedGlobalReference = (references, node) => {
|
|
12378
|
-
const reference = references.get(node);
|
|
12379
|
-
return reference !== void 0 && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs));
|
|
12380
|
-
};
|
|
12381
12965
|
var noNonportableServerGlobals = Rule_exports.define({
|
|
12382
12966
|
name: "no-nonportable-server-globals",
|
|
12383
12967
|
meta: Rule_exports.meta({
|
|
@@ -12386,23 +12970,23 @@ var noNonportableServerGlobals = Rule_exports.define({
|
|
|
12386
12970
|
}),
|
|
12387
12971
|
create: function* () {
|
|
12388
12972
|
const ctx = yield* RuleContext;
|
|
12389
|
-
const references =
|
|
12973
|
+
const references = indexReferences(ctx.sourceCode.scopeManager.scopes);
|
|
12390
12974
|
return {
|
|
12391
12975
|
Identifier: (node) => {
|
|
12392
12976
|
if (node.type !== "Identifier" || !restrictedGlobalNames.has(node.name) || isInsideTypeQuery(node)) {
|
|
12393
12977
|
return Effect_exports.void;
|
|
12394
12978
|
}
|
|
12395
|
-
return
|
|
12979
|
+
return isUnshadowedReference(references, node) ? ctx.report(restrictedGlobalDiagnostic(node, node.name)) : Effect_exports.void;
|
|
12396
12980
|
},
|
|
12397
12981
|
MemberExpression: (node) => {
|
|
12398
12982
|
if (node.type !== "MemberExpression" || node.object.type !== "Identifier" || node.object.name !== "globalThis") {
|
|
12399
12983
|
return Effect_exports.void;
|
|
12400
12984
|
}
|
|
12401
|
-
const
|
|
12402
|
-
if (
|
|
12985
|
+
const maybeMemberName = staticMemberName(node);
|
|
12986
|
+
if (Option_exports.isNone(maybeMemberName) || !restrictedGlobalNames.has(maybeMemberName.value)) {
|
|
12403
12987
|
return Effect_exports.void;
|
|
12404
12988
|
}
|
|
12405
|
-
return
|
|
12989
|
+
return isUnshadowedReference(references, node.object) ? ctx.report(restrictedGlobalDiagnostic(node, maybeMemberName.value)) : Effect_exports.void;
|
|
12406
12990
|
},
|
|
12407
12991
|
ObjectPattern: (node) => {
|
|
12408
12992
|
if (node.type !== "ObjectPattern") {
|
|
@@ -12416,10 +13000,10 @@ var noNonportableServerGlobals = Rule_exports.define({
|
|
|
12416
13000
|
if (property.type !== "Property") {
|
|
12417
13001
|
return [];
|
|
12418
13002
|
}
|
|
12419
|
-
const
|
|
12420
|
-
return
|
|
13003
|
+
const maybeName = staticPropertyName(property);
|
|
13004
|
+
return Option_exports.isSome(maybeName) && restrictedGlobalNames.has(maybeName.value) ? [{ name: maybeName.value, property }] : [];
|
|
12421
13005
|
});
|
|
12422
|
-
return
|
|
13006
|
+
return isUnshadowedReference(references, source) ? Effect_exports.forEach(
|
|
12423
13007
|
restrictedProperties,
|
|
12424
13008
|
({ name, property }) => ctx.report(restrictedGlobalDiagnostic(property, name)),
|
|
12425
13009
|
{ discard: true }
|
|
@@ -13161,6 +13745,7 @@ var basePlugin = Plugin_exports.define({
|
|
|
13161
13745
|
"no-empty-object-tagged-call": noEmptyObjectTaggedCall,
|
|
13162
13746
|
"no-hand-rolled-command-struct": noHandRolledCommandStruct,
|
|
13163
13747
|
"no-hardcoded-route-strings": noHardcodedRouteStrings,
|
|
13748
|
+
"no-impure-call-at-decision-time": noImpureCallAtDecisionTime,
|
|
13164
13749
|
"no-module-level-mutable-state": noModuleLevelMutableState,
|
|
13165
13750
|
"no-nonportable-server-globals": noNonportableServerGlobals,
|
|
13166
13751
|
"no-noop-message": noNoopMessage,
|
|
@@ -13183,13 +13768,31 @@ var serverFilePatterns = [
|
|
|
13183
13768
|
"**/entry.server.tsx",
|
|
13184
13769
|
"**/server/**/*.ts",
|
|
13185
13770
|
"**/server/**/*.tsx",
|
|
13186
|
-
"**/prerender.ts"
|
|
13771
|
+
"**/prerender.ts",
|
|
13772
|
+
"**/prerender.tsx"
|
|
13187
13773
|
];
|
|
13774
|
+
var entryFilePatterns = [
|
|
13775
|
+
"**/entry.ts",
|
|
13776
|
+
"**/entry.tsx",
|
|
13777
|
+
"**/entry.client.ts",
|
|
13778
|
+
"**/entry.client.tsx",
|
|
13779
|
+
"**/entry.server.ts",
|
|
13780
|
+
"**/entry.server.tsx"
|
|
13781
|
+
];
|
|
13782
|
+
var decisionTimeRuleId = "foldkit/no-impure-call-at-decision-time";
|
|
13188
13783
|
var serverOverride = {
|
|
13189
13784
|
files: serverFilePatterns,
|
|
13190
13785
|
excludeFiles: testFilePatterns,
|
|
13191
13786
|
rules: {
|
|
13192
|
-
"foldkit/no-nonportable-server-globals": "error"
|
|
13787
|
+
"foldkit/no-nonportable-server-globals": "error",
|
|
13788
|
+
[decisionTimeRuleId]: "off"
|
|
13789
|
+
}
|
|
13790
|
+
};
|
|
13791
|
+
var entryOverride = {
|
|
13792
|
+
files: entryFilePatterns,
|
|
13793
|
+
excludeFiles: testFilePatterns,
|
|
13794
|
+
rules: {
|
|
13795
|
+
[decisionTimeRuleId]: "off"
|
|
13193
13796
|
}
|
|
13194
13797
|
};
|
|
13195
13798
|
var testOverride = (config) => ({
|
|
@@ -13207,7 +13810,7 @@ var withOverrides = (config) => ({
|
|
|
13207
13810
|
...config.rules,
|
|
13208
13811
|
"foldkit/no-nonportable-server-globals": "off"
|
|
13209
13812
|
},
|
|
13210
|
-
overrides: [serverOverride, testOverride(config)]
|
|
13813
|
+
overrides: [serverOverride, entryOverride, testOverride(config)]
|
|
13211
13814
|
});
|
|
13212
13815
|
var index_default = {
|
|
13213
13816
|
...basePlugin,
|
package/dist/message.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAW3C,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAA;CAChC,CAAC,CAAA;AAEF,eAAO,MAAM,iCAAiC,aAClC,GAAG,CAAC,MAAM,CAAC,QACf,MAAM,CAAC,IAAI,KAChB,IA0BF,CAAA;AAED,eAAO,MAAM,YAAY,SACjB,MAAM,CAAC,cAAc,YACjB,WAAW,CAAC,MAAM,CAAC,KAC5B,aAAa,CAAC,WAAW,CA4B3B,CAAA;AAED,eAAO,MAAM,yBAAyB,WAC5B,MAAM,CAAC,gBAAgB,KAC9B,OAMA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-empty-commands-array.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-commands-array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-empty-commands-array.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-commands-array.ts"],"names":[],"mappings":"AAgDA;;;2EAG2E;AAC3E,eAAO,MAAM,oBAAoB,oCAyE/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-empty-to-parent-out-message.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-to-parent-out-message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-empty-to-parent-out-message.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-to-parent-out-message.ts"],"names":[],"mappings":"AAgHA;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,oCAgFpC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flags direct calls to known nondeterministic globals unless they appear in a
|
|
3
|
+
* recognized deferred Effect, Stream, Command, Mount, Subscription, or
|
|
4
|
+
* ManagedResource callback.
|
|
5
|
+
*/
|
|
6
|
+
export declare const noImpureCallAtDecisionTime: import("effect-oxlint").CreateRule;
|
|
7
|
+
//# sourceMappingURL=no-impure-call-at-decision-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-impure-call-at-decision-time.d.ts","sourceRoot":"","sources":["../../src/rules/no-impure-call-at-decision-time.ts"],"names":[],"mappings":"AA80BA;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,oCAyCrC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-nonportable-server-globals.d.ts","sourceRoot":"","sources":["../../src/rules/no-nonportable-server-globals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-nonportable-server-globals.d.ts","sourceRoot":"","sources":["../../src/rules/no-nonportable-server-globals.ts"],"names":[],"mappings":"AA+EA;;GAEG;AACH,eAAO,MAAM,0BAA0B,oCAuErC,CAAA"}
|
package/package.json
CHANGED
package/recommended.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"foldkit/no-empty-object-tagged-call": "error",
|
|
25
25
|
"foldkit/no-hand-rolled-command-struct": "error",
|
|
26
26
|
"foldkit/no-hardcoded-route-strings": "error",
|
|
27
|
+
"foldkit/no-impure-call-at-decision-time": "error",
|
|
27
28
|
"foldkit/no-module-level-mutable-state": "error",
|
|
28
29
|
"foldkit/no-nonportable-server-globals": "off",
|
|
29
30
|
"foldkit/no-noop-message": "error",
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
"**/entry.server.tsx",
|
|
42
43
|
"**/server/**/*.ts",
|
|
43
44
|
"**/server/**/*.tsx",
|
|
44
|
-
"**/prerender.ts"
|
|
45
|
+
"**/prerender.ts",
|
|
46
|
+
"**/prerender.tsx"
|
|
45
47
|
],
|
|
46
48
|
"excludeFiles": [
|
|
47
49
|
"**/*.test.ts",
|
|
@@ -50,7 +52,27 @@
|
|
|
50
52
|
"**/*.spec.tsx"
|
|
51
53
|
],
|
|
52
54
|
"rules": {
|
|
53
|
-
"foldkit/no-nonportable-server-globals": "error"
|
|
55
|
+
"foldkit/no-nonportable-server-globals": "error",
|
|
56
|
+
"foldkit/no-impure-call-at-decision-time": "off"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"files": [
|
|
61
|
+
"**/entry.ts",
|
|
62
|
+
"**/entry.tsx",
|
|
63
|
+
"**/entry.client.ts",
|
|
64
|
+
"**/entry.client.tsx",
|
|
65
|
+
"**/entry.server.ts",
|
|
66
|
+
"**/entry.server.tsx"
|
|
67
|
+
],
|
|
68
|
+
"excludeFiles": [
|
|
69
|
+
"**/*.test.ts",
|
|
70
|
+
"**/*.test.tsx",
|
|
71
|
+
"**/*.spec.ts",
|
|
72
|
+
"**/*.spec.tsx"
|
|
73
|
+
],
|
|
74
|
+
"rules": {
|
|
75
|
+
"foldkit/no-impure-call-at-decision-time": "off"
|
|
54
76
|
}
|
|
55
77
|
},
|
|
56
78
|
{
|
|
@@ -79,6 +101,7 @@
|
|
|
79
101
|
"foldkit/no-empty-object-tagged-call": "off",
|
|
80
102
|
"foldkit/no-hand-rolled-command-struct": "off",
|
|
81
103
|
"foldkit/no-hardcoded-route-strings": "off",
|
|
104
|
+
"foldkit/no-impure-call-at-decision-time": "off",
|
|
82
105
|
"foldkit/no-module-level-mutable-state": "off",
|
|
83
106
|
"foldkit/no-nonportable-server-globals": "off",
|
|
84
107
|
"foldkit/no-noop-message": "off",
|