eslint-plugin-mobx 0.0.0 → 0.0.5
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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +67 -33
- package/dist/index.js +505 -0
- package/package.json +50 -32
- package/src/exhaustive-make-observable.js +111 -0
- package/src/index.js +29 -0
- package/src/missing-make-observable.js +70 -0
- package/src/missing-observer.js +63 -0
- package/src/no-anonymous-observer.js +57 -0
- package/src/unconditional-make-observable.js +44 -0
- package/src/utils.js +29 -0
- package/.editorconfig +0 -15
- package/.eslintrc.js +0 -35
- package/husky.config.js +0 -5
- package/lint-staged.config.js +0 -4
- package/package-lock.json +0 -1293
- package/prettier.config.js +0 -7
- package/todo-rules.md +0 -115
package/prettier.config.js
DELETED
package/todo-rules.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
https://mobx.js.org/refguide/api.html#configure
|
|
2
|
-
|
|
3
|
-
### mobx/array-buffer: number
|
|
4
|
-
|
|
5
|
-
Increases the default created size of observable arrays to arrayBuffer, if the maximum size isn't yet there.
|
|
6
|
-
|
|
7
|
-
Observable arrays lazily create getters on members of ObservableArray.prototype starting at 0. This will create the members from 0 to arrayBuffer if they don't yet exist. Use arrayBuffer if you know you'll have a common minimum array size and don't want to risk first creating those getters in hot code paths. See also observable.
|
|
8
|
-
|
|
9
|
-
### mobx/computed-requires-reaction: boolean
|
|
10
|
-
|
|
11
|
-
Forbids the access of any unobserved computed value. Use this if you want to check whether you are using computed properties without a reactive context.
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
configure({ computedRequiresReaction: true })
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### mobx/observable-requires-reaction: boolean
|
|
18
|
-
|
|
19
|
-
Warns about any unobserved observable access. Use this if you want to check whether you are using observables without a reactive context (eg not inside an autorun, action, or react component without observer wrapping).
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
configure({ observableRequiresReaction: true })
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### mobx/reaction-requires-observable: boolean
|
|
26
|
-
|
|
27
|
-
Warns when a reaction (eg autorun) is created without any observable access. Use this to check whether you are unneededly wrapping react components with observer, or to find possible related bugs.
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
configure({ reactionRequiresObservable: true })
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### mobx/computed-configurable: boolean
|
|
34
|
-
|
|
35
|
-
Allows overwriting computed values. This is useful for testing purposes only. Don't enable this on production as it can cause memory-leaks.
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
configure({ computedConfigurable: true })
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### mobx/disable-error-boundaries: boolean
|
|
42
|
-
|
|
43
|
-
By default, MobX will catch and rethrow exceptions happening in your code to make sure that a reaction in one exception does not prevent the scheduled execution of other, possibly unrelated, reactions. This means exceptions are not propagated back to the original causing code and therefore you won't be able to catch them using try/catch.
|
|
44
|
-
|
|
45
|
-
There may be times when you want to catch those errors, for example when unit testing your reactions. You can disable this behaviour using disableErrorBoundaries.
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
configure({ disableErrorBoundaries: true })
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Please note that MobX won't recover from errors when using this configuration. For that reason, you may need to use \_resetGlobalState after each exception. Example:
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
configure({ disableErrorBoundaries: true })
|
|
55
|
-
|
|
56
|
-
test("Throw if age is negative", () => {
|
|
57
|
-
expect(() => {
|
|
58
|
-
const age = observable.box(10)
|
|
59
|
-
autorun(() => {
|
|
60
|
-
if (age.get() < 0) throw new Error("Age should not be negative")
|
|
61
|
-
})
|
|
62
|
-
age.set(-1)
|
|
63
|
-
}).toThrow()
|
|
64
|
-
_resetGlobalState() // Needed after each exception
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
> Prior to MobX 4, \_resetGlobalState was extras.resetGlobalState.
|
|
69
|
-
|
|
70
|
-
### mobx/enforce-actions
|
|
71
|
-
|
|
72
|
-
Also known as "strict mode". In strict mode, it is not allowed to change any state outside of an action. Acceputed vales:
|
|
73
|
-
|
|
74
|
-
`"never"` (default): State can be modified from anywhere
|
|
75
|
-
`"observed"`: All state that is observed somewhere needs to be changed through actions. This is the recommended strictness mode in non-trivial applications.
|
|
76
|
-
`"always"`: State always needs be updated (which in practice also includes creation) in actions.
|
|
77
|
-
|
|
78
|
-
### mobx/isolate-global-state: boolean
|
|
79
|
-
|
|
80
|
-
Isolates the global state of MobX, when there are multiple instances of MobX in the same environment. This is useful when you have an encapsulated library that is using MobX, living in the same page as the app that is using MobX. The reactivity inside the library will remain self-contained when you call configure({isolateGlobalState: true}) inside the library.
|
|
81
|
-
|
|
82
|
-
Without this options, if multiple MobX instances are active, the internal state will be shared. The benefit is that observables from both instances work together, the downside is that the MobX versions have to match.
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
configure({ isolateGlobalState: true })
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### mobx/reaction-scheduler: (f: () => void) => void
|
|
89
|
-
|
|
90
|
-
Sets a new function that executes all MobX reactions. By default reactionScheduler just runs the f reaction without any other behavior. This can be useful for basic debugging, or slowing down reactions to visualize application updates.
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
configure({
|
|
94
|
-
reactionScheduler: (f): void => {
|
|
95
|
-
console.log("Running an event after a delay:", f)
|
|
96
|
-
setTimeout(f, 100)
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### mobx/prefer-flow
|
|
102
|
-
|
|
103
|
-
https://mobx.js.org/refguide/api.html#flow
|
|
104
|
-
|
|
105
|
-
### mobx/prefer-run-in-action
|
|
106
|
-
|
|
107
|
-
### mobx/enforce-action-name
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
action('name', () => {})()
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### mobx/sort-class-params
|
|
114
|
-
|
|
115
|
-
Enforces observable, action, computed sorting
|