Skip to content

Commit 0795b3b

Browse files
authored
Add rule no-unnecessary-combination (#43)
* Add test cases for no-unnecessary-combination * Add basic implementation of no-unnecessary-combination * Export no-unnecessary-combination properly * Add docs of no-unnecessary-combination
1 parent 0773580 commit 0795b3b

17 files changed

+248
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ To configure individual rules:
4949
- [effector/no-ambiguity-target](rules/no-ambiguity-target/no-ambiguity-target.md)
5050
- [effector/prefer-sample-over-forward-with-mapping](rules/prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.md)
5151
- [effector/no-watch](rules/no-watch/no-watch.md)
52+
- [effector/no-unnecessary-combination](rules/no-unnecessary-combination/no-unnecessary-combination.md)
5253

5354
## Maintenance
5455

config/recommended.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ module.exports = {
88
"effector/prefer-sample-over-forward-with-mapping": "warn",
99
"effector/no-ambiguity-target": "warn",
1010
"effector/no-watch": "warn",
11+
"effector/no-unnecessary-combination": "warn",
1112
},
1213
};

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
"no-useless-methods": require("./rules/no-useless-methods/no-useless-methods"),
99
"no-ambiguity-target": require("./rules/no-ambiguity-target/no-ambiguity-target"),
1010
"no-watch": require("./rules/no-watch/no-watch"),
11+
"no-unnecessary-combination": require("./rules/no-unnecessary-combination/no-unnecessary-combination"),
1112
},
1213
configs: {
1314
recommended: require("./config/recommended"),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createEvent, createStore, forward, guard, sample } from "effector";
2+
3+
const event1 = createEvent();
4+
const event2 = createEvent();
5+
const $store1 = createStore(null);
6+
const $store2 = createStore(null);
7+
8+
sample({ clock: [event1, event2], source: [$store1, $store2] });
9+
10+
sample({ clock: event1, source: [$store1, $store2] });
11+
12+
sample({ clock: event1, source: { a: $store1, b: $store2 } });
13+
14+
guard({ clock: [event1, event2], source: $store1, filter: Boolean });
15+
16+
guard({ clock: event1, source: { a: $store1 }, filter: Boolean });
17+
18+
const otherEvent = createEvent();
19+
20+
forward({ from: [event1, event2], to: otherEvent });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { combine, createEvent, createStore, guard, merge } from "effector";
2+
3+
const $store1 = createStore(null);
4+
const $store2 = createStore(null);
5+
6+
guard({ clock: combine($store1, $store2), filter: Boolean });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { combine, createStore, sample } from "effector";
2+
3+
const $store1 = createStore(null);
4+
const $store2 = createStore(null);
5+
6+
sample({ clock: combine($store1, $store2) });
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { combine, createEvent, createStore, forward } from "effector";
2+
3+
const $store1 = createStore(null);
4+
const $store2 = createStore(null);
5+
6+
const target = createEvent();
7+
8+
forward({ from: combine($store1, $store2), to: target });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { combine, createEvent, createStore, guard, merge } from "effector";
2+
3+
const $store1 = createStore(null);
4+
const $store2 = createStore(null);
5+
6+
guard({ source: combine($store1, $store2), filter: Boolean });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { combine, createStore, sample } from "effector";
2+
3+
const $store1 = createStore(null);
4+
const $store2 = createStore(null);
5+
6+
sample({ source: combine($store1, $store2) });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createEvent, guard, merge } from "effector";
2+
3+
const event1 = createEvent();
4+
const event2 = createEvent();
5+
6+
guard({ clock: merge([event1, event2]), filter: Boolean });

0 commit comments

Comments
 (0)