eslint-plugin-effector 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -6
- package/config/react.js +5 -0
- package/config/recommended.js +2 -0
- package/config/scope.js +5 -0
- package/index.js +7 -0
- package/package.json +4 -1
- package/rules/enforce-effect-naming-convention/enforce-effect-naming-convention.js +16 -17
- package/rules/enforce-gate-naming-convention/enforce-gate-naming-convention.js +114 -0
- package/rules/enforce-store-naming-convention/enforce-store-naming-convention.js +25 -25
- package/rules/keep-options-order/config.js +3 -0
- package/rules/keep-options-order/keep-options-order.js +107 -0
- package/rules/no-ambiguity-target/no-ambiguity-target.js +38 -39
- package/rules/no-duplicate-on/no-duplicate-on.js +137 -0
- package/rules/no-forward/no-forward.js +77 -0
- package/rules/no-getState/no-getState.js +9 -36
- package/rules/no-unnecessary-combination/no-unnecessary-combination.js +39 -45
- package/rules/no-unnecessary-duplication/no-unnecessary-duplication.js +41 -45
- package/rules/no-useless-methods/no-useless-methods.js +56 -57
- package/rules/no-watch/no-watch.js +6 -12
- package/rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.js +31 -13
- package/rules/strict-effect-handlers/strict-effect-handlers.js +76 -0
- package/utils/builders.js +19 -0
- package/utils/extract-imported-from.js +10 -0
- package/utils/get-corrected-store-name.js +12 -14
- package/utils/get-nested-object-name.js +18 -0
- package/utils/get-store-name-convention.js +3 -3
- package/utils/is.js +30 -0
- package/utils/method.js +23 -0
- package/utils/naming.js +47 -0
- package/utils/node-type-is.js +59 -0
- package/utils/replace-by-sample.js +66 -0
- package/utils/validate-store-name-convention.js +7 -7
- package/rules/enforce-effect-naming-convention/enforce-effect-naming-convention.md +0 -11
- package/rules/enforce-store-naming-convention/enforce-store-naming-convention.md +0 -44
- package/rules/no-ambiguity-target/no-ambiguity-target.md +0 -12
- package/rules/no-getState/no-getState.md +0 -20
- package/rules/no-unnecessary-combination/no-unnecessary-combination.md +0 -14
- package/rules/no-unnecessary-duplication/no-unnecessary-duplication.md +0 -32
- package/rules/no-useless-methods/no-useless-methods.md +0 -14
- package/rules/no-watch/no-watch.md +0 -42
- package/rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.md +0 -27
- package/rules/tsconfig.json +0 -9
- package/utils/extract-imported-from-effector.js +0 -8
- package/utils/is-store-name-valid.js +0 -22
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# effector/no-watch
|
|
2
|
-
|
|
3
|
-
Method `.watch` leads to imperative code. Try replacing it with operators (`forward`, `sample`, etc) or use the `target` parameter of the operators.
|
|
4
|
-
|
|
5
|
-
> Caution! This rule only works on projects using TypeScript.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
const myFx = createEffect();
|
|
9
|
-
const myEvent = createEvent();
|
|
10
|
-
const $awesome = createStore();
|
|
11
|
-
|
|
12
|
-
// 👍 good solutions
|
|
13
|
-
forward({
|
|
14
|
-
from: myFx.finally,
|
|
15
|
-
to: myEvent,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
guard({
|
|
19
|
-
clock: myEvent,
|
|
20
|
-
filter: Boolean,
|
|
21
|
-
target: myFx,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
sample({
|
|
25
|
-
from: $awesome.updates,
|
|
26
|
-
fn: identity,
|
|
27
|
-
to: myEvent,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// 👎 bad solutions
|
|
31
|
-
myFx.finally.watch(myEvent);
|
|
32
|
-
|
|
33
|
-
myEvent.watch((payload) => {
|
|
34
|
-
if (Boolean(payload)) {
|
|
35
|
-
myFx(payload);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
$awesome.updates.watch((data) => {
|
|
40
|
-
myEvent(identity(data));
|
|
41
|
-
});
|
|
42
|
-
```
|
package/rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# effector/prefer-sample-over-forward-with-mapping
|
|
2
|
-
|
|
3
|
-
Prefer `sample` over `forward` with `.map`/`.prepend`.
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
const eventOne = createEvent();
|
|
7
|
-
const eventTwo = createEvent();
|
|
8
|
-
|
|
9
|
-
// 👎 looks weird
|
|
10
|
-
forward({
|
|
11
|
-
from: eventOne.map((items) => items.length),
|
|
12
|
-
to: eventTwo,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// 👎 weird too
|
|
16
|
-
forward({
|
|
17
|
-
from: eventOne,
|
|
18
|
-
to: eventTwo.prepend((items) => items.length),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// 👍 better
|
|
22
|
-
sample({
|
|
23
|
-
source: eventOne,
|
|
24
|
-
fn: (items) => items.length,
|
|
25
|
-
target: eventTwo,
|
|
26
|
-
});
|
|
27
|
-
```
|
package/rules/tsconfig.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
function extractImportedFromEffector(importedFromEffector, node) {
|
|
2
|
-
if (node.source.value === "effector") {
|
|
3
|
-
for (const s of node.specifiers) {
|
|
4
|
-
importedFromEffector.set(s.imported.name, s.local.name);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
module.exports = { extractImportedFromEffector };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const { getStoreNameConvention } = require("./get-store-name-convention");
|
|
2
|
-
|
|
3
|
-
function isStoreNameValid(storeName, context) {
|
|
4
|
-
const storeNameConvention = getStoreNameConvention(context);
|
|
5
|
-
|
|
6
|
-
// validate edge case
|
|
7
|
-
if (storeName?.startsWith("$") && storeName?.endsWith("$")) {
|
|
8
|
-
return false
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (storeNameConvention === "prefix" && storeName?.startsWith("$")) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (storeNameConvention === "postfix" && storeName?.endsWith("$")) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = { isStoreNameValid };
|