Fix a bunch of eslint warnings
This commit is contained in:
parent
078fa7a849
commit
aec6b2a251
17 changed files with 49 additions and 53 deletions
|
@ -30,7 +30,7 @@ export interface IdentityDerivationProvider {
|
|||
/**
|
||||
* Returns a derivation of the value at the provided path.
|
||||
*
|
||||
* @param path The path to create the derivation at.
|
||||
* @param path - The path to create the derivation at.
|
||||
*/
|
||||
getIdentityDerivation(path: Array<string | number>): IDerivation<unknown>
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ export default class Atom<State extends {}>
|
|||
/**
|
||||
* Sets the state of the atom.
|
||||
*
|
||||
* @param newState The new state of the atom.
|
||||
* @param newState - The new state of the atom.
|
||||
*/
|
||||
setState(newState: State) {
|
||||
const oldState = this._currentState
|
||||
|
@ -177,8 +177,8 @@ export default class Atom<State extends {}>
|
|||
* someAtom.getIn(['a']) // 2
|
||||
* ```
|
||||
*
|
||||
* @param path The path to call the reducer at.
|
||||
* @param reducer The function to use for creating the new state.
|
||||
* @param path - The path to call the reducer at.
|
||||
* @param reducer - The function to use for creating the new state.
|
||||
*/
|
||||
// TODO: Why is this a property and not a method?
|
||||
reduceState: PathBasedReducer<State, State> = (
|
||||
|
@ -240,7 +240,7 @@ export default class Atom<State extends {}>
|
|||
/**
|
||||
* Returns a new derivation of the value at the provided path.
|
||||
*
|
||||
* @param path The path to create the derivation at.
|
||||
* @param path - The path to create the derivation at.
|
||||
*/
|
||||
getIdentityDerivation(path: Array<string | number>): IDerivation<unknown> {
|
||||
return new DerivationFromSource<$IntentionalAny>(
|
||||
|
@ -256,7 +256,7 @@ const identityDerivationWeakMap = new WeakMap<{}, IDerivation<unknown>>()
|
|||
* Returns a derivation of the value at the provided pointer. Derivations are
|
||||
* cached per pointer.
|
||||
*
|
||||
* @param pointer The pointer to return the derivation at.
|
||||
* @param pointer - The pointer to return the derivation at.
|
||||
*/
|
||||
export const valueDerivation = <P extends PointerType<$IntentionalAny>>(
|
||||
pointer: P,
|
||||
|
@ -297,7 +297,7 @@ function isIdentityChangeProvider(
|
|||
* For pointers, the value is returned by first creating a derivation, so it is
|
||||
* reactive e.g. when used in a `prism`.
|
||||
*
|
||||
* @param pointerOrDerivationOrPlainValue The argument to return a value from.
|
||||
* @param pointerOrDerivationOrPlainValue - The argument to return a value from.
|
||||
*/
|
||||
export const val = <P>(
|
||||
pointerOrDerivationOrPlainValue: P,
|
||||
|
|
|
@ -9,7 +9,7 @@ export interface IBox<V> {
|
|||
/**
|
||||
* Sets the value of the Box.
|
||||
*
|
||||
* @param v The value to update the Box with.
|
||||
* @param v - The value to update the Box with.
|
||||
*/
|
||||
|
||||
set(v: V): void
|
||||
|
@ -43,7 +43,7 @@ export default class Box<V> implements IBox<V> {
|
|||
private _emitter = new Emitter<V>()
|
||||
|
||||
/**
|
||||
* @param _value The initial value of the Box.
|
||||
* @param _value - The initial value of the Box.
|
||||
*/
|
||||
constructor(
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ export default class Box<V> implements IBox<V> {
|
|||
/**
|
||||
* Sets the value of the Box.
|
||||
*
|
||||
* @param v The value to update the Box with.
|
||||
* @param v - The value to update the Box with.
|
||||
*/
|
||||
set(v: V) {
|
||||
if (v === this._value) return
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class PointerProxy<O extends {}>
|
|||
|
||||
/**
|
||||
* Sets the underlying pointer.
|
||||
* @param p The pointer to be proxied.
|
||||
* @param p - The pointer to be proxied.
|
||||
*/
|
||||
setPointer(p: Pointer<O>) {
|
||||
this._currentPointerBox.set(p)
|
||||
|
@ -45,7 +45,7 @@ export default class PointerProxy<O extends {}>
|
|||
/**
|
||||
* Returns a derivation of the value at the provided sub-path of the proxied pointer.
|
||||
*
|
||||
* @param path The path to create the derivation at.
|
||||
* @param path - The path to create the derivation at.
|
||||
*/
|
||||
getIdentityDerivation(path: Array<string | number>) {
|
||||
return this._currentPointerBox.derivation.flatMap((p) => {
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class Ticker {
|
|||
* Note that `fn` will be added to a `Set()`. Which means, if you call `onThisOrNextTick(fn)`
|
||||
* with the same fn twice in a single tick, it'll only run once.
|
||||
*
|
||||
* @param fn The function to be registered.
|
||||
* @param fn - The function to be registered.
|
||||
*
|
||||
* @see offThisOrNextTick
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ export default class Ticker {
|
|||
/**
|
||||
* Registers a side effect to be called on the next tick.
|
||||
*
|
||||
* @param fn The function to be registered.
|
||||
* @param fn - The function to be registered.
|
||||
*
|
||||
* @see onThisOrNextTick
|
||||
* @see offNextTick
|
||||
|
@ -49,7 +49,7 @@ export default class Ticker {
|
|||
/**
|
||||
* De-registers a fn to be called either on this tick or the next tick.
|
||||
*
|
||||
* @param fn The function to be de-registered.
|
||||
* @param fn - The function to be de-registered.
|
||||
*
|
||||
* @see onThisOrNextTick
|
||||
*/
|
||||
|
@ -60,7 +60,7 @@ export default class Ticker {
|
|||
/**
|
||||
* De-registers a fn to be called on the next tick.
|
||||
*
|
||||
* @param fn The function to be de-registered.
|
||||
* @param fn - The function to be de-registered.
|
||||
*
|
||||
* @see onNextTick
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ export default class Ticker {
|
|||
/**
|
||||
* Triggers a tick which starts executing the callbacks scheduled for this tick.
|
||||
*
|
||||
* @param t The time at the tick.
|
||||
* @param t - The time at the tick.
|
||||
*
|
||||
* @see onThisOrNextTick
|
||||
* @see onNextTick
|
||||
|
|
|
@ -108,8 +108,8 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
|||
* Convenience method that taps (subscribes to) the derivation using `this.changes(ticker).tap(fn)` and immediately calls
|
||||
* the callback with the current value.
|
||||
*
|
||||
* @param ticker The ticker to use for batching.
|
||||
* @param fn The callback to call on update.
|
||||
* @param ticker - The ticker to use for batching.
|
||||
* @param fn - The callback to call on update.
|
||||
*
|
||||
* @see changes
|
||||
*/
|
||||
|
@ -122,7 +122,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
|||
/**
|
||||
* Add a derivation as a dependent of this derivation.
|
||||
*
|
||||
* @param d The derivation to be made a dependent of this derivation.
|
||||
* @param d - The derivation to be made a dependent of this derivation.
|
||||
*
|
||||
* @see removeDependent
|
||||
*/
|
||||
|
@ -139,7 +139,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
|||
/**
|
||||
* Remove a derivation as a dependent of this derivation.
|
||||
*
|
||||
* @param d The derivation to be removed from as a dependent of this derivation.
|
||||
* @param d - The derivation to be removed from as a dependent of this derivation.
|
||||
*
|
||||
* @see addDependent
|
||||
*/
|
||||
|
@ -229,7 +229,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
|||
* Creates a new derivation from this derivation using the provided mapping function. The new derivation's value will be
|
||||
* `fn(thisDerivation.getValue())`.
|
||||
*
|
||||
* @param fn The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
* @param fn - The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
*/
|
||||
map<T>(fn: (v: V) => T): IDerivation<T> {
|
||||
return map(this, fn)
|
||||
|
@ -248,7 +248,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
|
|||
* new Box(3).derivation.flatMap((value) => new Box(value).derivation).getValue()
|
||||
* ```
|
||||
*
|
||||
* @param fn The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
* @param fn - The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
*/
|
||||
flatMap<R>(
|
||||
fn: (v: V) => R,
|
||||
|
|
|
@ -7,7 +7,7 @@ export default class ConstantDerivation<V> extends AbstractDerivation<V> {
|
|||
private readonly _v: V
|
||||
|
||||
/**
|
||||
* @param v The value of the derivation.
|
||||
* @param v - The value of the derivation.
|
||||
*/
|
||||
constructor(v: V) {
|
||||
super()
|
||||
|
|
|
@ -15,8 +15,8 @@ export default class DerivationEmitter<V> {
|
|||
private _hadTappers: boolean
|
||||
|
||||
/**
|
||||
* @param derivation The derivation to emit events for.
|
||||
* @param ticker The ticker to use to batch events.
|
||||
* @param derivation - The derivation to emit events for.
|
||||
* @param ticker - The ticker to use to batch events.
|
||||
*/
|
||||
constructor(derivation: IDerivation<V>, ticker: Ticker) {
|
||||
this._derivation = derivation
|
||||
|
|
|
@ -12,8 +12,8 @@ export default class DerivationFromSource<V> extends AbstractDerivation<V> {
|
|||
private _hasCachedValue: boolean
|
||||
|
||||
/**
|
||||
* @param _tapToSource A function that takes a listener and subscribes it to the underlying data source.
|
||||
* @param _getValueFromSource A function that returns the current value of the data source.
|
||||
* @param _tapToSource - A function that takes a listener and subscribes it to the underlying data source.
|
||||
* @param _getValueFromSource - A function that returns the current value of the data source.
|
||||
*/
|
||||
constructor(
|
||||
private readonly _tapToSource: (listener: (newValue: V) => void) => VoidFn,
|
||||
|
|
|
@ -40,8 +40,8 @@ export interface IDerivation<V> {
|
|||
* Convenience method that taps (subscribes to) the derivation using `this.changes(ticker).tap(fn)` and immediately calls
|
||||
* the callback with the current value.
|
||||
*
|
||||
* @param ticker The ticker to use for batching.
|
||||
* @param fn The callback to call on update.
|
||||
* @param ticker - The ticker to use for batching.
|
||||
* @param fn - The callback to call on update.
|
||||
*
|
||||
* @see changes
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ export interface IDerivation<V> {
|
|||
/**
|
||||
* Add a derivation as a dependent of this derivation.
|
||||
*
|
||||
* @param d The derivation to be made a dependent of this derivation.
|
||||
* @param d - The derivation to be made a dependent of this derivation.
|
||||
*
|
||||
* @see removeDependent
|
||||
*/
|
||||
|
@ -59,7 +59,7 @@ export interface IDerivation<V> {
|
|||
/**
|
||||
* Remove a derivation as a dependent of this derivation.
|
||||
*
|
||||
* @param d The derivation to be removed from as a dependent of this derivation.
|
||||
* @param d - The derivation to be removed from as a dependent of this derivation.
|
||||
*
|
||||
* @see addDependent
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ export interface IDerivation<V> {
|
|||
* Creates a new derivation from this derivation using the provided mapping function. The new derivation's value will be
|
||||
* `fn(thisDerivation.getValue())`.
|
||||
*
|
||||
* @param fn The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
* @param fn - The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
*/
|
||||
map<T>(fn: (v: V) => T): IDerivation<T>
|
||||
|
||||
|
@ -91,7 +91,7 @@ export interface IDerivation<V> {
|
|||
* new Box(3).derivation.flatMap((value) => new Box(value).derivation).getValue()
|
||||
* ```
|
||||
*
|
||||
* @param fn The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
* @param fn - The mapping function to use. Note: it accepts a plain value, not a derivation.
|
||||
*/
|
||||
flatMap<R>(
|
||||
fn: (v: V) => R,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
* // eslint-disable-next-line
|
||||
/*
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import Atom from '../Atom'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
// eslint-disable-next-line
|
||||
/*
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import Atom, {val} from '../../Atom'
|
||||
|
|
|
@ -338,7 +338,7 @@ type IPrismFn = {
|
|||
* Creates a derivation from the passed function that adds all derivations referenced
|
||||
* in it as dependencies, and reruns the function when these change.
|
||||
*
|
||||
* @param fn The function to rerun when the derivations referenced in it change.
|
||||
* @param fn - The function to rerun when the derivations referenced in it change.
|
||||
*/
|
||||
const prism: IPrismFn = (fn) => {
|
||||
return new PrismDerivation(fn)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
// eslint-disable-next-line
|
||||
/*
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import Atom, {val} from './Atom'
|
||||
|
|
|
@ -80,7 +80,7 @@ const handler = {
|
|||
* Returns the metadata associated with the pointer. Usually the root object and
|
||||
* the path.
|
||||
*
|
||||
* @param p The pointer.
|
||||
* @param p - The pointer.
|
||||
*/
|
||||
export const getPointerMeta = (
|
||||
p: Pointer<$IntentionalAny> | Pointer<{}> | Pointer<unknown>,
|
||||
|
@ -100,7 +100,7 @@ export const getPointerMeta = (
|
|||
* const {root, path} = getPointerParts(pointer)
|
||||
* ```
|
||||
*
|
||||
* @param p The pointer.
|
||||
* @param p - The pointer.
|
||||
*
|
||||
* @returns An object with two properties: `root`-the root object or the pointer, and `path`-the path of the pointer. `path` is an array of the property-chain.
|
||||
*/
|
||||
|
@ -136,11 +136,11 @@ export const getPointerParts = (
|
|||
* });
|
||||
* ```
|
||||
*
|
||||
* @param args The pointer parameters.
|
||||
* @param args.root The {@link Atom} the pointer applies to.
|
||||
* @param args.path The path to the (nested) property the pointer points to.
|
||||
* @param args - The pointer parameters.
|
||||
* @param args.root - The {@link Atom} the pointer applies to.
|
||||
* @param args.path - The path to the (nested) property the pointer points to.
|
||||
*
|
||||
* @typeParam O The type of the value being pointed to.
|
||||
* @typeParam O - The type of the value being pointed to.
|
||||
*/
|
||||
function pointer<O>(args: {root: {}; path?: Array<string | number>}) {
|
||||
const meta: PointerMeta = {
|
||||
|
|
|
@ -49,7 +49,7 @@ export default class Emitter<V> {
|
|||
/**
|
||||
* Emit a value.
|
||||
*
|
||||
* @param payload The value to be emitted.
|
||||
* @param payload - The value to be emitted.
|
||||
*/
|
||||
emit(payload: V) {
|
||||
this._tappers.forEach((cb) => {
|
||||
|
@ -69,13 +69,13 @@ export default class Emitter<V> {
|
|||
*
|
||||
* @callback Emitter~numberOfTappersChangeHandler
|
||||
*
|
||||
* @param {number} n The current number of tappers (subscribers).
|
||||
* @param {number} n - The current number of tappers (subscribers).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calls callback when the number of tappers (subscribers) changes.
|
||||
*
|
||||
* @param {Emitter~requestCallback} cb The function to be called.
|
||||
* @param {Emitter~requestCallback} cb - The function to be called.
|
||||
*/
|
||||
onNumberOfTappersChange(cb: (n: number) => void) {
|
||||
this._onNumberOfTappersChangeListener = cb
|
||||
|
|
|
@ -61,7 +61,7 @@ export default class Tappable<V> {
|
|||
/**
|
||||
* Tap (subscribe to) the data source.
|
||||
*
|
||||
* @param cb The callback to be called on a change.
|
||||
* @param cb - The callback to be called on a change.
|
||||
*/
|
||||
tap(cb: Listener<V>): Untap {
|
||||
const tapperId = this._lastTapperId++
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
// eslint-disable-next-line tsdoc/syntax
|
||||
/*
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import {setupTestSheet} from '@theatre/shared/testUtils'
|
||||
|
|
Loading…
Reference in a new issue