atom.io 0.19.2 → 0.19.4
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 +233 -0
- package/eslint-plugin/dist/index.js +223 -0
- package/eslint-plugin/package.json +16 -0
- package/eslint-plugin/src/index.ts +12 -0
- package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
- package/eslint-plugin/src/rules/index.ts +2 -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.cjs +5 -5
- package/json/dist/index.js +6 -6
- package/json/package.json +1 -1
- package/json/src/select-json-family.ts +5 -5
- package/package.json +27 -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.css +0 -3
- package/react-devtools/dist/index.js +70 -83
- package/react-devtools/package.json +1 -1
- package/react-devtools/src/Updates.tsx +10 -7
- package/react-devtools/src/devtools.scss +0 -3
- package/realtime/dist/index.js +1 -1
- package/realtime/package.json +1 -1
- package/realtime/src/shared-room-store.ts +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.d.ts +3 -4
- package/realtime-server/dist/index.js +1 -1
- package/realtime-server/package.json +1 -1
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
- 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,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@typescript-eslint/utils');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// eslint-plugin/src/rules/index.ts
|
|
14
|
+
var rules_exports = {};
|
|
15
|
+
__export(rules_exports, {
|
|
16
|
+
explicitStateTypes: () => explicitStateTypes,
|
|
17
|
+
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
18
|
+
});
|
|
19
|
+
var createRule = utils.ESLintUtils.RuleCreator(
|
|
20
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
|
|
21
|
+
);
|
|
22
|
+
var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
|
|
23
|
+
var explicitStateTypes = createRule({
|
|
24
|
+
name: `explicit-state-types`,
|
|
25
|
+
meta: {
|
|
26
|
+
type: `problem`,
|
|
27
|
+
docs: {
|
|
28
|
+
description: `State declarations must have generic type arguments directly passed to them`
|
|
29
|
+
},
|
|
30
|
+
messages: {
|
|
31
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
|
|
32
|
+
},
|
|
33
|
+
schema: []
|
|
34
|
+
// no options
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: [],
|
|
37
|
+
create(context) {
|
|
38
|
+
return {
|
|
39
|
+
CallExpression(node) {
|
|
40
|
+
const { callee } = node;
|
|
41
|
+
switch (callee.type) {
|
|
42
|
+
case `Identifier`: {
|
|
43
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
44
|
+
if (!node.typeArguments) {
|
|
45
|
+
context.report({
|
|
46
|
+
node,
|
|
47
|
+
messageId: `noTypeArgument`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case `MemberExpression`: {
|
|
54
|
+
if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
|
|
55
|
+
if (!node.typeArguments) {
|
|
56
|
+
context.report({
|
|
57
|
+
node,
|
|
58
|
+
messageId: `noTypeArgument`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
70
|
+
function walk(node, callback, depth = 0) {
|
|
71
|
+
callback(node, depth);
|
|
72
|
+
switch (node.type) {
|
|
73
|
+
case `FunctionDeclaration`:
|
|
74
|
+
case `FunctionExpression`:
|
|
75
|
+
case `ArrowFunctionExpression`:
|
|
76
|
+
for (const param of node.params) {
|
|
77
|
+
walk(param, callback, depth + 1);
|
|
78
|
+
}
|
|
79
|
+
walk(node.body, callback, depth + 1);
|
|
80
|
+
break;
|
|
81
|
+
case `BlockStatement`:
|
|
82
|
+
for (const statement of node.body) {
|
|
83
|
+
walk(statement, callback, depth + 1);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case `IfStatement`:
|
|
87
|
+
walk(node.test, callback, depth);
|
|
88
|
+
walk(node.consequent, callback, depth);
|
|
89
|
+
if (node.alternate) {
|
|
90
|
+
walk(node.alternate, callback, depth);
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case `SwitchStatement`:
|
|
94
|
+
walk(node.discriminant, callback, depth + 1);
|
|
95
|
+
for (const caseOrDefault of node.cases) {
|
|
96
|
+
walk(caseOrDefault, callback, depth);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case `ReturnStatement`:
|
|
100
|
+
if (node.argument) {
|
|
101
|
+
walk(node.argument, callback, depth);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case `SwitchCase`:
|
|
105
|
+
if (node.test) {
|
|
106
|
+
walk(node.test, callback, depth);
|
|
107
|
+
}
|
|
108
|
+
for (const statement of node.consequent) {
|
|
109
|
+
walk(statement, callback, depth);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case `VariableDeclaration`:
|
|
113
|
+
for (const declaration of node.declarations) {
|
|
114
|
+
walk(declaration, callback, depth);
|
|
115
|
+
if (declaration.init) {
|
|
116
|
+
walk(declaration.init, callback, depth);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case `BinaryExpression`:
|
|
121
|
+
walk(node.left, callback, depth);
|
|
122
|
+
walk(node.right, callback, depth);
|
|
123
|
+
break;
|
|
124
|
+
case `MemberExpression`:
|
|
125
|
+
walk(node.object, callback, depth);
|
|
126
|
+
walk(node.property, callback, depth);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
var synchronousSelectorDependencies = {
|
|
131
|
+
meta: {
|
|
132
|
+
type: `problem`,
|
|
133
|
+
docs: {
|
|
134
|
+
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
135
|
+
category: `Possible Errors`,
|
|
136
|
+
recommended: false,
|
|
137
|
+
url: ``
|
|
138
|
+
// URL to documentation page for this rule
|
|
139
|
+
},
|
|
140
|
+
schema: []
|
|
141
|
+
// no options
|
|
142
|
+
},
|
|
143
|
+
create(context) {
|
|
144
|
+
return {
|
|
145
|
+
CallExpression(node) {
|
|
146
|
+
let selectorComputation;
|
|
147
|
+
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
148
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
149
|
+
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
150
|
+
(prop) => {
|
|
151
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
const selectorLookup = selectorLookupProperty == null ? void 0 : selectorLookupProperty.value;
|
|
155
|
+
if ((selectorLookup == null ? void 0 : selectorLookup.type) === `FunctionExpression` || (selectorLookup == null ? void 0 : selectorLookup.type) === `ArrowFunctionExpression`) {
|
|
156
|
+
if (selectorLookup.body.type === `BlockStatement`) {
|
|
157
|
+
for (const statement of selectorLookup.body.body) {
|
|
158
|
+
if (statement.type === `ReturnStatement` && statement.argument) {
|
|
159
|
+
selectorComputation = statement.argument;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} else if (selectorLookup.body.type === `FunctionExpression` || selectorLookup.body.type === `ArrowFunctionExpression`) {
|
|
163
|
+
selectorComputation = selectorLookup.body;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
169
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
170
|
+
const selectorComputationProperty = node.arguments[0].properties.find(
|
|
171
|
+
(prop) => {
|
|
172
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
selectorComputation = selectorComputationProperty == null ? void 0 : selectorComputationProperty.value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if ((selectorComputation == null ? void 0 : selectorComputation.type) === `FunctionExpression` || (selectorComputation == null ? void 0 : selectorComputation.type) === `ArrowFunctionExpression`) {
|
|
179
|
+
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
|
|
180
|
+
let awaited;
|
|
181
|
+
let awaitNode;
|
|
182
|
+
walk(selectorComputation, (n, depth) => {
|
|
183
|
+
if (typeof awaited === `number`) {
|
|
184
|
+
if (awaited > depth) {
|
|
185
|
+
awaited = void 0;
|
|
186
|
+
awaitNode = void 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
switch (n.type) {
|
|
190
|
+
case `AwaitExpression`:
|
|
191
|
+
awaited = depth;
|
|
192
|
+
awaitNode = n;
|
|
193
|
+
break;
|
|
194
|
+
case `CallExpression`:
|
|
195
|
+
if (awaitNode) {
|
|
196
|
+
let willReport = false;
|
|
197
|
+
switch (n.callee.type) {
|
|
198
|
+
case `MemberExpression`:
|
|
199
|
+
if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `get`) {
|
|
200
|
+
willReport = true;
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
case `Identifier`:
|
|
204
|
+
if (n.callee.name === `get`) {
|
|
205
|
+
willReport = true;
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
if (willReport) {
|
|
210
|
+
context.report({
|
|
211
|
+
node: awaitNode,
|
|
212
|
+
message: `Using await before calling the 'get' transactor is not allowed.`
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// eslint-plugin/src/index.ts
|
|
225
|
+
var src_default = {
|
|
226
|
+
rules: {
|
|
227
|
+
"explicit-state-types": explicitStateTypes,
|
|
228
|
+
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
exports.Rules = rules_exports;
|
|
233
|
+
exports.default = src_default;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { __export } from '../../dist/chunk-F2X4B4VY.js';
|
|
2
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
+
|
|
4
|
+
// eslint-plugin/src/rules/index.ts
|
|
5
|
+
var rules_exports = {};
|
|
6
|
+
__export(rules_exports, {
|
|
7
|
+
explicitStateTypes: () => explicitStateTypes,
|
|
8
|
+
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
9
|
+
});
|
|
10
|
+
var createRule = ESLintUtils.RuleCreator(
|
|
11
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
|
|
12
|
+
);
|
|
13
|
+
var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
|
|
14
|
+
var explicitStateTypes = createRule({
|
|
15
|
+
name: `explicit-state-types`,
|
|
16
|
+
meta: {
|
|
17
|
+
type: `problem`,
|
|
18
|
+
docs: {
|
|
19
|
+
description: `State declarations must have generic type arguments directly passed to them`
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
|
|
23
|
+
},
|
|
24
|
+
schema: []
|
|
25
|
+
// no options
|
|
26
|
+
},
|
|
27
|
+
defaultOptions: [],
|
|
28
|
+
create(context) {
|
|
29
|
+
return {
|
|
30
|
+
CallExpression(node) {
|
|
31
|
+
const { callee } = node;
|
|
32
|
+
switch (callee.type) {
|
|
33
|
+
case `Identifier`: {
|
|
34
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
35
|
+
if (!node.typeArguments) {
|
|
36
|
+
context.report({
|
|
37
|
+
node,
|
|
38
|
+
messageId: `noTypeArgument`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case `MemberExpression`: {
|
|
45
|
+
if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
|
|
46
|
+
if (!node.typeArguments) {
|
|
47
|
+
context.report({
|
|
48
|
+
node,
|
|
49
|
+
messageId: `noTypeArgument`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
61
|
+
function walk(node, callback, depth = 0) {
|
|
62
|
+
callback(node, depth);
|
|
63
|
+
switch (node.type) {
|
|
64
|
+
case `FunctionDeclaration`:
|
|
65
|
+
case `FunctionExpression`:
|
|
66
|
+
case `ArrowFunctionExpression`:
|
|
67
|
+
for (const param of node.params) {
|
|
68
|
+
walk(param, callback, depth + 1);
|
|
69
|
+
}
|
|
70
|
+
walk(node.body, callback, depth + 1);
|
|
71
|
+
break;
|
|
72
|
+
case `BlockStatement`:
|
|
73
|
+
for (const statement of node.body) {
|
|
74
|
+
walk(statement, callback, depth + 1);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case `IfStatement`:
|
|
78
|
+
walk(node.test, callback, depth);
|
|
79
|
+
walk(node.consequent, callback, depth);
|
|
80
|
+
if (node.alternate) {
|
|
81
|
+
walk(node.alternate, callback, depth);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case `SwitchStatement`:
|
|
85
|
+
walk(node.discriminant, callback, depth + 1);
|
|
86
|
+
for (const caseOrDefault of node.cases) {
|
|
87
|
+
walk(caseOrDefault, callback, depth);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case `ReturnStatement`:
|
|
91
|
+
if (node.argument) {
|
|
92
|
+
walk(node.argument, callback, depth);
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case `SwitchCase`:
|
|
96
|
+
if (node.test) {
|
|
97
|
+
walk(node.test, callback, depth);
|
|
98
|
+
}
|
|
99
|
+
for (const statement of node.consequent) {
|
|
100
|
+
walk(statement, callback, depth);
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case `VariableDeclaration`:
|
|
104
|
+
for (const declaration of node.declarations) {
|
|
105
|
+
walk(declaration, callback, depth);
|
|
106
|
+
if (declaration.init) {
|
|
107
|
+
walk(declaration.init, callback, depth);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case `BinaryExpression`:
|
|
112
|
+
walk(node.left, callback, depth);
|
|
113
|
+
walk(node.right, callback, depth);
|
|
114
|
+
break;
|
|
115
|
+
case `MemberExpression`:
|
|
116
|
+
walk(node.object, callback, depth);
|
|
117
|
+
walk(node.property, callback, depth);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var synchronousSelectorDependencies = {
|
|
122
|
+
meta: {
|
|
123
|
+
type: `problem`,
|
|
124
|
+
docs: {
|
|
125
|
+
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
126
|
+
category: `Possible Errors`,
|
|
127
|
+
recommended: false,
|
|
128
|
+
url: ``
|
|
129
|
+
// URL to documentation page for this rule
|
|
130
|
+
},
|
|
131
|
+
schema: []
|
|
132
|
+
// no options
|
|
133
|
+
},
|
|
134
|
+
create(context) {
|
|
135
|
+
return {
|
|
136
|
+
CallExpression(node) {
|
|
137
|
+
let selectorComputation;
|
|
138
|
+
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
139
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
140
|
+
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
141
|
+
(prop) => {
|
|
142
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
const selectorLookup = selectorLookupProperty == null ? void 0 : selectorLookupProperty.value;
|
|
146
|
+
if ((selectorLookup == null ? void 0 : selectorLookup.type) === `FunctionExpression` || (selectorLookup == null ? void 0 : selectorLookup.type) === `ArrowFunctionExpression`) {
|
|
147
|
+
if (selectorLookup.body.type === `BlockStatement`) {
|
|
148
|
+
for (const statement of selectorLookup.body.body) {
|
|
149
|
+
if (statement.type === `ReturnStatement` && statement.argument) {
|
|
150
|
+
selectorComputation = statement.argument;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} else if (selectorLookup.body.type === `FunctionExpression` || selectorLookup.body.type === `ArrowFunctionExpression`) {
|
|
154
|
+
selectorComputation = selectorLookup.body;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
160
|
+
if (node.arguments[0].type === `ObjectExpression`) {
|
|
161
|
+
const selectorComputationProperty = node.arguments[0].properties.find(
|
|
162
|
+
(prop) => {
|
|
163
|
+
return `key` in prop && `name` in prop.key && prop.key.name === `get`;
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
selectorComputation = selectorComputationProperty == null ? void 0 : selectorComputationProperty.value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if ((selectorComputation == null ? void 0 : selectorComputation.type) === `FunctionExpression` || (selectorComputation == null ? void 0 : selectorComputation.type) === `ArrowFunctionExpression`) {
|
|
170
|
+
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
|
|
171
|
+
let awaited;
|
|
172
|
+
let awaitNode;
|
|
173
|
+
walk(selectorComputation, (n, depth) => {
|
|
174
|
+
if (typeof awaited === `number`) {
|
|
175
|
+
if (awaited > depth) {
|
|
176
|
+
awaited = void 0;
|
|
177
|
+
awaitNode = void 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
switch (n.type) {
|
|
181
|
+
case `AwaitExpression`:
|
|
182
|
+
awaited = depth;
|
|
183
|
+
awaitNode = n;
|
|
184
|
+
break;
|
|
185
|
+
case `CallExpression`:
|
|
186
|
+
if (awaitNode) {
|
|
187
|
+
let willReport = false;
|
|
188
|
+
switch (n.callee.type) {
|
|
189
|
+
case `MemberExpression`:
|
|
190
|
+
if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `get`) {
|
|
191
|
+
willReport = true;
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
case `Identifier`:
|
|
195
|
+
if (n.callee.name === `get`) {
|
|
196
|
+
willReport = true;
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
if (willReport) {
|
|
201
|
+
context.report({
|
|
202
|
+
node: awaitNode,
|
|
203
|
+
message: `Using await before calling the 'get' transactor is not allowed.`
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// eslint-plugin/src/index.ts
|
|
216
|
+
var src_default = {
|
|
217
|
+
rules: {
|
|
218
|
+
"explicit-state-types": explicitStateTypes,
|
|
219
|
+
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
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,12 @@
|
|
|
1
|
+
import type { ESLint } from "eslint"
|
|
2
|
+
|
|
3
|
+
import * as Rules from "./rules"
|
|
4
|
+
|
|
5
|
+
export { Rules }
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
rules: {
|
|
9
|
+
"explicit-state-types": Rules.explicitStateTypes as any,
|
|
10
|
+
"synchronous-selector-dependencies": Rules.synchronousSelectorDependencies,
|
|
11
|
+
},
|
|
12
|
+
} satisfies ESLint.Plugin
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ESLintUtils } from "@typescript-eslint/utils"
|
|
2
|
+
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator(
|
|
4
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
const STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`]
|
|
8
|
+
|
|
9
|
+
export const explicitStateTypes = createRule({
|
|
10
|
+
name: `explicit-state-types`,
|
|
11
|
+
meta: {
|
|
12
|
+
type: `problem`,
|
|
13
|
+
docs: {
|
|
14
|
+
description: `State declarations must have generic type arguments directly passed to them`,
|
|
15
|
+
},
|
|
16
|
+
messages: {
|
|
17
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`,
|
|
18
|
+
},
|
|
19
|
+
schema: [], // no options
|
|
20
|
+
},
|
|
21
|
+
defaultOptions: [],
|
|
22
|
+
create(context) {
|
|
23
|
+
return {
|
|
24
|
+
CallExpression(node) {
|
|
25
|
+
const { callee } = node
|
|
26
|
+
switch (callee.type) {
|
|
27
|
+
case `Identifier`: {
|
|
28
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
29
|
+
if (!node.typeArguments) {
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
messageId: `noTypeArgument`,
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
break
|
|
37
|
+
}
|
|
38
|
+
case `MemberExpression`: {
|
|
39
|
+
if (
|
|
40
|
+
callee.property.type === `Identifier` &&
|
|
41
|
+
STATE_FUNCTIONS.includes(callee.property.name)
|
|
42
|
+
) {
|
|
43
|
+
if (!node.typeArguments) {
|
|
44
|
+
context.report({
|
|
45
|
+
node,
|
|
46
|
+
messageId: `noTypeArgument`,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
})
|