atom.io 0.19.2 → 0.19.3
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/data/dist/index.js +1 -1
- package/data/package.json +1 -1
- package/dist/{chunk-U2IICNHQ.js → chunk-F2X4B4VY.js} +5 -1
- package/dist/index.js +1 -1
- package/eslint-plugin/dist/index.cjs +180 -0
- package/eslint-plugin/dist/index.js +171 -0
- package/eslint-plugin/package.json +16 -0
- package/eslint-plugin/src/index.ts +11 -0
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +190 -0
- package/internal/dist/index.js +1 -1
- package/internal/package.json +1 -1
- package/introspection/dist/index.js +1 -1
- package/introspection/package.json +1 -1
- package/json/dist/index.js +1 -1
- package/json/package.json +1 -1
- package/package.json +24 -9
- package/react/dist/index.js +1 -1
- package/react/package.json +1 -1
- package/react-devtools/dist/index.cjs +92 -105
- package/react-devtools/dist/index.js +70 -83
- package/react-devtools/package.json +1 -1
- package/react-devtools/src/Updates.tsx +10 -7
- package/realtime/dist/index.js +1 -1
- package/realtime/package.json +1 -1
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/package.json +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-react/package.json +1 -1
- package/realtime-server/dist/index.js +1 -1
- package/realtime-server/package.json +1 -1
- package/realtime-testing/dist/index.js +1 -1
- package/realtime-testing/package.json +1 -1
- package/transceivers/set-rtx/dist/index.js +1 -1
- package/transceivers/set-rtx/package.json +1 -1
package/data/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-MSCJWACE.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
|
-
import '../../dist/chunk-
|
|
3
|
+
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, findInStore, IMPLICIT, createRegularAtom, createRegularAtomFamily, createSelectorFamily } from 'atom.io/internal';
|
|
5
5
|
|
|
6
6
|
function dict(findState, index, store = IMPLICIT.STORE) {
|
package/data/package.json
CHANGED
|
@@ -30,5 +30,9 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
}
|
|
31
31
|
return target;
|
|
32
32
|
};
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name in all)
|
|
35
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
|
+
};
|
|
33
37
|
|
|
34
|
-
export { __objRest, __restKey, __spreadProps, __spreadValues };
|
|
38
|
+
export { __export, __objRest, __restKey, __spreadProps, __spreadValues };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-F2X4B4VY.js';
|
|
2
2
|
import * as Internal from 'atom.io/internal';
|
|
3
3
|
import { createStandaloneAtom, IMPLICIT, createAtomFamily, findInStore, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, getFromStore, setIntoStore, timeTravel, subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary, actUponStore } from 'atom.io/internal';
|
|
4
4
|
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// eslint-plugin/src/rules/index.ts
|
|
12
|
+
var rules_exports = {};
|
|
13
|
+
__export(rules_exports, {
|
|
14
|
+
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
18
|
+
function walk(node, callback, depth = 0) {
|
|
19
|
+
callback(node, depth);
|
|
20
|
+
switch (node.type) {
|
|
21
|
+
case `FunctionDeclaration`:
|
|
22
|
+
case `FunctionExpression`:
|
|
23
|
+
case `ArrowFunctionExpression`:
|
|
24
|
+
for (const param of node.params) {
|
|
25
|
+
walk(param, callback, depth + 1);
|
|
26
|
+
}
|
|
27
|
+
walk(node.body, callback, depth + 1);
|
|
28
|
+
break;
|
|
29
|
+
case `BlockStatement`:
|
|
30
|
+
for (const statement of node.body) {
|
|
31
|
+
walk(statement, callback, depth + 1);
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case `IfStatement`:
|
|
35
|
+
walk(node.test, callback, depth);
|
|
36
|
+
walk(node.consequent, callback, depth);
|
|
37
|
+
if (node.alternate) {
|
|
38
|
+
walk(node.alternate, callback, depth);
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case `SwitchStatement`:
|
|
42
|
+
walk(node.discriminant, callback, depth + 1);
|
|
43
|
+
for (const caseOrDefault of node.cases) {
|
|
44
|
+
walk(caseOrDefault, callback, depth);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
case `ReturnStatement`:
|
|
48
|
+
if (node.argument) {
|
|
49
|
+
walk(node.argument, callback, depth);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case `SwitchCase`:
|
|
53
|
+
if (node.test) {
|
|
54
|
+
walk(node.test, callback, depth);
|
|
55
|
+
}
|
|
56
|
+
for (const statement of node.consequent) {
|
|
57
|
+
walk(statement, callback, depth);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case `VariableDeclaration`:
|
|
61
|
+
for (const declaration of node.declarations) {
|
|
62
|
+
walk(declaration, callback, depth);
|
|
63
|
+
if (declaration.init) {
|
|
64
|
+
walk(declaration.init, callback, depth);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case `BinaryExpression`:
|
|
69
|
+
walk(node.left, callback, depth);
|
|
70
|
+
walk(node.right, callback, depth);
|
|
71
|
+
break;
|
|
72
|
+
case `MemberExpression`:
|
|
73
|
+
walk(node.object, callback, depth);
|
|
74
|
+
walk(node.property, callback, depth);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
var synchronousSelectorDependencies = {
|
|
79
|
+
meta: {
|
|
80
|
+
type: `problem`,
|
|
81
|
+
docs: {
|
|
82
|
+
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
83
|
+
category: `Possible Errors`,
|
|
84
|
+
recommended: false,
|
|
85
|
+
url: ``
|
|
86
|
+
// URL to documentation page for this rule
|
|
87
|
+
},
|
|
88
|
+
schema: []
|
|
89
|
+
// no options
|
|
90
|
+
},
|
|
91
|
+
create(context) {
|
|
92
|
+
return {
|
|
93
|
+
CallExpression(node) {
|
|
94
|
+
let selectorComputation;
|
|
95
|
+
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
96
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
97
|
+
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
98
|
+
(prop) => {
|
|
99
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
const selectorLookup = selectorLookupProperty == null ? void 0 : selectorLookupProperty.value;
|
|
103
|
+
if ((selectorLookup == null ? void 0 : selectorLookup.type) === `FunctionExpression` || (selectorLookup == null ? void 0 : selectorLookup.type) === `ArrowFunctionExpression`) {
|
|
104
|
+
if (selectorLookup.body.type === `BlockStatement`) {
|
|
105
|
+
for (const statement of selectorLookup.body.body) {
|
|
106
|
+
if (statement.type === `ReturnStatement` && statement.argument) {
|
|
107
|
+
selectorComputation = statement.argument;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else if (selectorLookup.body.type === `FunctionExpression` || selectorLookup.body.type === `ArrowFunctionExpression`) {
|
|
111
|
+
selectorComputation = selectorLookup.body;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
117
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
118
|
+
const selectorComputationProperty = node.arguments[0].properties.find(
|
|
119
|
+
(prop) => {
|
|
120
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
selectorComputation = selectorComputationProperty == null ? void 0 : selectorComputationProperty.value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if ((selectorComputation == null ? void 0 : selectorComputation.type) === `FunctionExpression` || (selectorComputation == null ? void 0 : selectorComputation.type) === `ArrowFunctionExpression`) {
|
|
127
|
+
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
|
|
128
|
+
let awaited;
|
|
129
|
+
let awaitNode;
|
|
130
|
+
walk(selectorComputation, (n, depth) => {
|
|
131
|
+
if (typeof awaited === `number`) {
|
|
132
|
+
if (awaited > depth) {
|
|
133
|
+
awaited = void 0;
|
|
134
|
+
awaitNode = void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
switch (n.type) {
|
|
138
|
+
case `AwaitExpression`:
|
|
139
|
+
awaited = depth;
|
|
140
|
+
awaitNode = n;
|
|
141
|
+
break;
|
|
142
|
+
case `CallExpression`:
|
|
143
|
+
if (awaitNode) {
|
|
144
|
+
let willReport = false;
|
|
145
|
+
switch (n.callee.type) {
|
|
146
|
+
case `MemberExpression`:
|
|
147
|
+
if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `get`) {
|
|
148
|
+
willReport = true;
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case `Identifier`:
|
|
152
|
+
if (n.callee.name === `get`) {
|
|
153
|
+
willReport = true;
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (willReport) {
|
|
158
|
+
context.report({
|
|
159
|
+
node: awaitNode,
|
|
160
|
+
message: `Using await before calling the 'get' transactor is not allowed.`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// eslint-plugin/src/index.ts
|
|
173
|
+
var src_default = {
|
|
174
|
+
rules: {
|
|
175
|
+
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
exports.Rules = rules_exports;
|
|
180
|
+
exports.default = src_default;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { __export } from '../../dist/chunk-F2X4B4VY.js';
|
|
2
|
+
|
|
3
|
+
// eslint-plugin/src/rules/index.ts
|
|
4
|
+
var rules_exports = {};
|
|
5
|
+
__export(rules_exports, {
|
|
6
|
+
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
10
|
+
function walk(node, callback, depth = 0) {
|
|
11
|
+
callback(node, depth);
|
|
12
|
+
switch (node.type) {
|
|
13
|
+
case `FunctionDeclaration`:
|
|
14
|
+
case `FunctionExpression`:
|
|
15
|
+
case `ArrowFunctionExpression`:
|
|
16
|
+
for (const param of node.params) {
|
|
17
|
+
walk(param, callback, depth + 1);
|
|
18
|
+
}
|
|
19
|
+
walk(node.body, callback, depth + 1);
|
|
20
|
+
break;
|
|
21
|
+
case `BlockStatement`:
|
|
22
|
+
for (const statement of node.body) {
|
|
23
|
+
walk(statement, callback, depth + 1);
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case `IfStatement`:
|
|
27
|
+
walk(node.test, callback, depth);
|
|
28
|
+
walk(node.consequent, callback, depth);
|
|
29
|
+
if (node.alternate) {
|
|
30
|
+
walk(node.alternate, callback, depth);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
case `SwitchStatement`:
|
|
34
|
+
walk(node.discriminant, callback, depth + 1);
|
|
35
|
+
for (const caseOrDefault of node.cases) {
|
|
36
|
+
walk(caseOrDefault, callback, depth);
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case `ReturnStatement`:
|
|
40
|
+
if (node.argument) {
|
|
41
|
+
walk(node.argument, callback, depth);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case `SwitchCase`:
|
|
45
|
+
if (node.test) {
|
|
46
|
+
walk(node.test, callback, depth);
|
|
47
|
+
}
|
|
48
|
+
for (const statement of node.consequent) {
|
|
49
|
+
walk(statement, callback, depth);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case `VariableDeclaration`:
|
|
53
|
+
for (const declaration of node.declarations) {
|
|
54
|
+
walk(declaration, callback, depth);
|
|
55
|
+
if (declaration.init) {
|
|
56
|
+
walk(declaration.init, callback, depth);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case `BinaryExpression`:
|
|
61
|
+
walk(node.left, callback, depth);
|
|
62
|
+
walk(node.right, callback, depth);
|
|
63
|
+
break;
|
|
64
|
+
case `MemberExpression`:
|
|
65
|
+
walk(node.object, callback, depth);
|
|
66
|
+
walk(node.property, callback, depth);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var synchronousSelectorDependencies = {
|
|
71
|
+
meta: {
|
|
72
|
+
type: `problem`,
|
|
73
|
+
docs: {
|
|
74
|
+
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
75
|
+
category: `Possible Errors`,
|
|
76
|
+
recommended: false,
|
|
77
|
+
url: ``
|
|
78
|
+
// URL to documentation page for this rule
|
|
79
|
+
},
|
|
80
|
+
schema: []
|
|
81
|
+
// no options
|
|
82
|
+
},
|
|
83
|
+
create(context) {
|
|
84
|
+
return {
|
|
85
|
+
CallExpression(node) {
|
|
86
|
+
let selectorComputation;
|
|
87
|
+
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
88
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
89
|
+
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
90
|
+
(prop) => {
|
|
91
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
const selectorLookup = selectorLookupProperty == null ? void 0 : selectorLookupProperty.value;
|
|
95
|
+
if ((selectorLookup == null ? void 0 : selectorLookup.type) === `FunctionExpression` || (selectorLookup == null ? void 0 : selectorLookup.type) === `ArrowFunctionExpression`) {
|
|
96
|
+
if (selectorLookup.body.type === `BlockStatement`) {
|
|
97
|
+
for (const statement of selectorLookup.body.body) {
|
|
98
|
+
if (statement.type === `ReturnStatement` && statement.argument) {
|
|
99
|
+
selectorComputation = statement.argument;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} else if (selectorLookup.body.type === `FunctionExpression` || selectorLookup.body.type === `ArrowFunctionExpression`) {
|
|
103
|
+
selectorComputation = selectorLookup.body;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
109
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
110
|
+
const selectorComputationProperty = node.arguments[0].properties.find(
|
|
111
|
+
(prop) => {
|
|
112
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
selectorComputation = selectorComputationProperty == null ? void 0 : selectorComputationProperty.value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if ((selectorComputation == null ? void 0 : selectorComputation.type) === `FunctionExpression` || (selectorComputation == null ? void 0 : selectorComputation.type) === `ArrowFunctionExpression`) {
|
|
119
|
+
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
|
|
120
|
+
let awaited;
|
|
121
|
+
let awaitNode;
|
|
122
|
+
walk(selectorComputation, (n, depth) => {
|
|
123
|
+
if (typeof awaited === `number`) {
|
|
124
|
+
if (awaited > depth) {
|
|
125
|
+
awaited = void 0;
|
|
126
|
+
awaitNode = void 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
switch (n.type) {
|
|
130
|
+
case `AwaitExpression`:
|
|
131
|
+
awaited = depth;
|
|
132
|
+
awaitNode = n;
|
|
133
|
+
break;
|
|
134
|
+
case `CallExpression`:
|
|
135
|
+
if (awaitNode) {
|
|
136
|
+
let willReport = false;
|
|
137
|
+
switch (n.callee.type) {
|
|
138
|
+
case `MemberExpression`:
|
|
139
|
+
if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `get`) {
|
|
140
|
+
willReport = true;
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case `Identifier`:
|
|
144
|
+
if (n.callee.name === `get`) {
|
|
145
|
+
willReport = true;
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
if (willReport) {
|
|
150
|
+
context.report({
|
|
151
|
+
node: awaitNode,
|
|
152
|
+
message: `Using await before calling the 'get' transactor is not allowed.`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// eslint-plugin/src/index.ts
|
|
165
|
+
var src_default = {
|
|
166
|
+
rules: {
|
|
167
|
+
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { rules_exports as Rules, src_default as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atom.io-eslint-plugin",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"browser": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./synchronous-selector-dependencies"
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { Rule } from "eslint"
|
|
2
|
+
import type * as ESTree from "estree"
|
|
3
|
+
|
|
4
|
+
function walk(
|
|
5
|
+
node: ESTree.Node,
|
|
6
|
+
callback: (node: ESTree.Node, depth: number) => void,
|
|
7
|
+
depth = 0,
|
|
8
|
+
) {
|
|
9
|
+
callback(node, depth)
|
|
10
|
+
|
|
11
|
+
switch (node.type) {
|
|
12
|
+
case `FunctionDeclaration`:
|
|
13
|
+
case `FunctionExpression`:
|
|
14
|
+
case `ArrowFunctionExpression`:
|
|
15
|
+
for (const param of node.params) {
|
|
16
|
+
walk(param, callback, depth + 1)
|
|
17
|
+
}
|
|
18
|
+
walk(node.body, callback, depth + 1)
|
|
19
|
+
break
|
|
20
|
+
case `BlockStatement`:
|
|
21
|
+
for (const statement of node.body) {
|
|
22
|
+
walk(statement, callback, depth + 1)
|
|
23
|
+
}
|
|
24
|
+
break
|
|
25
|
+
case `IfStatement`:
|
|
26
|
+
walk(node.test, callback, depth)
|
|
27
|
+
walk(node.consequent, callback, depth)
|
|
28
|
+
if (node.alternate) {
|
|
29
|
+
walk(node.alternate, callback, depth)
|
|
30
|
+
}
|
|
31
|
+
break
|
|
32
|
+
case `SwitchStatement`:
|
|
33
|
+
walk(node.discriminant, callback, depth + 1)
|
|
34
|
+
for (const caseOrDefault of node.cases) {
|
|
35
|
+
walk(caseOrDefault, callback, depth)
|
|
36
|
+
}
|
|
37
|
+
break
|
|
38
|
+
case `ReturnStatement`:
|
|
39
|
+
if (node.argument) {
|
|
40
|
+
walk(node.argument, callback, depth)
|
|
41
|
+
}
|
|
42
|
+
break
|
|
43
|
+
case `SwitchCase`:
|
|
44
|
+
if (node.test) {
|
|
45
|
+
walk(node.test, callback, depth)
|
|
46
|
+
}
|
|
47
|
+
for (const statement of node.consequent) {
|
|
48
|
+
walk(statement, callback, depth)
|
|
49
|
+
}
|
|
50
|
+
break
|
|
51
|
+
case `VariableDeclaration`:
|
|
52
|
+
for (const declaration of node.declarations) {
|
|
53
|
+
walk(declaration, callback, depth)
|
|
54
|
+
if (declaration.init) {
|
|
55
|
+
walk(declaration.init, callback, depth)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
break
|
|
59
|
+
case `BinaryExpression`:
|
|
60
|
+
walk(node.left, callback, depth)
|
|
61
|
+
walk(node.right, callback, depth)
|
|
62
|
+
break
|
|
63
|
+
case `MemberExpression`:
|
|
64
|
+
walk(node.object, callback, depth)
|
|
65
|
+
walk(node.property, callback, depth)
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const synchronousSelectorDependencies = {
|
|
71
|
+
meta: {
|
|
72
|
+
type: `problem`,
|
|
73
|
+
docs: {
|
|
74
|
+
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
75
|
+
category: `Possible Errors`,
|
|
76
|
+
recommended: false,
|
|
77
|
+
url: ``, // URL to documentation page for this rule
|
|
78
|
+
},
|
|
79
|
+
schema: [], // no options
|
|
80
|
+
},
|
|
81
|
+
create(context) {
|
|
82
|
+
return {
|
|
83
|
+
CallExpression(node) {
|
|
84
|
+
let selectorComputation: ESTree.Node | undefined
|
|
85
|
+
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
86
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
87
|
+
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
88
|
+
(prop): prop is ESTree.Property => {
|
|
89
|
+
return (
|
|
90
|
+
`key` in prop && `name` in prop.key && prop.key.name === `get`
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
const selectorLookup = selectorLookupProperty?.value
|
|
95
|
+
if (
|
|
96
|
+
selectorLookup?.type === `FunctionExpression` ||
|
|
97
|
+
selectorLookup?.type === `ArrowFunctionExpression`
|
|
98
|
+
) {
|
|
99
|
+
if (selectorLookup.body.type === `BlockStatement`) {
|
|
100
|
+
for (const statement of selectorLookup.body.body) {
|
|
101
|
+
if (
|
|
102
|
+
statement.type === `ReturnStatement` &&
|
|
103
|
+
statement.argument
|
|
104
|
+
) {
|
|
105
|
+
selectorComputation = statement.argument
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else if (
|
|
109
|
+
selectorLookup.body.type === `FunctionExpression` ||
|
|
110
|
+
selectorLookup.body.type === `ArrowFunctionExpression`
|
|
111
|
+
) {
|
|
112
|
+
selectorComputation = selectorLookup.body
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
118
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
119
|
+
const selectorComputationProperty =
|
|
120
|
+
node.arguments[0].properties.find(
|
|
121
|
+
(prop): prop is ESTree.Property => {
|
|
122
|
+
return (
|
|
123
|
+
`key` in prop &&
|
|
124
|
+
`name` in prop.key &&
|
|
125
|
+
prop.key.name === `get`
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
)
|
|
129
|
+
selectorComputation = selectorComputationProperty?.value
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (
|
|
133
|
+
selectorComputation?.type === `FunctionExpression` ||
|
|
134
|
+
selectorComputation?.type === `ArrowFunctionExpression`
|
|
135
|
+
) {
|
|
136
|
+
const nonDestructuredTransactorsName =
|
|
137
|
+
selectorComputation.params[0] &&
|
|
138
|
+
`name` in selectorComputation.params[0]
|
|
139
|
+
? selectorComputation.params[0].name
|
|
140
|
+
: undefined
|
|
141
|
+
let awaited: number | undefined
|
|
142
|
+
let awaitNode: ESTree.AwaitExpression | undefined
|
|
143
|
+
walk(selectorComputation, (n, depth) => {
|
|
144
|
+
// console.log(`${`\t`.repeat(depth)}${n.type} ${n.name ?? ``}`)
|
|
145
|
+
if (typeof awaited === `number`) {
|
|
146
|
+
if (awaited > depth) {
|
|
147
|
+
awaited = undefined
|
|
148
|
+
awaitNode = undefined
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
switch (n.type) {
|
|
152
|
+
case `AwaitExpression`:
|
|
153
|
+
awaited = depth
|
|
154
|
+
awaitNode = n
|
|
155
|
+
break
|
|
156
|
+
case `CallExpression`:
|
|
157
|
+
if (awaitNode) {
|
|
158
|
+
let willReport = false
|
|
159
|
+
switch (n.callee.type) {
|
|
160
|
+
case `MemberExpression`:
|
|
161
|
+
if (
|
|
162
|
+
n.callee.object.type === `Identifier` &&
|
|
163
|
+
n.callee.object.name ===
|
|
164
|
+
nonDestructuredTransactorsName &&
|
|
165
|
+
n.callee.property.type === `Identifier` &&
|
|
166
|
+
n.callee.property.name === `get`
|
|
167
|
+
) {
|
|
168
|
+
willReport = true
|
|
169
|
+
}
|
|
170
|
+
break
|
|
171
|
+
case `Identifier`:
|
|
172
|
+
if (n.callee.name === `get`) {
|
|
173
|
+
willReport = true
|
|
174
|
+
}
|
|
175
|
+
break
|
|
176
|
+
}
|
|
177
|
+
if (willReport) {
|
|
178
|
+
context.report({
|
|
179
|
+
node: awaitNode,
|
|
180
|
+
message: `Using await before calling the 'get' transactor is not allowed.`,
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
} satisfies Rule.RuleModule
|
package/internal/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Junction } from '../../dist/chunk-FTONNX2R.js';
|
|
2
|
-
import { __spreadValues, __spreadProps } from '../../dist/chunk-
|
|
2
|
+
import { __spreadValues, __spreadProps } from '../../dist/chunk-F2X4B4VY.js';
|
|
3
3
|
import { stringifyJson, selectJson, parseJson, selectJsonFamily } from 'atom.io/json';
|
|
4
4
|
import { AtomIOLogger } from 'atom.io';
|
|
5
5
|
|
package/internal/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __spreadValues, __spreadProps } from '../../dist/chunk-
|
|
1
|
+
import { __spreadValues, __spreadProps } from '../../dist/chunk-F2X4B4VY.js';
|
|
2
2
|
import * as Internal from 'atom.io/internal';
|
|
3
3
|
import { createRegularAtom, newest, createStandaloneSelector, IMPLICIT, createRegularAtomFamily, Subject, createSelectorFamily } from 'atom.io/internal';
|
|
4
4
|
|
package/json/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseJson } from '../../dist/chunk-BF4MVQF6.js';
|
|
2
2
|
export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-BF4MVQF6.js';
|
|
3
|
-
import '../../dist/chunk-
|
|
3
|
+
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, IMPLICIT, createSelectorFamily } from 'atom.io/internal';
|
|
5
5
|
|
|
6
6
|
var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
|