eslint-plugin-react-hooks-extra
Advanced tools
Comparing version 1.5.3 to 1.5.4-beta.0
1643
dist/index.js
'use strict'; | ||
var core = require('@eslint-react/core'); | ||
require('string-ts'); | ||
var shared = require('@eslint-react/shared'); | ||
@@ -9,107 +10,83 @@ var ast = require('@eslint-react/ast'); | ||
var __defProp = Object.defineProperty; | ||
var __export = (target, all2) => { | ||
for (var name2 in all2) | ||
__defProp(target, name2, { get: all2[name2], enumerable: true }); | ||
}; | ||
// package.json | ||
var name = "eslint-plugin-react-hooks-extra"; | ||
var version = "1.5.3"; | ||
var version = "1.5.4-beta.0"; | ||
var createRule = shared.createRuleForPlugin("hooks-extra"); | ||
const createRule = shared.createRuleForPlugin("hooks-extra"); | ||
const RULE_NAME$3 = "ensure-custom-hooks-using-other-hooks"; | ||
var ensureCustomHooksUsingOtherHooks = createRule({ | ||
name: RULE_NAME$3, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce custom hooks using other hooks", | ||
requiresTypeChecking: false | ||
}, | ||
schema: [], | ||
messages: { | ||
ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS: "Custom hooks {{name}} should use other hooks" | ||
} | ||
// src/rules/ensure-custom-hooks-using-other-hooks.ts | ||
var RULE_NAME = "ensure-custom-hooks-using-other-hooks"; | ||
var ensure_custom_hooks_using_other_hooks_default = createRule({ | ||
name: RULE_NAME, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce custom hooks using other hooks", | ||
requiresTypeChecking: false | ||
}, | ||
defaultOptions: [], | ||
create (context) { | ||
const { ctx, listeners } = core.useHookCollector(); | ||
return { | ||
...listeners, | ||
"Program:exit" (node) { | ||
const allHooks = ctx.getAllHooks(node); | ||
for (const { name, hookCalls, node } of allHooks.values()){ | ||
if (hookCalls.length > 0) continue; | ||
context.report({ | ||
data: { | ||
name: name.value | ||
}, | ||
messageId: "ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS", | ||
node | ||
}); | ||
} | ||
} | ||
}; | ||
schema: [], | ||
messages: { | ||
ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS: "Custom hooks {{name}} should use other hooks" | ||
} | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
const { ctx, listeners } = core.useHookCollector(); | ||
return { | ||
...listeners, | ||
"Program:exit"(node) { | ||
const allHooks = ctx.getAllHooks(node); | ||
for (const { name: name2, hookCalls, node: node2 } of allHooks.values()) { | ||
if (hookCalls.length > 0) | ||
continue; | ||
context.report({ | ||
data: { | ||
name: name2.value | ||
}, | ||
messageId: "ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS", | ||
node: node2 | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
/** | ||
* Tests if a value is a `function`. | ||
* | ||
* @param input - The value to test. | ||
* | ||
* @example | ||
* import { isFunction } from 'effect/Predicate' | ||
* | ||
* assert.deepStrictEqual(isFunction(isFunction), true) | ||
* assert.deepStrictEqual(isFunction("function"), false) | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const isFunction$1 = input => typeof input === "function"; | ||
/** | ||
* Creates a function that can be used in a data-last (aka `pipe`able) or | ||
* data-first style. | ||
* | ||
* The first parameter to `dual` is either the arity of the uncurried function | ||
* or a predicate that determines if the function is being used in a data-first | ||
* or data-last style. | ||
* | ||
* Using the arity is the most common use case, but there are some cases where | ||
* you may want to use a predicate. For example, if you have a function that | ||
* takes an optional argument, you can use a predicate to determine if the | ||
* function is being used in a data-first or data-last style. | ||
* | ||
* @param arity - Either the arity of the uncurried function or a predicate | ||
* which determines if the function is being used in a data-first | ||
* or data-last style. | ||
* @param body - The definition of the uncurried function. | ||
* | ||
* @example | ||
* import { dual, pipe } from "effect/Function" | ||
* | ||
* // Exampe using arity to determine data-first or data-last style | ||
* const sum: { | ||
* (that: number): (self: number) => number | ||
* (self: number, that: number): number | ||
* } = dual(2, (self: number, that: number): number => self + that) | ||
* | ||
* assert.deepStrictEqual(sum(2, 3), 5) | ||
* assert.deepStrictEqual(pipe(2, sum(3)), 5) | ||
* | ||
* // Example using a predicate to determine data-first or data-last style | ||
* const sum2: { | ||
* (that: number): (self: number) => number | ||
* (self: number, that: number): number | ||
* } = dual((args) => args.length === 1, (self: number, that: number): number => self + that) | ||
* | ||
* assert.deepStrictEqual(sum(2, 3), 5) | ||
* assert.deepStrictEqual(pipe(2, sum(3)), 5) | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
const dual = function (arity, body) { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Function.js | ||
var Function_exports = {}; | ||
__export(Function_exports, { | ||
SK: () => SK, | ||
absurd: () => absurd, | ||
apply: () => apply, | ||
compose: () => compose, | ||
constFalse: () => constFalse, | ||
constNull: () => constNull, | ||
constTrue: () => constTrue, | ||
constUndefined: () => constUndefined, | ||
constVoid: () => constVoid, | ||
constant: () => constant, | ||
dual: () => dual, | ||
flip: () => flip, | ||
flow: () => flow, | ||
hole: () => hole, | ||
identity: () => identity, | ||
isFunction: () => isFunction, | ||
pipe: () => pipe, | ||
tupled: () => tupled, | ||
unsafeCoerce: () => unsafeCoerce, | ||
untupled: () => untupled | ||
}); | ||
var isFunction = (input) => typeof input === "function"; | ||
var dual = function(arity, body) { | ||
if (typeof arity === "function") { | ||
return function () { | ||
return function() { | ||
if (arity(arguments)) { | ||
// @ts-expect-error | ||
return body.apply(this, arguments); | ||
} | ||
return self => body(self, ...arguments); | ||
return (self) => body(self, ...arguments); | ||
}; | ||
@@ -122,7 +99,7 @@ } | ||
case 2: | ||
return function (a, b) { | ||
return function(a, b2) { | ||
if (arguments.length >= 2) { | ||
return body(a, b); | ||
return body(a, b2); | ||
} | ||
return function (self) { | ||
return function(self) { | ||
return body(self, a); | ||
@@ -132,36 +109,35 @@ }; | ||
case 3: | ||
return function (a, b, c) { | ||
return function(a, b2, c2) { | ||
if (arguments.length >= 3) { | ||
return body(a, b, c); | ||
return body(a, b2, c2); | ||
} | ||
return function (self) { | ||
return body(self, a, b); | ||
return function(self) { | ||
return body(self, a, b2); | ||
}; | ||
}; | ||
case 4: | ||
return function (a, b, c, d) { | ||
return function(a, b2, c2, d2) { | ||
if (arguments.length >= 4) { | ||
return body(a, b, c, d); | ||
return body(a, b2, c2, d2); | ||
} | ||
return function (self) { | ||
return body(self, a, b, c); | ||
return function(self) { | ||
return body(self, a, b2, c2); | ||
}; | ||
}; | ||
case 5: | ||
return function (a, b, c, d, e) { | ||
return function(a, b2, c2, d2, e2) { | ||
if (arguments.length >= 5) { | ||
return body(a, b, c, d, e); | ||
return body(a, b2, c2, d2, e2); | ||
} | ||
return function (self) { | ||
return body(self, a, b, c, d); | ||
return function(self) { | ||
return body(self, a, b2, c2, d2); | ||
}; | ||
}; | ||
default: | ||
return function () { | ||
return function() { | ||
if (arguments.length >= arity) { | ||
// @ts-expect-error | ||
return body.apply(this, arguments); | ||
} | ||
const args = arguments; | ||
return function (self) { | ||
return function(self) { | ||
return body(self, ...args); | ||
@@ -172,17 +148,18 @@ }; | ||
}; | ||
/** | ||
* Reverses the order of arguments for a curried function. | ||
* | ||
* @param f - A curried function that takes multiple arguments. | ||
* | ||
* @example | ||
* import { flip } from "effect/Function" | ||
* | ||
* const f = (a: number) => (b: string) => a - b.length | ||
* | ||
* assert.deepStrictEqual(flip(f)('aaa')(2), -1) | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
const flip = f => (...b) => (...a) => f(...a)(...b); | ||
var apply = (a) => (self) => self(a); | ||
var identity = (a) => a; | ||
var unsafeCoerce = identity; | ||
var constant = (value) => () => value; | ||
var constTrue = /* @__PURE__ */ constant(true); | ||
var constFalse = /* @__PURE__ */ constant(false); | ||
var constNull = /* @__PURE__ */ constant(null); | ||
var constUndefined = /* @__PURE__ */ constant(void 0); | ||
var constVoid = constUndefined; | ||
var flip = (f) => (...b2) => (...a) => f(...a)(...b2); | ||
var compose = /* @__PURE__ */ dual(2, (ab, bc) => (a) => bc(ab(a))); | ||
var absurd = (_) => { | ||
throw new Error("Called `absurd` function which should be uncallable"); | ||
}; | ||
var tupled = (f) => (a) => f(...a); | ||
var untupled = (f) => (...a) => f(a); | ||
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) { | ||
@@ -208,27 +185,63 @@ switch (arguments.length) { | ||
return hi(gh(fg(ef(de(cd(bc(ab(a)))))))); | ||
default: | ||
{ | ||
let ret = arguments[0]; | ||
for (let i = 1; i < arguments.length; i++) { | ||
ret = arguments[i](ret); | ||
} | ||
return ret; | ||
default: { | ||
let ret = arguments[0]; | ||
for (let i2 = 1; i2 < arguments.length; i2++) { | ||
ret = arguments[i2](ret); | ||
} | ||
return ret; | ||
} | ||
} | ||
} | ||
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab; | ||
case 2: | ||
return function() { | ||
return bc(ab.apply(this, arguments)); | ||
}; | ||
case 3: | ||
return function() { | ||
return cd(bc(ab.apply(this, arguments))); | ||
}; | ||
case 4: | ||
return function() { | ||
return de(cd(bc(ab.apply(this, arguments)))); | ||
}; | ||
case 5: | ||
return function() { | ||
return ef(de(cd(bc(ab.apply(this, arguments))))); | ||
}; | ||
case 6: | ||
return function() { | ||
return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); | ||
}; | ||
case 7: | ||
return function() { | ||
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); | ||
}; | ||
case 8: | ||
return function() { | ||
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); | ||
}; | ||
case 9: | ||
return function() { | ||
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); | ||
}; | ||
} | ||
return; | ||
} | ||
var hole = /* @__PURE__ */ unsafeCoerce(absurd); | ||
var SK = (_, b2) => b2; | ||
const moduleVersion = "2.3.1"; | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/internal/version.js | ||
var moduleVersion = "2.3.1"; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const globalStoreId = /*#__PURE__*/Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/GlobalValue.js | ||
var globalStoreId = /* @__PURE__ */ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`); | ||
if (!(globalStoreId in globalThis)) { | ||
globalThis[globalStoreId] = /*#__PURE__*/new Map(); | ||
globalThis[globalStoreId] = /* @__PURE__ */ new Map(); | ||
} | ||
const globalStore = globalThis[globalStoreId]; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const globalValue = (id, compute) => { | ||
var globalStore = globalThis[globalStoreId]; | ||
var globalValue = (id, compute) => { | ||
if (!globalStore.has(id)) { | ||
@@ -240,91 +253,112 @@ globalStore.set(id, compute()); | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
/** | ||
* Tests if a value is a `function`. | ||
* | ||
* @param input - The value to test. | ||
* | ||
* @example | ||
* import { isFunction } from "effect/Predicate" | ||
* | ||
* assert.deepStrictEqual(isFunction(isFunction), true) | ||
* | ||
* assert.deepStrictEqual(isFunction("function"), false) | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const isFunction = isFunction$1; | ||
const isRecordOrArray = input => typeof input === "object" && input !== null; | ||
/** | ||
* Tests if a value is an `object`. | ||
* | ||
* @param input - The value to test. | ||
* | ||
* @example | ||
* import { isObject } from "effect/Predicate" | ||
* | ||
* assert.deepStrictEqual(isObject({}), true) | ||
* assert.deepStrictEqual(isObject([]), true) | ||
* | ||
* assert.deepStrictEqual(isObject(null), false) | ||
* assert.deepStrictEqual(isObject(undefined), false) | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const isObject = input => isRecordOrArray(input) || isFunction(input); | ||
/** | ||
* Checks whether a value is an `object` containing a specified property key. | ||
* | ||
* @param property - The field to check within the object. | ||
* @param self - The value to examine. | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const hasProperty = /*#__PURE__*/dual(2, (self, property) => isObject(self) && property in self); | ||
/** | ||
* A guard that succeeds when the input is `null` or `undefined`. | ||
* | ||
* @param input - The value to test. | ||
* | ||
* @example | ||
* import { isNullable } from "effect/Predicate" | ||
* | ||
* assert.deepStrictEqual(isNullable(null), true) | ||
* assert.deepStrictEqual(isNullable(undefined), true) | ||
* | ||
* assert.deepStrictEqual(isNullable({}), false) | ||
* assert.deepStrictEqual(isNullable([]), false) | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const isNullable = input => input === null || input === undefined; | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Predicate.js | ||
var isFunction2 = isFunction; | ||
var isRecordOrArray = (input) => typeof input === "object" && input !== null; | ||
var isObject = (input) => isRecordOrArray(input) || isFunction2(input); | ||
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self); | ||
var isNullable = (input) => input === null || input === void 0; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const defaultIncHi = 0x14057b7e; | ||
const defaultIncLo = 0xf767814f; | ||
const MUL_HI = 0x5851f42d >>> 0; | ||
const MUL_LO = 0x4c957f2d >>> 0; | ||
const BIT_53 = 9007199254740992.0; | ||
const BIT_27 = 134217728.0; | ||
/** | ||
* PCG is a family of simple fast space-efficient statistically good algorithms | ||
* for random number generation. Unlike many general-purpose RNGs, they are also | ||
* hard to predict. | ||
* | ||
* @category model | ||
* @since 2.0.0 | ||
*/ | ||
class PCGRandom { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Utils.js | ||
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind"); | ||
var GenKindImpl = class { | ||
value; | ||
constructor(value) { | ||
this.value = value; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
get _F() { | ||
return identity; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
get _R() { | ||
return (_) => _; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
get _O() { | ||
return (_) => _; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
get _E() { | ||
return (_) => _; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
[GenKindTypeId] = GenKindTypeId; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
[Symbol.iterator]() { | ||
return new SingleShotGen(this); | ||
} | ||
}; | ||
var SingleShotGen = class _SingleShotGen { | ||
self; | ||
called = false; | ||
constructor(self) { | ||
this.self = self; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
next(a) { | ||
return this.called ? { | ||
value: a, | ||
done: true | ||
} : (this.called = true, { | ||
value: this.self, | ||
done: false | ||
}); | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
return(a) { | ||
return { | ||
value: a, | ||
done: true | ||
}; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
throw(e2) { | ||
throw e2; | ||
} | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
[Symbol.iterator]() { | ||
return new _SingleShotGen(this.self); | ||
} | ||
}; | ||
var adapter = () => ( | ||
// @ts-expect-error | ||
function() { | ||
let x2 = arguments[0]; | ||
for (let i2 = 1; i2 < arguments.length; i2++) { | ||
x2 = arguments[i2](x2); | ||
} | ||
return new GenKindImpl(x2); | ||
} | ||
); | ||
var defaultIncHi = 335903614; | ||
var defaultIncLo = 4150755663; | ||
var MUL_HI = 1481765933 >>> 0; | ||
var MUL_LO = 1284865837 >>> 0; | ||
var BIT_53 = 9007199254740992; | ||
var BIT_27 = 134217728; | ||
var PCGRandom = class { | ||
_state; | ||
constructor(seedHi, seedLo, incHi, incLo) { | ||
if (isNullable(seedLo) && isNullable(seedHi)) { | ||
seedLo = Math.random() * 0xffffffff >>> 0; | ||
seedLo = Math.random() * 4294967295 >>> 0; | ||
seedHi = 0; | ||
@@ -381,3 +415,3 @@ } else if (isNullable(seedLo)) { | ||
if ((max & max - 1) === 0) { | ||
return this._next() & max - 1; // fast path for power of 2 | ||
return this._next() & max - 1; | ||
} | ||
@@ -387,4 +421,2 @@ let num = 0; | ||
for (num = this._next(); num < skew; num = this._next()) { | ||
// this loop will rarely execute more than twice, | ||
// and is intentionally empty | ||
} | ||
@@ -401,4 +433,4 @@ return num % max; | ||
number() { | ||
const hi = (this._next() & 0x03ffffff) * 1.0; | ||
const lo = (this._next() & 0x07ffffff) * 1.0; | ||
const hi = (this._next() & 67108863) * 1; | ||
const lo = (this._next() & 134217727) * 1; | ||
return (hi * BIT_27 + lo) / BIT_53; | ||
@@ -408,9 +440,6 @@ } | ||
_next() { | ||
// save current state (what we'll use for this number) | ||
const oldHi = this._state[0] >>> 0; | ||
const oldLo = this._state[1] >>> 0; | ||
// churn LCG. | ||
mul64(this._state, oldHi, oldLo, MUL_HI, MUL_LO); | ||
add64(this._state, this._state[0], this._state[1], this._state[2], this._state[3]); | ||
// get least sig. 32 bits of ((oldstate >> 18) ^ oldstate) >> 27 | ||
let xsHi = oldHi >>> 18; | ||
@@ -421,4 +450,2 @@ let xsLo = (oldLo >>> 18 | oldHi << 14) >>> 0; | ||
const xorshifted = (xsLo >>> 27 | xsHi << 5) >>> 0; | ||
// rotate xorshifted right a random amount, based on the most sig. 5 bits | ||
// bits of the old state. | ||
const rot = oldHi >>> 27; | ||
@@ -428,7 +455,7 @@ const rot2 = (-rot >>> 0 & 31) >>> 0; | ||
} | ||
} | ||
}; | ||
function mul64(out, aHi, aLo, bHi, bLo) { | ||
let c1 = (aLo >>> 16) * (bLo & 0xffff) >>> 0; | ||
let c0 = (aLo & 0xffff) * (bLo >>> 16) >>> 0; | ||
let lo = (aLo & 0xffff) * (bLo & 0xffff) >>> 0; | ||
let c1 = (aLo >>> 16) * (bLo & 65535) >>> 0; | ||
let c0 = (aLo & 65535) * (bLo >>> 16) >>> 0; | ||
let lo = (aLo & 65535) * (bLo & 65535) >>> 0; | ||
let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0; | ||
@@ -450,3 +477,2 @@ c0 = c0 << 16 >>> 0; | ||
} | ||
// add two 64 bit numbers (given in parts), and store the result in `out`. | ||
function add64(out, aHi, aLo, bHi, bLo) { | ||
@@ -462,19 +488,7 @@ let hi = aHi + bHi >>> 0; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
/** @internal */ | ||
const randomHashCache = /*#__PURE__*/globalValue( /*#__PURE__*/Symbol.for("effect/Hash/randomHashCache"), () => new WeakMap()); | ||
/** @internal */ | ||
const pcgr = /*#__PURE__*/globalValue( /*#__PURE__*/Symbol.for("effect/Hash/pcgr"), () => new PCGRandom()); | ||
/** | ||
* @since 2.0.0 | ||
* @category symbols | ||
*/ | ||
const symbol$1 = /*#__PURE__*/Symbol.for("effect/Hash"); | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const hash = self => { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Hash.js | ||
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap()); | ||
var pcgr = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/pcgr"), () => new PCGRandom()); | ||
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash"); | ||
var hash = (self) => { | ||
switch (typeof self) { | ||
@@ -494,13 +508,12 @@ case "number": | ||
case "function": | ||
case "object": | ||
{ | ||
if (self === null) { | ||
return string("null"); | ||
} | ||
if (isHash(self)) { | ||
return self[symbol$1](); | ||
} else { | ||
return random(self); | ||
} | ||
case "object": { | ||
if (self === null) { | ||
return string("null"); | ||
} | ||
if (isHash(self)) { | ||
return self[symbol](); | ||
} else { | ||
return random(self); | ||
} | ||
} | ||
default: | ||
@@ -510,7 +523,3 @@ throw new Error(`BUG: unhandled typeof ${typeof self} - please report an issue at https://github.com/Effect-TS/effect/issues`); | ||
}; | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const random = self => { | ||
var random = (self) => { | ||
if (!randomHashCache.has(self)) { | ||
@@ -521,43 +530,22 @@ randomHashCache.set(self, number(pcgr.integer(Number.MAX_SAFE_INTEGER))); | ||
}; | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const combine = b => self => self * 53 ^ b; | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const optimize = n => n & 0xbfffffff | n >>> 1 & 0x40000000; | ||
/** | ||
* @since 2.0.0 | ||
* @category guards | ||
*/ | ||
const isHash = u => hasProperty(u, symbol$1); | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const number = n => { | ||
if (n !== n || n === Infinity) { | ||
var combine = (b2) => (self) => self * 53 ^ b2; | ||
var optimize = (n2) => n2 & 3221225471 | n2 >>> 1 & 1073741824; | ||
var isHash = (u2) => hasProperty(u2, symbol); | ||
var number = (n2) => { | ||
if (n2 !== n2 || n2 === Infinity) { | ||
return 0; | ||
} | ||
let h = n | 0; | ||
if (h !== n) { | ||
h ^= n * 0xffffffff; | ||
let h = n2 | 0; | ||
if (h !== n2) { | ||
h ^= n2 * 4294967295; | ||
} | ||
while (n > 0xffffffff) { | ||
h ^= n /= 0xffffffff; | ||
while (n2 > 4294967295) { | ||
h ^= n2 /= 4294967295; | ||
} | ||
return optimize(n); | ||
return optimize(n2); | ||
}; | ||
/** | ||
* @since 2.0.0 | ||
* @category hashing | ||
*/ | ||
const string = str => { | ||
let h = 5381, | ||
i = str.length; | ||
while (i) { | ||
h = h * 33 ^ str.charCodeAt(--i); | ||
var string = (str) => { | ||
let h = 5381, i2 = str.length; | ||
while (i2) { | ||
h = h * 33 ^ str.charCodeAt(--i2); | ||
} | ||
@@ -567,10 +555,7 @@ return optimize(h); | ||
/** | ||
* @since 2.0.0 | ||
* @category symbols | ||
*/ | ||
const symbol = /*#__PURE__*/Symbol.for("effect/Equal"); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Equal.js | ||
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal"); | ||
function equals() { | ||
if (arguments.length === 1) { | ||
return self => compareBoth(self, arguments[0]); | ||
return (self) => compareBoth(self, arguments[0]); | ||
} | ||
@@ -589,3 +574,3 @@ return compareBoth(arguments[0], arguments[1]); | ||
if (isEqual(self) && isEqual(that)) { | ||
return hash(self) === hash(that) && self[symbol](that); | ||
return hash(self) === hash(that) && self[symbol2](that); | ||
} | ||
@@ -595,39 +580,84 @@ } | ||
} | ||
/** | ||
* @since 2.0.0 | ||
* @category guards | ||
*/ | ||
const isEqual = u => hasProperty(u, symbol); | ||
var isEqual = (u2) => hasProperty(u2, symbol2); | ||
var equivalence = () => (self, that) => equals(self, that); | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
/** | ||
* @since 2.0.0 | ||
* @category symbols | ||
*/ | ||
const NodeInspectSymbol = /*#__PURE__*/Symbol.for("nodejs.util.inspect.custom"); | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const toJSON = x => { | ||
if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) { | ||
return x.toJSON(); | ||
} else if (Array.isArray(x)) { | ||
return x.map(toJSON); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Equivalence.js | ||
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Inspectable.js | ||
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"); | ||
var toJSON = (x2) => { | ||
if (hasProperty(x2, "toJSON") && isFunction2(x2["toJSON"]) && x2["toJSON"].length === 0) { | ||
return x2.toJSON(); | ||
} else if (Array.isArray(x2)) { | ||
return x2.map(toJSON); | ||
} | ||
return x; | ||
return x2; | ||
}; | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const format = x => JSON.stringify(x, null, 2); | ||
var format = (x2) => JSON.stringify(x2, null, 2); | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const pipeArguments = (self, args) => { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Option.js | ||
var Option_exports = {}; | ||
__export(Option_exports, { | ||
Do: () => Do, | ||
TypeId: () => TypeId3, | ||
all: () => all, | ||
andThen: () => andThen, | ||
ap: () => ap, | ||
as: () => as, | ||
asUnit: () => asUnit, | ||
bind: () => bind, | ||
bindTo: () => bindTo, | ||
composeK: () => composeK, | ||
contains: () => contains, | ||
containsWith: () => containsWith, | ||
exists: () => exists, | ||
filter: () => filter, | ||
filterMap: () => filterMap, | ||
firstSomeOf: () => firstSomeOf, | ||
flatMap: () => flatMap, | ||
flatMapNullable: () => flatMapNullable, | ||
flatten: () => flatten, | ||
fromIterable: () => fromIterable, | ||
fromNullable: () => fromNullable, | ||
gen: () => gen, | ||
getEquivalence: () => getEquivalence, | ||
getLeft: () => getLeft2, | ||
getOrElse: () => getOrElse, | ||
getOrNull: () => getOrNull, | ||
getOrThrow: () => getOrThrow, | ||
getOrThrowWith: () => getOrThrowWith, | ||
getOrUndefined: () => getOrUndefined, | ||
getOrder: () => getOrder, | ||
getRight: () => getRight2, | ||
isNone: () => isNone2, | ||
isOption: () => isOption2, | ||
isSome: () => isSome2, | ||
let: () => let_, | ||
lift2: () => lift2, | ||
liftNullable: () => liftNullable, | ||
liftPredicate: () => liftPredicate, | ||
liftThrowable: () => liftThrowable, | ||
map: () => map, | ||
match: () => match, | ||
none: () => none2, | ||
orElse: () => orElse, | ||
orElseEither: () => orElseEither, | ||
orElseSome: () => orElseSome, | ||
partitionMap: () => partitionMap, | ||
product: () => product, | ||
productMany: () => productMany, | ||
reduceCompact: () => reduceCompact, | ||
some: () => some2, | ||
tap: () => tap, | ||
toArray: () => toArray, | ||
toRefinement: () => toRefinement, | ||
unit: () => unit, | ||
zipLeft: () => zipLeft, | ||
zipRight: () => zipRight, | ||
zipWith: () => zipWith | ||
}); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Pipeable.js | ||
var pipeArguments = (self, args) => { | ||
switch (args.length) { | ||
@@ -652,61 +682,55 @@ case 1: | ||
return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))))); | ||
default: | ||
{ | ||
let ret = self; | ||
for (let i = 0, len = args.length; i < len; i++) { | ||
ret = args[i](ret); | ||
} | ||
return ret; | ||
default: { | ||
let ret = self; | ||
for (let i2 = 0, len = args.length; i2 < len; i2++) { | ||
ret = args[i2](ret); | ||
} | ||
return ret; | ||
} | ||
} | ||
}; | ||
/** @internal */ | ||
const EffectTypeId = /*#__PURE__*/Symbol.for("effect/Effect"); | ||
/** @internal */ | ||
const StreamTypeId = /*#__PURE__*/Symbol.for("effect/Stream"); | ||
/** @internal */ | ||
const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink"); | ||
/** @internal */ | ||
const ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel"); | ||
/** @internal */ | ||
const effectVariance = { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/internal/effectable.js | ||
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect"); | ||
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream"); | ||
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink"); | ||
var ChannelTypeId = /* @__PURE__ */ Symbol.for("effect/Channel"); | ||
var effectVariance = { | ||
/* c8 ignore next */ | ||
_R: _ => _, | ||
_R: (_) => _, | ||
/* c8 ignore next */ | ||
_E: _ => _, | ||
_E: (_) => _, | ||
/* c8 ignore next */ | ||
_A: _ => _, | ||
_A: (_) => _, | ||
_V: moduleVersion | ||
}; | ||
const sinkVariance = { | ||
var sinkVariance = { | ||
/* c8 ignore next */ | ||
_A: _ => _, | ||
_A: (_) => _, | ||
/* c8 ignore next */ | ||
_In: _ => _, | ||
_In: (_) => _, | ||
/* c8 ignore next */ | ||
_L: _ => _, | ||
_L: (_) => _, | ||
/* c8 ignore next */ | ||
_E: _ => _, | ||
_E: (_) => _, | ||
/* c8 ignore next */ | ||
_R: _ => _ | ||
_R: (_) => _ | ||
}; | ||
const channelVariance = { | ||
var channelVariance = { | ||
/* c8 ignore next */ | ||
_Env: _ => _, | ||
_Env: (_) => _, | ||
/* c8 ignore next */ | ||
_InErr: _ => _, | ||
_InErr: (_) => _, | ||
/* c8 ignore next */ | ||
_InElem: _ => _, | ||
_InElem: (_) => _, | ||
/* c8 ignore next */ | ||
_InDone: _ => _, | ||
_InDone: (_) => _, | ||
/* c8 ignore next */ | ||
_OutErr: _ => _, | ||
_OutErr: (_) => _, | ||
/* c8 ignore next */ | ||
_OutElem: _ => _, | ||
_OutElem: (_) => _, | ||
/* c8 ignore next */ | ||
_OutDone: _ => _ | ||
_OutDone: (_) => _ | ||
}; | ||
/** @internal */ | ||
const EffectPrototype = { | ||
var EffectPrototype = { | ||
[EffectTypeId]: effectVariance, | ||
@@ -716,6 +740,6 @@ [StreamTypeId]: effectVariance, | ||
[ChannelTypeId]: channelVariance, | ||
[symbol](that) { | ||
[symbol2](that) { | ||
return this === that; | ||
}, | ||
[symbol$1]() { | ||
[symbol]() { | ||
return random(this); | ||
@@ -728,10 +752,8 @@ }, | ||
/** | ||
* @since 2.0.0 | ||
*/ | ||
const TypeId = /*#__PURE__*/Symbol.for("effect/Option"); | ||
const CommonProto = { | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/internal/option.js | ||
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option"); | ||
var CommonProto = { | ||
...EffectPrototype, | ||
[TypeId]: { | ||
_A: _ => _ | ||
_A: (_) => _ | ||
}, | ||
@@ -745,9 +767,9 @@ [NodeInspectSymbol]() { | ||
}; | ||
const SomeProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), { | ||
var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), { | ||
_tag: "Some", | ||
_op: "Some", | ||
[symbol](that) { | ||
[symbol2](that) { | ||
return isOption(that) && isSome(that) && equals(that.value, this.value); | ||
}, | ||
[symbol$1]() { | ||
[symbol]() { | ||
return combine(hash(this._tag))(hash(this.value)); | ||
@@ -763,9 +785,9 @@ }, | ||
}); | ||
const NoneProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), { | ||
var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), { | ||
_tag: "None", | ||
_op: "None", | ||
[symbol](that) { | ||
return isOption(that) && isNone$1(that); | ||
[symbol2](that) { | ||
return isOption(that) && isNone(that); | ||
}, | ||
[symbol$1]() { | ||
[symbol]() { | ||
return combine(hash(this._tag)); | ||
@@ -780,12 +802,7 @@ }, | ||
}); | ||
/** @internal */ | ||
const isOption = input => hasProperty(input, TypeId); | ||
/** @internal */ | ||
const isNone$1 = fa => fa._tag === "None"; | ||
/** @internal */ | ||
const isSome = fa => fa._tag === "Some"; | ||
/** @internal */ | ||
const none$1 = /*#__PURE__*/Object.create(NoneProto); | ||
/** @internal */ | ||
const some$1 = value => { | ||
var isOption = (input) => hasProperty(input, TypeId); | ||
var isNone = (fa) => fa._tag === "None"; | ||
var isSome = (fa) => fa._tag === "Some"; | ||
var none = /* @__PURE__ */ Object.create(NoneProto); | ||
var some = (value) => { | ||
const a = Object.create(SomeProto); | ||
@@ -796,265 +813,563 @@ a.value = value; | ||
/** | ||
* Creates a new `Option` that represents the absence of a value. | ||
* | ||
* @category constructors | ||
* @since 2.0.0 | ||
*/ | ||
const none = () => none$1; | ||
/** | ||
* Creates a new `Option` that wraps the given value. | ||
* | ||
* @param value - The value to wrap. | ||
* | ||
* @category constructors | ||
* @since 2.0.0 | ||
*/ | ||
const some = some$1; | ||
/** | ||
* Determine if a `Option` is a `None`. | ||
* | ||
* @param self - The `Option` to check. | ||
* | ||
* @example | ||
* import { some, none, isNone } from 'effect/Option' | ||
* | ||
* assert.deepStrictEqual(isNone(some(1)), false) | ||
* assert.deepStrictEqual(isNone(none()), true) | ||
* | ||
* @category guards | ||
* @since 2.0.0 | ||
*/ | ||
const isNone = isNone$1; | ||
/** | ||
* Maps the `Some` side of an `Option` value to a new `Option` value. | ||
* | ||
* @param self - An `Option` to map | ||
* @param f - The function to map over the value of the `Option` | ||
* | ||
* @category mapping | ||
* @since 2.0.0 | ||
*/ | ||
const map = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : some(f(self.value))); | ||
/** | ||
* Applies a function to the value of an `Option` and flattens the result, if the input is `Some`. | ||
* | ||
* @category sequencing | ||
* @since 2.0.0 | ||
*/ | ||
const flatMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : f(self.value)); | ||
/** | ||
* Maps over the value of an `Option` and filters out `None`s. | ||
* | ||
* Useful when in addition to filtering you also want to change the type of the `Option`. | ||
* | ||
* @param self - The `Option` to map over. | ||
* @param f - A function to apply to the value of the `Option`. | ||
* | ||
* @example | ||
* import * as O from "effect/Option" | ||
* | ||
* const evenNumber = (n: number) => n % 2 === 0 ? O.some(n) : O.none() | ||
* | ||
* assert.deepStrictEqual(O.filterMap(O.none(), evenNumber), O.none()) | ||
* assert.deepStrictEqual(O.filterMap(O.some(3), evenNumber), O.none()) | ||
* assert.deepStrictEqual(O.filterMap(O.some(2), evenNumber), O.some(2)) | ||
* | ||
* @category filtering | ||
* @since 2.0.0 | ||
*/ | ||
const filterMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : f(self.value)); | ||
/** | ||
* Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`. | ||
* | ||
* If you need to change the type of the `Option` in addition to filtering, see `filterMap`. | ||
* | ||
* @param predicate - A predicate function to apply to the `Option` value. | ||
* @param fb - The `Option` to filter. | ||
* | ||
* @example | ||
* import * as O from "effect/Option" | ||
* | ||
* // predicate | ||
* const isEven = (n: number) => n % 2 === 0 | ||
* | ||
* assert.deepStrictEqual(O.filter(O.none(), isEven), O.none()) | ||
* assert.deepStrictEqual(O.filter(O.some(3), isEven), O.none()) | ||
* assert.deepStrictEqual(O.filter(O.some(2), isEven), O.some(2)) | ||
* | ||
* // refinement | ||
* const isNumber = (v: unknown): v is number => typeof v === "number" | ||
* | ||
* assert.deepStrictEqual(O.filter(O.none(), isNumber), O.none()) | ||
* assert.deepStrictEqual(O.filter(O.some('hello'), isNumber), O.none()) | ||
* assert.deepStrictEqual(O.filter(O.some(2), isNumber), O.some(2)) | ||
* | ||
* @category filtering | ||
* @since 2.0.0 | ||
*/ | ||
const filter = /*#__PURE__*/dual(2, (self, predicate) => filterMap(self, b => predicate(b) ? some$1(b) : none$1)); | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/internal/either.js | ||
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either"); | ||
var CommonProto2 = { | ||
...EffectPrototype, | ||
[TypeId2]: { | ||
_A: (_) => _ | ||
}, | ||
[NodeInspectSymbol]() { | ||
return this.toJSON(); | ||
}, | ||
toString() { | ||
return format(this.toJSON()); | ||
} | ||
}; | ||
var RightProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), { | ||
_tag: "Right", | ||
_op: "Right", | ||
[symbol2](that) { | ||
return isEither(that) && isRight(that) && equals(that.right, this.right); | ||
}, | ||
[symbol]() { | ||
return combine(hash(this._tag))(hash(this.right)); | ||
}, | ||
toJSON() { | ||
return { | ||
_id: "Either", | ||
_tag: this._tag, | ||
right: toJSON(this.right) | ||
}; | ||
} | ||
}); | ||
var LeftProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), { | ||
_tag: "Left", | ||
_op: "Left", | ||
[symbol2](that) { | ||
return isEither(that) && isLeft(that) && equals(that.left, this.left); | ||
}, | ||
[symbol]() { | ||
return combine(hash(this._tag))(hash(this.left)); | ||
}, | ||
toJSON() { | ||
return { | ||
_id: "Either", | ||
_tag: this._tag, | ||
left: toJSON(this.left) | ||
}; | ||
} | ||
}); | ||
var isEither = (input) => hasProperty(input, TypeId2); | ||
var isLeft = (ma) => ma._tag === "Left"; | ||
var isRight = (ma) => ma._tag === "Right"; | ||
var left = (left2) => { | ||
const a = Object.create(LeftProto); | ||
a.left = left2; | ||
return a; | ||
}; | ||
var right = (right2) => { | ||
const a = Object.create(RightProto); | ||
a.right = right2; | ||
return a; | ||
}; | ||
var getLeft = (self) => isRight(self) ? none : some(self.left); | ||
var getRight = (self) => isLeft(self) ? none : some(self.right); | ||
/** | ||
* Bun currently has a bug where `setTimeout` doesn't behave correctly with a 0ms delay. | ||
* | ||
* @see https://github.com/oven-sh/bun/issues/3333 | ||
*/ | ||
/** @internal */ | ||
typeof process === "undefined" ? false : !!process?.isBun; | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Order.js | ||
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that); | ||
var match; | ||
function n(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function t(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return (e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return "Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var u=0;return function(){return u>=t.length?{done:!0}:{done:!1,value:t[u++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r=Symbol.for("@ts-pattern/matcher"),e=Symbol.for("@ts-pattern/isVariadic"),u="@ts-pattern/anonymous-select-key",i=function(n){return Boolean(n&&"object"==typeof n)},o=function(n){return n&&!!n[r]},c=function n(u,c,a){if(o(u)){var f=u[r]().match(c),s=f.matched,l=f.selections;return s&&l&&Object.keys(l).forEach(function(n){return a(n,l[n])}),s}if(i(u)){if(!i(c))return !1;if(Array.isArray(u)){if(!Array.isArray(c))return !1;for(var h,v=[],g=[],m=[],p=t(u.keys());!(h=p()).done;){var y=u[h.value];o(y)&&y[e]?m.push(y):m.length?g.push(y):v.push(y);}if(m.length){if(m.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(c.length<v.length+g.length)return !1;var d=c.slice(0,v.length),b=0===g.length?[]:c.slice(-g.length),w=c.slice(v.length,0===g.length?Infinity:-g.length);return v.every(function(t,r){return n(t,d[r],a)})&&g.every(function(t,r){return n(t,b[r],a)})&&(0===m.length||n(m[0],w,a))}return u.length===c.length&&u.every(function(t,r){return n(t,c[r],a)})}return Object.keys(u).every(function(t){var e,i=u[t];return (t in c||o(e=i)&&"optional"===e[r]().matcherType)&&n(i,c[t],a)})}return Object.is(c,u)},a=function n(t){var e,u,c;return i(t)?o(t)?null!=(e=null==(u=(c=t[r]()).getSelectionKeys)?void 0:u.call(c))?e:[]:Array.isArray(t)?f(t,n):f(Object.values(t),n):[]},f=function(n,t){return n.reduce(function(n,r){return n.concat(t(r))},[])};function l(n){return Object.assign(n,{optional:function(){return v(n)},and:function(t){return p(n,t)},or:function(t){return y(n,t)},select:function(t){return void 0===t?b(n):b(t,n)}})}function v(n){var t;return l(((t={})[r]=function(){return {match:function(t){var r={},e=function(n,t){r[n]=t;};return void 0===t?(a(n).forEach(function(n){return e(n,void 0)}),{matched:!0,selections:r}):{matched:c(n,t,e),selections:r}},getSelectionKeys:function(){return a(n)},matcherType:"optional"}},t))}function p(){var n,t=[].slice.call(arguments);return l(((n={})[r]=function(){return {match:function(n){var r={},e=function(n,t){r[n]=t;};return {matched:t.every(function(t){return c(t,n,e)}),selections:r}},getSelectionKeys:function(){return f(t,a)},matcherType:"and"}},n))}function y(){var n,t=[].slice.call(arguments);return l(((n={})[r]=function(){return {match:function(n){var r={},e=function(n,t){r[n]=t;};return f(t,a).forEach(function(n){return e(n,void 0)}),{matched:t.some(function(t){return c(t,n,e)}),selections:r}},getSelectionKeys:function(){return f(t,a)},matcherType:"or"}},n))}function d(n){var t;return (t={})[r]=function(){return {match:function(t){return {matched:Boolean(n(t))}}}},t}function b(){var n,t=[].slice.call(arguments),e="string"==typeof t[0]?t[0]:void 0,i=2===t.length?t[1]:"string"==typeof t[0]?void 0:t[0];return l(((n={})[r]=function(){return {match:function(n){var t,r=((t={})[null!=e?e:u]=n,t);return {matched:void 0===i||c(i,n,function(n,t){r[n]=t;}),selections:r}},getSelectionKeys:function(){return [null!=e?e:u].concat(void 0===i?[]:a(i))}}},n))}function w(n){return "number"==typeof n}function S(n){return "string"==typeof n}function j(n){return "bigint"==typeof n}l(d(function(n){return !0}));(function n(t){return Object.assign(l(t),{startsWith:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.startsWith(e)}))));var e;},endsWith:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.endsWith(e)}))));var e;},minLength:function(r){return n(p(t,function(n){return d(function(t){return S(t)&&t.length>=n})}(r)))},maxLength:function(r){return n(p(t,function(n){return d(function(t){return S(t)&&t.length<=n})}(r)))},includes:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&n.includes(e)}))));var e;},regex:function(r){return n(p(t,(e=r,d(function(n){return S(n)&&Boolean(n.match(e))}))));var e;}})})(d(S));(function n(t){return Object.assign(l(t),{between:function(r,e){return n(p(t,function(n,t){return d(function(r){return w(r)&&n<=r&&t>=r})}(r,e)))},lt:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t<n})}(r)))},gt:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t>n})}(r)))},lte:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t<=n})}(r)))},gte:function(r){return n(p(t,function(n){return d(function(t){return w(t)&&t>=n})}(r)))},int:function(){return n(p(t,d(function(n){return w(n)&&Number.isInteger(n)})))},finite:function(){return n(p(t,d(function(n){return w(n)&&Number.isFinite(n)})))},positive:function(){return n(p(t,d(function(n){return w(n)&&n>0})))},negative:function(){return n(p(t,d(function(n){return w(n)&&n<0})))}})})(d(w));(function n(t){return Object.assign(l(t),{between:function(r,e){return n(p(t,function(n,t){return d(function(r){return j(r)&&n<=r&&t>=r})}(r,e)))},lt:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t<n})}(r)))},gt:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t>n})}(r)))},lte:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t<=n})}(r)))},gte:function(r){return n(p(t,function(n){return d(function(t){return j(t)&&t>=n})}(r)))},positive:function(){return n(p(t,d(function(n){return j(n)&&n>0})))},negative:function(){return n(p(t,d(function(n){return j(n)&&n<0})))}})})(d(j));l(d(function(n){return "boolean"==typeof n}));l(d(function(n){return "symbol"==typeof n}));l(d(function(n){return null==n}));var I={matched:!1,value:void 0},_=/*#__PURE__*/function(){function n(n,t){this.input=void 0,this.state=void 0,this.input=n,this.state=t;}var t=n.prototype;return t.with=function(){var t=this,r=[].slice.call(arguments);if(this.state.matched)return this;var e=r[r.length-1],i=[r[0]],o=void 0;3===r.length&&"function"==typeof r[1]?o=r[1]:r.length>2&&i.push.apply(i,r.slice(1,r.length-1));var a=!1,f={},s=function(n,t){a=!0,f[n]=t;},l=!i.some(function(n){return c(n,t.input,s)})||o&&!Boolean(o(this.input))?I:{matched:!0,value:e(a?u in f?f[u]:f:this.input,this.input)};return new n(this.input,l)},t.when=function(t,r){if(this.state.matched)return this;var e=Boolean(t(this.input));return new n(this.input,e?{matched:!0,value:r(this.input,this.input)}:I)},t.otherwise=function(n){return this.state.matched?this.state.value:n(this.input)},t.exhaustive=function(){if(this.state.matched)return this.state.value;var n;try{n=JSON.stringify(this.input);}catch(t){n=this.input;}throw new Error("Pattern matching error: no pattern matches value "+n)},t.run=function(){return this.exhaustive()},t.returnType=function(){return this},n}();match = function(n){return new _(n,I)}; | ||
// ../../../node_modules/.pnpm/effect@2.3.1/node_modules/effect/dist/esm/Option.js | ||
var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Option"); | ||
var none2 = () => none; | ||
var some2 = some; | ||
var isOption2 = isOption; | ||
var isNone2 = isNone; | ||
var isSome2 = isSome; | ||
var match = /* @__PURE__ */ dual(2, (self, { | ||
onNone, | ||
onSome | ||
}) => isNone2(self) ? onNone() : onSome(self.value)); | ||
var toRefinement = (f) => (a) => isSome2(f(a)); | ||
var fromIterable = (collection) => { | ||
for (const a of collection) { | ||
return some2(a); | ||
} | ||
return none2(); | ||
}; | ||
var getRight2 = getRight; | ||
var getLeft2 = getLeft; | ||
var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value); | ||
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self); | ||
var orElseSome = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? some2(onNone()) : self); | ||
var orElseEither = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? map(that(), right) : map(self, left)); | ||
var firstSomeOf = (collection) => { | ||
let out = none2(); | ||
for (out of collection) { | ||
if (isSome2(out)) { | ||
return out; | ||
} | ||
} | ||
return out; | ||
}; | ||
var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue); | ||
var liftNullable = (f) => (...a) => fromNullable(f(...a)); | ||
var getOrNull = /* @__PURE__ */ getOrElse(constNull); | ||
var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); | ||
var liftThrowable = (f) => (...a) => { | ||
try { | ||
return some2(f(...a)); | ||
} catch (e2) { | ||
return none2(); | ||
} | ||
}; | ||
var getOrThrowWith = /* @__PURE__ */ dual(2, (self, onNone) => { | ||
if (isSome2(self)) { | ||
return self.value; | ||
} | ||
throw onNone(); | ||
}); | ||
var getOrThrow = /* @__PURE__ */ getOrThrowWith(() => new Error("getOrThrow called on a None")); | ||
var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); | ||
var as = /* @__PURE__ */ dual(2, (self, b2) => map(self, () => b2)); | ||
var asUnit = /* @__PURE__ */ as(void 0); | ||
var unit = /* @__PURE__ */ some2(void 0); | ||
var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); | ||
var andThen = /* @__PURE__ */ dual(2, (self, f) => isFunction(f) ? flatMap(self, f) : flatMap(self, () => f)); | ||
var flatMapNullable = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : fromNullable(f(self.value))); | ||
var flatten = /* @__PURE__ */ flatMap(identity); | ||
var zipRight = /* @__PURE__ */ dual(2, (self, that) => flatMap(self, () => that)); | ||
var composeK = /* @__PURE__ */ dual(2, (afb, bfc) => (a) => flatMap(afb(a), bfc)); | ||
var zipLeft = /* @__PURE__ */ dual(2, (self, that) => tap(self, () => that)); | ||
var tap = /* @__PURE__ */ dual(2, (self, f) => flatMap(self, (a) => map(f(a), () => a))); | ||
var product = (self, that) => isSome2(self) && isSome2(that) ? some2([self.value, that.value]) : none2(); | ||
var productMany = (self, collection) => { | ||
if (isNone2(self)) { | ||
return none2(); | ||
} | ||
const out = [self.value]; | ||
for (const o2 of collection) { | ||
if (isNone2(o2)) { | ||
return none2(); | ||
} | ||
out.push(o2.value); | ||
} | ||
return some2(out); | ||
}; | ||
var all = (input) => { | ||
if (Symbol.iterator in input) { | ||
const out2 = []; | ||
for (const o2 of input) { | ||
if (isNone2(o2)) { | ||
return none2(); | ||
} | ||
out2.push(o2.value); | ||
} | ||
return some2(out2); | ||
} | ||
const out = {}; | ||
for (const key of Object.keys(input)) { | ||
const o2 = input[key]; | ||
if (isNone2(o2)) { | ||
return none2(); | ||
} | ||
out[key] = o2.value; | ||
} | ||
return some2(out); | ||
}; | ||
var zipWith = /* @__PURE__ */ dual(3, (self, that, f) => map(product(self, that), ([a, b2]) => f(a, b2))); | ||
var ap = /* @__PURE__ */ dual(2, (self, that) => zipWith(self, that, (f, a) => f(a))); | ||
var reduceCompact = /* @__PURE__ */ dual(3, (self, b2, f) => { | ||
let out = b2; | ||
for (const oa of self) { | ||
if (isSome2(oa)) { | ||
out = f(out, oa.value); | ||
} | ||
} | ||
return out; | ||
}); | ||
var toArray = (self) => isNone2(self) ? [] : [self.value]; | ||
var partitionMap = /* @__PURE__ */ dual(2, (self, f) => { | ||
if (isNone2(self)) { | ||
return [none2(), none2()]; | ||
} | ||
const e2 = f(self.value); | ||
return isLeft(e2) ? [some2(e2.left), none2()] : [none2(), some2(e2.right)]; | ||
}); | ||
var filterMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); | ||
var filter = /* @__PURE__ */ dual(2, (self, predicate) => filterMap(self, (b2) => predicate(b2) ? some(b2) : none)); | ||
var getEquivalence = (isEquivalent) => make((x2, y2) => x2 === y2 || (isNone2(x2) ? isNone2(y2) : isNone2(y2) ? false : isEquivalent(x2.value, y2.value))); | ||
var getOrder = (O) => make2((self, that) => isSome2(self) ? isSome2(that) ? O(self.value, that.value) : 1 : -1); | ||
var lift2 = (f) => dual(2, (self, that) => zipWith(self, that, f)); | ||
var liftPredicate = (predicate) => (b2) => predicate(b2) ? some2(b2) : none2(); | ||
var containsWith = (isEquivalent) => dual(2, (self, a) => isNone2(self) ? false : isEquivalent(self.value, a)); | ||
var _equivalence = /* @__PURE__ */ equivalence(); | ||
var contains = /* @__PURE__ */ containsWith(_equivalence); | ||
var exists = /* @__PURE__ */ dual(2, (self, refinement) => isNone2(self) ? false : refinement(self.value)); | ||
var bindTo = /* @__PURE__ */ dual(2, (self, name2) => map(self, (a) => ({ | ||
[name2]: a | ||
}))); | ||
var let_ = /* @__PURE__ */ dual(3, (self, name2, f) => map(self, (a) => Object.assign({}, a, { | ||
[name2]: f(a) | ||
}))); | ||
var bind = /* @__PURE__ */ dual(3, (self, name2, f) => flatMap(self, (a) => map(f(a), (b2) => Object.assign({}, a, { | ||
[name2]: b2 | ||
})))); | ||
var Do = /* @__PURE__ */ some2({}); | ||
var adapter2 = /* @__PURE__ */ adapter(); | ||
var gen = (f) => { | ||
const iterator = f(adapter2); | ||
let state = iterator.next(); | ||
if (state.done) { | ||
return some2(state.value); | ||
} else { | ||
let current = state.value.value; | ||
if (isNone2(current)) { | ||
return current; | ||
} | ||
while (!state.done) { | ||
state = iterator.next(current.value); | ||
if (!state.done) { | ||
current = state.value.value; | ||
if (isNone2(current)) { | ||
return current; | ||
} | ||
} | ||
} | ||
return some2(state.value); | ||
} | ||
}; | ||
const RULE_NAME$2 = "ensure-use-callback-has-non-empty-deps"; | ||
var ensureUseCallbackHasNonEmptyDeps = createRule({ | ||
name: RULE_NAME$2, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce 'useCallback' has non-empty dependencies array", | ||
requiresTypeChecking: false | ||
}, | ||
schema: [], | ||
messages: { | ||
ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS: "useCallback should have a non-empty dependencies array" | ||
} | ||
// ../../../node_modules/.pnpm/ts-pattern@5.0.6/node_modules/ts-pattern/dist/index.js | ||
var t = Symbol.for("@ts-pattern/matcher"); | ||
var e = Symbol.for("@ts-pattern/isVariadic"); | ||
var n = "@ts-pattern/anonymous-select-key"; | ||
var r = (t2) => Boolean(t2 && "object" == typeof t2); | ||
var i = (e2) => e2 && !!e2[t]; | ||
var s = (n2, o2, c2) => { | ||
if (i(n2)) { | ||
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(o2); | ||
return r2 && i2 && Object.keys(i2).forEach((t2) => c2(t2, i2[t2])), r2; | ||
} | ||
if (r(n2)) { | ||
if (!r(o2)) | ||
return false; | ||
if (Array.isArray(n2)) { | ||
if (!Array.isArray(o2)) | ||
return false; | ||
let t2 = [], r2 = [], a = []; | ||
for (const s2 of n2.keys()) { | ||
const o3 = n2[s2]; | ||
i(o3) && o3[e] ? a.push(o3) : a.length ? r2.push(o3) : t2.push(o3); | ||
} | ||
if (a.length) { | ||
if (a.length > 1) | ||
throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed."); | ||
if (o2.length < t2.length + r2.length) | ||
return false; | ||
const e2 = o2.slice(0, t2.length), n3 = 0 === r2.length ? [] : o2.slice(-r2.length), i2 = o2.slice(t2.length, 0 === r2.length ? Infinity : -r2.length); | ||
return t2.every((t3, n4) => s(t3, e2[n4], c2)) && r2.every((t3, e3) => s(t3, n3[e3], c2)) && (0 === a.length || s(a[0], i2, c2)); | ||
} | ||
return n2.length === o2.length && n2.every((t3, e2) => s(t3, o2[e2], c2)); | ||
} | ||
return Object.keys(n2).every((e2) => { | ||
const r2 = n2[e2]; | ||
return (e2 in o2 || i(a = r2) && "optional" === a[t]().matcherType) && s(r2, o2[e2], c2); | ||
var a; | ||
}); | ||
} | ||
return Object.is(o2, n2); | ||
}; | ||
var o = (e2) => { | ||
var n2, s2, a; | ||
return r(e2) ? i(e2) ? null != (n2 = null == (s2 = (a = e2[t]()).getSelectionKeys) ? void 0 : s2.call(a)) ? n2 : [] : Array.isArray(e2) ? c(e2, o) : c(Object.values(e2), o) : []; | ||
}; | ||
var c = (t2, e2) => t2.reduce((t3, n2) => t3.concat(e2(n2)), []); | ||
function u(t2) { | ||
return Object.assign(t2, { optional: () => l(t2), and: (e2) => m(t2, e2), or: (e2) => y(t2, e2), select: (e2) => void 0 === e2 ? p(t2) : p(e2, t2) }); | ||
} | ||
function l(e2) { | ||
return u({ [t]: () => ({ match: (t2) => { | ||
let n2 = {}; | ||
const r2 = (t3, e3) => { | ||
n2[t3] = e3; | ||
}; | ||
return void 0 === t2 ? (o(e2).forEach((t3) => r2(t3, void 0)), { matched: true, selections: n2 }) : { matched: s(e2, t2, r2), selections: n2 }; | ||
}, getSelectionKeys: () => o(e2), matcherType: "optional" }) }); | ||
} | ||
function m(...e2) { | ||
return u({ [t]: () => ({ match: (t2) => { | ||
let n2 = {}; | ||
const r2 = (t3, e3) => { | ||
n2[t3] = e3; | ||
}; | ||
return { matched: e2.every((e3) => s(e3, t2, r2)), selections: n2 }; | ||
}, getSelectionKeys: () => c(e2, o), matcherType: "and" }) }); | ||
} | ||
function y(...e2) { | ||
return u({ [t]: () => ({ match: (t2) => { | ||
let n2 = {}; | ||
const r2 = (t3, e3) => { | ||
n2[t3] = e3; | ||
}; | ||
return c(e2, o).forEach((t3) => r2(t3, void 0)), { matched: e2.some((e3) => s(e3, t2, r2)), selections: n2 }; | ||
}, getSelectionKeys: () => c(e2, o), matcherType: "or" }) }); | ||
} | ||
function d(e2) { | ||
return { [t]: () => ({ match: (t2) => ({ matched: Boolean(e2(t2)) }) }) }; | ||
} | ||
function p(...e2) { | ||
const r2 = "string" == typeof e2[0] ? e2[0] : void 0, i2 = 2 === e2.length ? e2[1] : "string" == typeof e2[0] ? void 0 : e2[0]; | ||
return u({ [t]: () => ({ match: (t2) => { | ||
let e3 = { [null != r2 ? r2 : n]: t2 }; | ||
return { matched: void 0 === i2 || s(i2, t2, (t3, n2) => { | ||
e3[t3] = n2; | ||
}), selections: e3 }; | ||
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] : o(i2)) }) }); | ||
} | ||
function v(t2) { | ||
return "number" == typeof t2; | ||
} | ||
function b(t2) { | ||
return "string" == typeof t2; | ||
} | ||
function w(t2) { | ||
return "bigint" == typeof t2; | ||
} | ||
u(d(function(t2) { | ||
return true; | ||
})); | ||
var j = (t2) => Object.assign(u(t2), { startsWith: (e2) => { | ||
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.startsWith(n2))))); | ||
var n2; | ||
}, endsWith: (e2) => { | ||
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.endsWith(n2))))); | ||
var n2; | ||
}, minLength: (e2) => j(m(t2, ((t3) => d((e3) => b(e3) && e3.length >= t3))(e2))), maxLength: (e2) => j(m(t2, ((t3) => d((e3) => b(e3) && e3.length <= t3))(e2))), includes: (e2) => { | ||
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.includes(n2))))); | ||
var n2; | ||
}, regex: (e2) => { | ||
return j(m(t2, (n2 = e2, d((t3) => b(t3) && Boolean(t3.match(n2)))))); | ||
var n2; | ||
} }); | ||
j(d(b)); | ||
var K = (t2) => Object.assign(u(t2), { between: (e2, n2) => K(m(t2, ((t3, e3) => d((n3) => v(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 < t3))(e2))), gt: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 > t3))(e2))), lte: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 <= t3))(e2))), gte: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 >= t3))(e2))), int: () => K(m(t2, d((t3) => v(t3) && Number.isInteger(t3)))), finite: () => K(m(t2, d((t3) => v(t3) && Number.isFinite(t3)))), positive: () => K(m(t2, d((t3) => v(t3) && t3 > 0))), negative: () => K(m(t2, d((t3) => v(t3) && t3 < 0))) }); | ||
K(d(v)); | ||
var x = (t2) => Object.assign(u(t2), { between: (e2, n2) => x(m(t2, ((t3, e3) => d((n3) => w(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 < t3))(e2))), gt: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 > t3))(e2))), lte: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 <= t3))(e2))), gte: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 >= t3))(e2))), positive: () => x(m(t2, d((t3) => w(t3) && t3 > 0))), negative: () => x(m(t2, d((t3) => w(t3) && t3 < 0))) }); | ||
x(d(w)); | ||
u(d(function(t2) { | ||
return "boolean" == typeof t2; | ||
})); | ||
u(d(function(t2) { | ||
return "symbol" == typeof t2; | ||
})); | ||
u(d(function(t2) { | ||
return null == t2; | ||
})); | ||
var W = { matched: false, value: void 0 }; | ||
function N(t2) { | ||
return new $(t2, W); | ||
} | ||
var $ = class _$ { | ||
constructor(t2, e2) { | ||
this.input = void 0, this.state = void 0, this.input = t2, this.state = e2; | ||
} | ||
with(...t2) { | ||
if (this.state.matched) | ||
return this; | ||
const e2 = t2[t2.length - 1], r2 = [t2[0]]; | ||
let i2; | ||
3 === t2.length && "function" == typeof t2[1] ? i2 = t2[1] : t2.length > 2 && r2.push(...t2.slice(1, t2.length - 1)); | ||
let o2 = false, c2 = {}; | ||
const a = (t3, e3) => { | ||
o2 = true, c2[t3] = e3; | ||
}, u2 = !r2.some((t3) => s(t3, this.input, a)) || i2 && !Boolean(i2(this.input)) ? W : { matched: true, value: e2(o2 ? n in c2 ? c2[n] : c2 : this.input, this.input) }; | ||
return new _$(this.input, u2); | ||
} | ||
when(t2, e2) { | ||
if (this.state.matched) | ||
return this; | ||
const n2 = Boolean(t2(this.input)); | ||
return new _$(this.input, n2 ? { matched: true, value: e2(this.input, this.input) } : W); | ||
} | ||
otherwise(t2) { | ||
return this.state.matched ? this.state.value : t2(this.input); | ||
} | ||
exhaustive() { | ||
if (this.state.matched) | ||
return this.state.value; | ||
let t2; | ||
try { | ||
t2 = JSON.stringify(this.input); | ||
} catch (e2) { | ||
t2 = this.input; | ||
} | ||
throw new Error(`Pattern matching error: no pattern matches value ${t2}`); | ||
} | ||
run() { | ||
return this.exhaustive(); | ||
} | ||
returnType() { | ||
return this; | ||
} | ||
}; | ||
// src/rules/ensure-use-callback-has-non-empty-deps.ts | ||
var RULE_NAME2 = "ensure-use-callback-has-non-empty-deps"; | ||
var ensure_use_callback_has_non_empty_deps_default = createRule({ | ||
name: RULE_NAME2, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce 'useCallback' has non-empty dependencies array", | ||
requiresTypeChecking: false | ||
}, | ||
defaultOptions: [], | ||
create (context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useCallback ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression (node) { | ||
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope(); | ||
if (!core.isReactHookCall(node)) return; | ||
if (!core.isUseCallbackCall(node, context, pragma) && !alias.some(flip(core.isReactHookCallWithNameLoose)(node))) { | ||
return; | ||
} | ||
const [_, deps] = node.arguments; | ||
if (!deps) { | ||
context.report({ | ||
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS", | ||
node | ||
}); | ||
return; | ||
} | ||
const maybeDescriptor = pipe(match(deps).with({ | ||
type: ast.NodeType.ArrayExpression | ||
}, some).with({ | ||
type: ast.NodeType.Identifier | ||
}, (n)=>{ | ||
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), filter(ast.is(ast.NodeType.ArrayExpression))); | ||
}).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({ | ||
node, | ||
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS" | ||
}))); | ||
map(maybeDescriptor, context.report); | ||
} | ||
}; | ||
schema: [], | ||
messages: { | ||
ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS: "useCallback should have a non-empty dependencies array" | ||
} | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useCallback ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression(node) { | ||
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope(); | ||
if (!core.isReactHookCall(node)) | ||
return; | ||
if (!core.isUseCallbackCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node))) { | ||
return; | ||
} | ||
const [_, deps] = node.arguments; | ||
if (!deps) { | ||
context.report({ | ||
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS", | ||
node | ||
}); | ||
return; | ||
} | ||
const maybeDescriptor = Function_exports.pipe( | ||
N(deps).with({ type: ast.NodeType.ArrayExpression }, Option_exports.some).with({ type: ast.NodeType.Identifier }, (n2) => { | ||
return Function_exports.pipe( | ||
_var.findVariable(n2.name, initialScope), | ||
Option_exports.flatMap(_var.getVariableInit(0)), | ||
Option_exports.filter(ast.is(ast.NodeType.ArrayExpression)) | ||
); | ||
}).otherwise(Option_exports.none), | ||
Option_exports.filter((x2) => x2.elements.length === 0), | ||
Option_exports.map(() => ({ | ||
node, | ||
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS" | ||
})) | ||
); | ||
Option_exports.map(maybeDescriptor, context.report); | ||
} | ||
}; | ||
} | ||
}); | ||
const RULE_NAME$1 = "ensure-use-memo-has-non-empty-deps"; | ||
var ensureUseMemoHasNonEmptyDeps = createRule({ | ||
name: RULE_NAME$1, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce 'useMemo' has non-empty dependencies array", | ||
requiresTypeChecking: false | ||
}, | ||
schema: [], | ||
messages: { | ||
ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS: "useMemo should have a non-empty dependencies array" | ||
} | ||
var RULE_NAME3 = "ensure-use-memo-has-non-empty-deps"; | ||
var ensure_use_memo_has_non_empty_deps_default = createRule({ | ||
name: RULE_NAME3, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "enforce 'useMemo' has non-empty dependencies array", | ||
requiresTypeChecking: false | ||
}, | ||
defaultOptions: [], | ||
create (context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useMemo ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression (node) { | ||
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope(); | ||
if (!core.isReactHookCall(node)) return; | ||
if (!core.isUseMemoCall(node, context, pragma) && !alias.some(flip(core.isReactHookCallWithNameLoose)(node))) return; | ||
const [_, deps] = node.arguments; | ||
if (!deps) { | ||
context.report({ | ||
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS", | ||
node | ||
}); | ||
return; | ||
} | ||
const maybeDescriptor = pipe(match(deps).with({ | ||
type: ast.NodeType.ArrayExpression | ||
}, some).with({ | ||
type: ast.NodeType.Identifier | ||
}, (n)=>{ | ||
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), filter(ast.is(ast.NodeType.ArrayExpression))); | ||
}).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({ | ||
node, | ||
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS" | ||
}))); | ||
map(maybeDescriptor, context.report); | ||
} | ||
}; | ||
schema: [], | ||
messages: { | ||
ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS: "useMemo should have a non-empty dependencies array" | ||
} | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useMemo ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression(node) { | ||
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope(); | ||
if (!core.isReactHookCall(node)) | ||
return; | ||
if (!core.isUseMemoCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node))) | ||
return; | ||
const [_, deps] = node.arguments; | ||
if (!deps) { | ||
context.report({ | ||
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS", | ||
node | ||
}); | ||
return; | ||
} | ||
const maybeDescriptor = Function_exports.pipe( | ||
N(deps).with({ type: ast.NodeType.ArrayExpression }, Option_exports.some).with({ type: ast.NodeType.Identifier }, (n2) => { | ||
return Function_exports.pipe( | ||
_var.findVariable(n2.name, initialScope), | ||
Option_exports.flatMap(_var.getVariableInit(0)), | ||
Option_exports.filter(ast.is(ast.NodeType.ArrayExpression)) | ||
); | ||
}).otherwise(Option_exports.none), | ||
Option_exports.filter((x2) => x2.elements.length === 0), | ||
Option_exports.map(() => ({ | ||
node, | ||
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS" | ||
})) | ||
); | ||
Option_exports.map(maybeDescriptor, context.report); | ||
} | ||
}; | ||
} | ||
}); | ||
// Ported from https://github.com/jsx-eslint/eslint-plugin-react/pull/3579/commits/ebb739a0fe99a2ee77055870bfda9f67a2691374 | ||
const RULE_NAME = "prefer-use-state-lazy-initialization"; | ||
// variables should be defined here | ||
const ALLOW_LIST = Object.freeze([ | ||
"Boolean", | ||
"String", | ||
"Number" | ||
]); | ||
// rule takes inspiration from https://github.com/facebook/react/issues/26520 | ||
var preferUseStateLazyInitialization = createRule({ | ||
name: RULE_NAME, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "disallow function calls in 'useState' that aren't wrapped in an initializer function", | ||
requiresTypeChecking: false | ||
}, | ||
schema: [], | ||
messages: { | ||
PREFER_USE_STATE_LAZY_INITIALIZATION: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'" | ||
} | ||
var RULE_NAME4 = "prefer-use-state-lazy-initialization"; | ||
var ALLOW_LIST = Object.freeze(["Boolean", "String", "Number"]); | ||
var prefer_use_state_lazy_initialization_default = createRule({ | ||
name: RULE_NAME4, | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "disallow function calls in 'useState' that aren't wrapped in an initializer function", | ||
requiresTypeChecking: false | ||
}, | ||
defaultOptions: [], | ||
create (context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useState ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression (node) { | ||
if (!core.isReactHookCall(node)) return; | ||
if (!core.isUseStateCall(node, context, pragma) && !alias.some(flip(core.isReactHookCallWithNameLoose)(node))) return; | ||
const [useStateInput] = node.arguments; | ||
if (!useStateInput) return; | ||
const nestedCallExpressions = ast.getNestedCallExpressions(useStateInput); | ||
const hasFunctionCall = nestedCallExpressions.some((n)=>{ | ||
return "name" in n.callee && !ALLOW_LIST.includes(n.callee.name); | ||
}); | ||
if (!hasFunctionCall) return; | ||
context.report({ | ||
node: useStateInput, | ||
messageId: "PREFER_USE_STATE_LAZY_INITIALIZATION" | ||
}); | ||
} | ||
}; | ||
schema: [], | ||
messages: { | ||
PREFER_USE_STATE_LAZY_INITIALIZATION: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'" | ||
} | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useState ?? []; | ||
const pragma = jsx.getPragmaFromContext(context); | ||
return { | ||
CallExpression(node) { | ||
if (!core.isReactHookCall(node)) | ||
return; | ||
if (!core.isUseStateCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node))) | ||
return; | ||
const [useStateInput] = node.arguments; | ||
if (!useStateInput) | ||
return; | ||
const nestedCallExpressions = ast.getNestedCallExpressions(useStateInput); | ||
const hasFunctionCall = nestedCallExpressions.some((n2) => { | ||
return "name" in n2.callee && !ALLOW_LIST.includes(n2.callee.name); | ||
}); | ||
if (!hasFunctionCall) | ||
return; | ||
context.report({ | ||
node: useStateInput, | ||
messageId: "PREFER_USE_STATE_LAZY_INITIALIZATION" | ||
}); | ||
} | ||
}; | ||
} | ||
}); | ||
// Workaround for @typescript-eslint/utils's TS2742 error. | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const meta = { | ||
name, | ||
version | ||
// src/index.ts | ||
var meta = { | ||
name, | ||
version | ||
}; | ||
const rules = { | ||
"ensure-custom-hooks-using-other-hooks": ensureCustomHooksUsingOtherHooks, | ||
"ensure-use-callback-has-non-empty-deps": ensureUseCallbackHasNonEmptyDeps, | ||
"ensure-use-memo-has-non-empty-deps": ensureUseMemoHasNonEmptyDeps, | ||
"prefer-use-state-lazy-initialization": preferUseStateLazyInitialization | ||
var rules = { | ||
"ensure-custom-hooks-using-other-hooks": ensure_custom_hooks_using_other_hooks_default, | ||
"ensure-use-callback-has-non-empty-deps": ensure_use_callback_has_non_empty_deps_default, | ||
"ensure-use-memo-has-non-empty-deps": ensure_use_memo_has_non_empty_deps_default, | ||
"prefer-use-state-lazy-initialization": prefer_use_state_lazy_initialization_default | ||
}; | ||
@@ -1061,0 +1376,0 @@ |
{ | ||
"name": "eslint-plugin-react-hooks-extra", | ||
"version": "1.5.3", | ||
"version": "1.5.4-beta.0", | ||
"description": "ESLint React's ESLint plugin for React Hooks related rules.", | ||
@@ -44,9 +44,9 @@ "homepage": "https://github.com/rel1cx/eslint-react", | ||
"string-ts": "2.0.0", | ||
"@eslint-react/ast": "1.5.3", | ||
"@eslint-react/core": "1.5.3", | ||
"@eslint-react/jsx": "1.5.3", | ||
"@eslint-react/shared": "1.5.3", | ||
"@eslint-react/tools": "1.5.3", | ||
"@eslint-react/types": "1.5.3", | ||
"@eslint-react/var": "1.5.3" | ||
"@eslint-react/ast": "1.5.4-beta.0", | ||
"@eslint-react/core": "1.5.4-beta.0", | ||
"@eslint-react/jsx": "1.5.4-beta.0", | ||
"@eslint-react/shared": "1.5.4-beta.0", | ||
"@eslint-react/tools": "1.5.4-beta.0", | ||
"@eslint-react/types": "1.5.4-beta.0", | ||
"@eslint-react/var": "1.5.4-beta.0" | ||
}, | ||
@@ -68,3 +68,3 @@ "devDependencies": { | ||
"scripts": { | ||
"build": "rollup -c rollup.config.ts --configPlugin swc3 && cp dist/index.d.ts dist/index.d.mts", | ||
"build": "tsup", | ||
"build:docs": "typedoc", | ||
@@ -71,0 +71,0 @@ "lint:publish": "publint", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
88920
6
2670
1
+ Added@eslint-react/ast@1.5.4-beta.0(transitive)
+ Added@eslint-react/core@1.5.4-beta.0(transitive)
+ Added@eslint-react/jsx@1.5.4-beta.0(transitive)
+ Added@eslint-react/shared@1.5.4-beta.0(transitive)
+ Added@eslint-react/tools@1.5.4-beta.0(transitive)
+ Added@eslint-react/types@1.5.4-beta.0(transitive)
+ Added@eslint-react/var@1.5.4-beta.0(transitive)
- Removed@eslint-react/ast@1.5.3(transitive)
- Removed@eslint-react/core@1.5.3(transitive)
- Removed@eslint-react/jsx@1.5.3(transitive)
- Removed@eslint-react/shared@1.5.3(transitive)
- Removed@eslint-react/tools@1.5.3(transitive)
- Removed@eslint-react/types@1.5.3(transitive)
- Removed@eslint-react/var@1.5.3(transitive)