Fix a bunch of eslint warnings

This commit is contained in:
Aria Minaei 2022-02-23 22:53:39 +01:00
parent 078fa7a849
commit aec6b2a251
17 changed files with 49 additions and 53 deletions

View file

@ -30,7 +30,7 @@ export interface IdentityDerivationProvider {
/** /**
* Returns a derivation of the value at the provided path. * 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> getIdentityDerivation(path: Array<string | number>): IDerivation<unknown>
} }
@ -139,7 +139,7 @@ export default class Atom<State extends {}>
/** /**
* Sets the state of the atom. * 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) { setState(newState: State) {
const oldState = this._currentState const oldState = this._currentState
@ -177,8 +177,8 @@ export default class Atom<State extends {}>
* someAtom.getIn(['a']) // 2 * someAtom.getIn(['a']) // 2
* ``` * ```
* *
* @param path The path to call the reducer at. * @param path - The path to call the reducer at.
* @param reducer The function to use for creating the new state. * @param reducer - The function to use for creating the new state.
*/ */
// TODO: Why is this a property and not a method? // TODO: Why is this a property and not a method?
reduceState: PathBasedReducer<State, State> = ( 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. * 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> { getIdentityDerivation(path: Array<string | number>): IDerivation<unknown> {
return new DerivationFromSource<$IntentionalAny>( 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 * Returns a derivation of the value at the provided pointer. Derivations are
* cached per pointer. * 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>>( export const valueDerivation = <P extends PointerType<$IntentionalAny>>(
pointer: P, pointer: P,
@ -297,7 +297,7 @@ function isIdentityChangeProvider(
* For pointers, the value is returned by first creating a derivation, so it is * For pointers, the value is returned by first creating a derivation, so it is
* reactive e.g. when used in a `prism`. * 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>( export const val = <P>(
pointerOrDerivationOrPlainValue: P, pointerOrDerivationOrPlainValue: P,

View file

@ -9,7 +9,7 @@ export interface IBox<V> {
/** /**
* Sets the value of the Box. * 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 set(v: V): void
@ -43,7 +43,7 @@ export default class Box<V> implements IBox<V> {
private _emitter = new Emitter<V>() private _emitter = new Emitter<V>()
/** /**
* @param _value The initial value of the Box. * @param _value - The initial value of the Box.
*/ */
constructor( constructor(
/** /**
@ -60,7 +60,7 @@ export default class Box<V> implements IBox<V> {
/** /**
* Sets the value of the Box. * 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) { set(v: V) {
if (v === this._value) return if (v === this._value) return

View file

@ -36,7 +36,7 @@ export default class PointerProxy<O extends {}>
/** /**
* Sets the underlying pointer. * Sets the underlying pointer.
* @param p The pointer to be proxied. * @param p - The pointer to be proxied.
*/ */
setPointer(p: Pointer<O>) { setPointer(p: Pointer<O>) {
this._currentPointerBox.set(p) 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. * 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>) { getIdentityDerivation(path: Array<string | number>) {
return this._currentPointerBox.derivation.flatMap((p) => { return this._currentPointerBox.derivation.flatMap((p) => {

View file

@ -26,7 +26,7 @@ export default class Ticker {
* Note that `fn` will be added to a `Set()`. Which means, if you call `onThisOrNextTick(fn)` * 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. * 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 * @see offThisOrNextTick
*/ */
@ -37,7 +37,7 @@ export default class Ticker {
/** /**
* Registers a side effect to be called on the next tick. * 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 onThisOrNextTick
* @see offNextTick * @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. * 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 * @see onThisOrNextTick
*/ */
@ -60,7 +60,7 @@ export default class Ticker {
/** /**
* De-registers a fn to be called on the next tick. * 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 * @see onNextTick
*/ */
@ -81,7 +81,7 @@ export default class Ticker {
/** /**
* Triggers a tick which starts executing the callbacks scheduled for this tick. * 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 onThisOrNextTick
* @see onNextTick * @see onNextTick

View file

@ -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 * Convenience method that taps (subscribes to) the derivation using `this.changes(ticker).tap(fn)` and immediately calls
* the callback with the current value. * the callback with the current value.
* *
* @param ticker The ticker to use for batching. * @param ticker - The ticker to use for batching.
* @param fn The callback to call on update. * @param fn - The callback to call on update.
* *
* @see changes * @see changes
*/ */
@ -122,7 +122,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
/** /**
* Add a derivation as a dependent of this derivation. * 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 * @see removeDependent
*/ */
@ -139,7 +139,7 @@ export default abstract class AbstractDerivation<V> implements IDerivation<V> {
/** /**
* Remove a derivation as a dependent of this derivation. * 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 * @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 * Creates a new derivation from this derivation using the provided mapping function. The new derivation's value will be
* `fn(thisDerivation.getValue())`. * `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> { map<T>(fn: (v: V) => T): IDerivation<T> {
return map(this, fn) 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() * 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>( flatMap<R>(
fn: (v: V) => R, fn: (v: V) => R,

View file

@ -7,7 +7,7 @@ export default class ConstantDerivation<V> extends AbstractDerivation<V> {
private readonly _v: V private readonly _v: V
/** /**
* @param v The value of the derivation. * @param v - The value of the derivation.
*/ */
constructor(v: V) { constructor(v: V) {
super() super()

View file

@ -15,8 +15,8 @@ export default class DerivationEmitter<V> {
private _hadTappers: boolean private _hadTappers: boolean
/** /**
* @param derivation The derivation to emit events for. * @param derivation - The derivation to emit events for.
* @param ticker The ticker to use to batch events. * @param ticker - The ticker to use to batch events.
*/ */
constructor(derivation: IDerivation<V>, ticker: Ticker) { constructor(derivation: IDerivation<V>, ticker: Ticker) {
this._derivation = derivation this._derivation = derivation

View file

@ -12,8 +12,8 @@ export default class DerivationFromSource<V> extends AbstractDerivation<V> {
private _hasCachedValue: boolean private _hasCachedValue: boolean
/** /**
* @param _tapToSource A function that takes a listener and subscribes it to the underlying 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. * @param _getValueFromSource - A function that returns the current value of the data source.
*/ */
constructor( constructor(
private readonly _tapToSource: (listener: (newValue: V) => void) => VoidFn, private readonly _tapToSource: (listener: (newValue: V) => void) => VoidFn,

View file

@ -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 * Convenience method that taps (subscribes to) the derivation using `this.changes(ticker).tap(fn)` and immediately calls
* the callback with the current value. * the callback with the current value.
* *
* @param ticker The ticker to use for batching. * @param ticker - The ticker to use for batching.
* @param fn The callback to call on update. * @param fn - The callback to call on update.
* *
* @see changes * @see changes
*/ */
@ -50,7 +50,7 @@ export interface IDerivation<V> {
/** /**
* Add a derivation as a dependent of this derivation. * 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 * @see removeDependent
*/ */
@ -59,7 +59,7 @@ export interface IDerivation<V> {
/** /**
* Remove a derivation as a dependent of this derivation. * 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 * @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 * Creates a new derivation from this derivation using the provided mapping function. The new derivation's value will be
* `fn(thisDerivation.getValue())`. * `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> 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() * 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>( flatMap<R>(
fn: (v: V) => R, fn: (v: V) => R,

View file

@ -1,5 +1,4 @@
/** /*
* // eslint-disable-next-line
* @jest-environment jsdom * @jest-environment jsdom
*/ */
import Atom from '../Atom' import Atom from '../Atom'

View file

@ -1,5 +1,4 @@
/** /*
// eslint-disable-next-line
* @jest-environment jsdom * @jest-environment jsdom
*/ */
import Atom, {val} from '../../Atom' import Atom, {val} from '../../Atom'

View file

@ -338,7 +338,7 @@ type IPrismFn = {
* Creates a derivation from the passed function that adds all derivations referenced * Creates a derivation from the passed function that adds all derivations referenced
* in it as dependencies, and reruns the function when these change. * 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) => { const prism: IPrismFn = (fn) => {
return new PrismDerivation(fn) return new PrismDerivation(fn)

View file

@ -1,5 +1,4 @@
/** /*
// eslint-disable-next-line
* @jest-environment jsdom * @jest-environment jsdom
*/ */
import Atom, {val} from './Atom' import Atom, {val} from './Atom'

View file

@ -80,7 +80,7 @@ const handler = {
* Returns the metadata associated with the pointer. Usually the root object and * Returns the metadata associated with the pointer. Usually the root object and
* the path. * the path.
* *
* @param p The pointer. * @param p - The pointer.
*/ */
export const getPointerMeta = ( export const getPointerMeta = (
p: Pointer<$IntentionalAny> | Pointer<{}> | Pointer<unknown>, p: Pointer<$IntentionalAny> | Pointer<{}> | Pointer<unknown>,
@ -100,7 +100,7 @@ export const getPointerMeta = (
* const {root, path} = getPointerParts(pointer) * 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. * @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 - The pointer parameters.
* @param args.root The {@link Atom} the pointer applies to. * @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.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>}) { function pointer<O>(args: {root: {}; path?: Array<string | number>}) {
const meta: PointerMeta = { const meta: PointerMeta = {

View file

@ -49,7 +49,7 @@ export default class Emitter<V> {
/** /**
* Emit a value. * Emit a value.
* *
* @param payload The value to be emitted. * @param payload - The value to be emitted.
*/ */
emit(payload: V) { emit(payload: V) {
this._tappers.forEach((cb) => { this._tappers.forEach((cb) => {
@ -69,13 +69,13 @@ export default class Emitter<V> {
* *
* @callback Emitter~numberOfTappersChangeHandler * @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. * 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) { onNumberOfTappersChange(cb: (n: number) => void) {
this._onNumberOfTappersChangeListener = cb this._onNumberOfTappersChangeListener = cb

View file

@ -61,7 +61,7 @@ export default class Tappable<V> {
/** /**
* Tap (subscribe to) the data source. * 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 { tap(cb: Listener<V>): Untap {
const tapperId = this._lastTapperId++ const tapperId = this._lastTapperId++

View file

@ -1,5 +1,4 @@
/** /*
// eslint-disable-next-line tsdoc/syntax
* @jest-environment jsdom * @jest-environment jsdom
*/ */
import {setupTestSheet} from '@theatre/shared/testUtils' import {setupTestSheet} from '@theatre/shared/testUtils'