New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-react-dom

Package Overview
Dependencies
Maintainers
1
Versions
919
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-dom - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1-next.1

1019

dist/index.js

@@ -5,3 +5,2 @@ 'use strict';

var jsx = require('@eslint-react/jsx');
var tools = require('@eslint-react/tools');
var shared = require('@eslint-react/shared');

@@ -12,4 +11,954 @@ var _var = require('@eslint-react/var');

var name = "eslint-plugin-react-dom";
var version = "1.5.0";
var version = "1.5.1-next.1";
/**
* 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) {
if (typeof arity === "function") {
return function () {
if (arity(arguments)) {
// @ts-expect-error
return body.apply(this, arguments);
}
return self => body(self, ...arguments);
};
}
switch (arity) {
case 0:
case 1:
throw new RangeError(`Invalid arity ${arity}`);
case 2:
return function (a, b) {
if (arguments.length >= 2) {
return body(a, b);
}
return function (self) {
return body(self, a);
};
};
case 3:
return function (a, b, c) {
if (arguments.length >= 3) {
return body(a, b, c);
}
return function (self) {
return body(self, a, b);
};
};
case 4:
return function (a, b, c, d) {
if (arguments.length >= 4) {
return body(a, b, c, d);
}
return function (self) {
return body(self, a, b, c);
};
};
case 5:
return function (a, b, c, d, e) {
if (arguments.length >= 5) {
return body(a, b, c, d, e);
}
return function (self) {
return body(self, a, b, c, d);
};
};
default:
return function () {
if (arguments.length >= arity) {
// @ts-expect-error
return body.apply(this, arguments);
}
const args = arguments;
return function (self) {
return body(self, ...args);
};
};
}
};
/**
* Creates a constant value that never changes.
*
* This is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument)
* and want that inner function to always use the same value, no matter how many times it is called.
*
* @param value - The constant value to be returned.
*
* @example
* import { constant } from "effect/Function"
*
* const constNull = constant(null)
*
* assert.deepStrictEqual(constNull(), null)
* assert.deepStrictEqual(constNull(), null)
*
* @since 2.0.0
*/
const constant = value => () => value;
/**
* A thunk that returns always `false`.
*
* @example
* import { constFalse } from "effect/Function"
*
* assert.deepStrictEqual(constFalse(), false)
*
* @since 2.0.0
*/
const constFalse = /*#__PURE__*/constant(false);
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
switch (arguments.length) {
case 1:
return a;
case 2:
return ab(a);
case 3:
return bc(ab(a));
case 4:
return cd(bc(ab(a)));
case 5:
return de(cd(bc(ab(a))));
case 6:
return ef(de(cd(bc(ab(a)))));
case 7:
return fg(ef(de(cd(bc(ab(a))))));
case 8:
return gh(fg(ef(de(cd(bc(ab(a)))))));
case 9:
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;
}
}
}
const moduleVersion = "2.2.2";
/**
* @since 2.0.0
*/
const globalStoreId = /*#__PURE__*/Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
if (!(globalStoreId in globalThis)) {
globalThis[globalStoreId] = /*#__PURE__*/new Map();
}
const globalStore = globalThis[globalStoreId];
/**
* @since 2.0.0
*/
const globalValue = (id, compute) => {
if (!globalStore.has(id)) {
globalStore.set(id, compute());
}
return globalStore.get(id);
};
/**
* @since 2.0.0
*/
/**
* Tests if a value is a `string`.
*
* @param input - The value to test.
*
* @example
* import { isString } from "effect/Predicate"
*
* assert.deepStrictEqual(isString("a"), true)
*
* assert.deepStrictEqual(isString(1), false)
*
* @category guards
* @since 2.0.0
*/
const isString = input => typeof input === "string";
/**
* 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;
/**
* @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 {
_state;
constructor(seedHi, seedLo, incHi, incLo) {
if (isNullable(seedLo) && isNullable(seedHi)) {
seedLo = Math.random() * 0xffffffff >>> 0;
seedHi = 0;
} else if (isNullable(seedLo)) {
seedLo = seedHi;
seedHi = 0;
}
if (isNullable(incLo) && isNullable(incHi)) {
incLo = this._state ? this._state[3] : defaultIncLo;
incHi = this._state ? this._state[2] : defaultIncHi;
} else if (isNullable(incLo)) {
incLo = incHi;
incHi = 0;
}
this._state = new Int32Array([0, 0, incHi >>> 0, ((incLo || 0) | 1) >>> 0]);
this._next();
add64(this._state, this._state[0], this._state[1], seedHi >>> 0, seedLo >>> 0);
this._next();
return this;
}
/**
* Returns a copy of the internal state of this random number generator as a
* JavaScript Array.
*
* @category getters
* @since 2.0.0
*/
getState() {
return [this._state[0], this._state[1], this._state[2], this._state[3]];
}
/**
* Restore state previously retrieved using `getState()`.
*
* @since 2.0.0
*/
setState(state) {
this._state[0] = state[0];
this._state[1] = state[1];
this._state[2] = state[2];
this._state[3] = state[3] | 1;
}
/**
* Get a uniformly distributed 32 bit integer between [0, max).
*
* @category getter
* @since 2.0.0
*/
integer(max) {
if (!max) {
return this._next();
}
max = max >>> 0;
if ((max & max - 1) === 0) {
return this._next() & max - 1; // fast path for power of 2
}
let num = 0;
const skew = (-max >>> 0) % max >>> 0;
for (num = this._next(); num < skew; num = this._next()) {
// this loop will rarely execute more than twice,
// and is intentionally empty
}
return num % max;
}
/**
* Get a uniformly distributed IEEE-754 double between 0.0 and 1.0, with
* 53 bits of precision (every bit of the mantissa is randomized).
*
* @category getters
* @since 2.0.0
*/
number() {
const hi = (this._next() & 0x03ffffff) * 1.0;
const lo = (this._next() & 0x07ffffff) * 1.0;
return (hi * BIT_27 + lo) / BIT_53;
}
/** @internal */
_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;
let xsLo = (oldLo >>> 18 | oldHi << 14) >>> 0;
xsHi = (xsHi ^ oldHi) >>> 0;
xsLo = (xsLo ^ oldLo) >>> 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;
const rot2 = (-rot >>> 0 & 31) >>> 0;
return (xorshifted >>> rot | xorshifted << rot2) >>> 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 hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
c0 = c0 << 16 >>> 0;
lo = lo + c0 >>> 0;
if (lo >>> 0 < c0 >>> 0) {
hi = hi + 1 >>> 0;
}
c1 = c1 << 16 >>> 0;
lo = lo + c1 >>> 0;
if (lo >>> 0 < c1 >>> 0) {
hi = hi + 1 >>> 0;
}
hi = hi + Math.imul(aLo, bHi) >>> 0;
hi = hi + Math.imul(aHi, bLo) >>> 0;
out[0] = hi;
out[1] = lo;
}
// add two 64 bit numbers (given in parts), and store the result in `out`.
function add64(out, aHi, aLo, bHi, bLo) {
let hi = aHi + bHi >>> 0;
const lo = aLo + bLo >>> 0;
if (lo >>> 0 < aLo >>> 0) {
hi = hi + 1 | 0;
}
out[0] = hi;
out[1] = lo;
}
/**
* @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 => {
switch (typeof self) {
case "number":
return number(self);
case "bigint":
return string(self.toString(10));
case "boolean":
return string(String(self));
case "symbol":
return string(String(self));
case "string":
return string(self);
case "undefined":
return string("undefined");
case "function":
case "object":
{
if (self === null) {
return string("null");
}
if (isHash(self)) {
return self[symbol$1]();
} else {
return random(self);
}
}
default:
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 => {
if (!randomHashCache.has(self)) {
randomHashCache.set(self, number(pcgr.integer(Number.MAX_SAFE_INTEGER)));
}
return randomHashCache.get(self);
};
/**
* @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) {
return 0;
}
let h = n | 0;
if (h !== n) {
h ^= n * 0xffffffff;
}
while (n > 0xffffffff) {
h ^= n /= 0xffffffff;
}
return optimize(n);
};
/**
* @since 2.0.0
* @category hashing
*/
const string = str => {
let h = 5381,
i = str.length;
while (i) {
h = h * 33 ^ str.charCodeAt(--i);
}
return optimize(h);
};
/**
* @since 2.0.0
* @category symbols
*/
const symbol = /*#__PURE__*/Symbol.for("effect/Equal");
function equals() {
if (arguments.length === 1) {
return self => compareBoth(self, arguments[0]);
}
return compareBoth(arguments[0], arguments[1]);
}
function compareBoth(self, that) {
if (self === that) {
return true;
}
const selfType = typeof self;
if (selfType !== typeof that) {
return false;
}
if ((selfType === "object" || selfType === "function") && self !== null && that !== null) {
if (isEqual(self) && isEqual(that)) {
return hash(self) === hash(that) && self[symbol](that);
}
}
return false;
}
/**
* @since 2.0.0
* @category guards
*/
const isEqual = u => hasProperty(u, symbol);
/**
* @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);
}
return x;
};
/**
* @since 2.0.0
*/
const format = x => JSON.stringify(x, null, 2);
/**
* @since 2.0.0
*/
/**
* @since 2.0.0
*/
const pipeArguments = (self, args) => {
switch (args.length) {
case 1:
return args[0](self);
case 2:
return args[1](args[0](self));
case 3:
return args[2](args[1](args[0](self)));
case 4:
return args[3](args[2](args[1](args[0](self))));
case 5:
return args[4](args[3](args[2](args[1](args[0](self)))));
case 6:
return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
case 7:
return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
case 8:
return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
case 9:
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;
}
}
};
/** @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 = {
/* c8 ignore next */
_R: _ => _,
/* c8 ignore next */
_E: _ => _,
/* c8 ignore next */
_A: _ => _,
_V: moduleVersion
};
const sinkVariance = {
/* c8 ignore next */
_R: _ => _,
/* c8 ignore next */
_E: _ => _,
/* c8 ignore next */
_In: _ => _,
/* c8 ignore next */
_L: _ => _,
/* c8 ignore next */
_Z: _ => _
};
const channelVariance = {
/* c8 ignore next */
_Env: _ => _,
/* c8 ignore next */
_InErr: _ => _,
/* c8 ignore next */
_InElem: _ => _,
/* c8 ignore next */
_InDone: _ => _,
/* c8 ignore next */
_OutErr: _ => _,
/* c8 ignore next */
_OutElem: _ => _,
/* c8 ignore next */
_OutDone: _ => _
};
/** @internal */
const EffectPrototype = {
[EffectTypeId]: effectVariance,
[StreamTypeId]: effectVariance,
[SinkTypeId]: sinkVariance,
[ChannelTypeId]: channelVariance,
[symbol](that) {
return this === that;
},
[symbol$1]() {
return random(this);
},
pipe() {
return pipeArguments(this, arguments);
}
};
/**
* @since 2.0.0
*/
const TypeId = /*#__PURE__*/Symbol.for("effect/Option");
const CommonProto = {
...EffectPrototype,
[TypeId]: {
_A: _ => _
},
[NodeInspectSymbol]() {
return this.toJSON();
},
toString() {
return format(this.toJSON());
}
};
const SomeProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), {
_tag: "Some",
_op: "Some",
[symbol](that) {
return isOption(that) && isSome$1(that) && equals(that.value, this.value);
},
[symbol$1]() {
return combine(hash(this._tag))(hash(this.value));
},
toJSON() {
return {
_id: "Option",
_tag: this._tag,
value: toJSON(this.value)
};
}
});
const NoneProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonProto), {
_tag: "None",
_op: "None",
[symbol](that) {
return isOption(that) && isNone$1(that);
},
[symbol$1]() {
return combine(hash(this._tag));
},
toJSON() {
return {
_id: "Option",
_tag: this._tag
};
}
});
/** @internal */
const isOption = input => hasProperty(input, TypeId);
/** @internal */
const isNone$1 = fa => fa._tag === "None";
/** @internal */
const isSome$1 = fa => fa._tag === "Some";
/** @internal */
const none$1 = /*#__PURE__*/Object.create(NoneProto);
/** @internal */
const some$1 = value => {
const a = Object.create(SomeProto);
a.value = value;
return a;
};
/**
* 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;
/**
* Determine if a `Option` is a `Some`.
*
* @param self - The `Option` to check.
*
* @example
* import { some, none, isSome } from 'effect/Option'
*
* assert.deepStrictEqual(isSome(some(1)), true)
* assert.deepStrictEqual(isSome(none()), false)
*
* @category guards
* @since 2.0.0
*/
const isSome = isSome$1;
/**
* Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
* returns the value wrapped in a `Some`.
*
* @param nullableValue - The nullable value to be converted to an `Option`.
*
* @example
* import * as O from "effect/Option"
*
* assert.deepStrictEqual(O.fromNullable(undefined), O.none())
* assert.deepStrictEqual(O.fromNullable(null), O.none())
* assert.deepStrictEqual(O.fromNullable(1), O.some(1))
*
* @category conversions
* @since 2.0.0
*/
const fromNullable = nullableValue => nullableValue == null ? none() : some(nullableValue);
/**
* 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));
/**
* This is `flatMap` + `fromNullable`, useful when working with optional values.
*
* @example
* import { some, none, flatMapNullable } from 'effect/Option'
* import { pipe } from "effect/Function"
*
* interface Employee {
* company?: {
* address?: {
* street?: {
* name?: string
* }
* }
* }
* }
*
* const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
*
* assert.deepStrictEqual(
* pipe(
* some(employee1),
* flatMapNullable(employee => employee.company?.address?.street?.name),
* ),
* some('high street')
* )
*
* const employee2: Employee = { company: { address: { street: {} } } }
*
* assert.deepStrictEqual(
* pipe(
* some(employee2),
* flatMapNullable(employee => employee.company?.address?.street?.name),
* ),
* none()
* )
*
* @category sequencing
* @since 2.0.0
*/
const flatMapNullable = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : fromNullable(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));
/**
* Check if a value in an `Option` type meets a certain predicate.
*
* @param self - The `Option` to check.
* @param predicate - The condition to check.
*
* @example
* import { some, none, exists } from 'effect/Option'
* import { pipe } from "effect/Function"
*
* const isEven = (n: number) => n % 2 === 0
*
* assert.deepStrictEqual(pipe(some(2), exists(isEven)), true)
* assert.deepStrictEqual(pipe(some(1), exists(isEven)), false)
* assert.deepStrictEqual(pipe(none(), exists(isEven)), false)
*
* @since 2.0.0
*/
const exists = /*#__PURE__*/dual(2, (self, refinement) => isNone(self) ? false : refinement(self.value));
/**
* 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;
const createRule = shared.createRuleForPlugin("dom");

@@ -81,3 +1030,3 @@

const findProp = jsx.findPropInProperties(props, context, initialScope);
const hasChildrenOrDangerProp = tools.O.isSome(findProp("children")) || tools.O.isSome(findProp("dangerouslySetInnerHTML"));
const hasChildrenOrDangerProp = isSome(findProp("children")) || isSome(findProp("dangerouslySetInnerHTML"));
if (hasChildrenOrDangerProp) {

@@ -111,3 +1060,3 @@ // e.g. React.createElement('br', { children: 'Foo' })

const findAttr = jsx.findPropInAttributes(attributes, context, initialScope);
const hasChildrenOrDangerAttr = tools.O.isSome(findAttr("children")) || tools.O.isSome(findAttr("dangerouslySetInnerHTML"));
const hasChildrenOrDangerAttr = isSome(findAttr("children")) || isSome(findAttr("dangerouslySetInnerHTML"));
if (hasChildrenOrDangerAttr) {

@@ -161,10 +1110,10 @@ // e.g. <br children="Foo" />

]), (n)=>{
return "properties" in n ? tools.O.some(n.properties) : tools.O.none();
return "properties" in n ? some(n.properties) : none();
}).when(ast.is(ast.NodeType.Identifier), (n)=>{
const initialScope = context.sourceCode.getScope?.(n) ?? context.getScope();
return tools.F.pipe(_var.findVariable(n.name, initialScope), tools.O.flatMap(_var.getVariableInit(0)), tools.O.flatMap((n)=>"properties" in n ? tools.O.fromNullable(n.properties) : tools.O.none()));
}).otherwise(tools.O.none);
if (tools.O.isNone(maybeProperties)) return;
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), flatMap((n)=>"properties" in n ? fromNullable(n.properties) : none()));
}).otherwise(none);
if (isNone(maybeProperties)) return;
const properties = maybeProperties.value;
const hasDanger = tools.O.isSome(jsx.findPropInProperties(properties, context, initialScope)("dangerouslySetInnerHTML"));
const hasDanger = isSome(jsx.findPropInProperties(properties, context, initialScope)("dangerouslySetInnerHTML"));
if (hasDanger) {

@@ -180,3 +1129,3 @@ context.report({

const maybeDanger = jsx.findPropInAttributes(node.openingElement.attributes, context, initialScope)("dangerouslySetInnerHTML");
if (tools.O.isSome(maybeDanger)) {
if (isSome(maybeDanger)) {
context.report({

@@ -195,3 +1144,3 @@ messageId: "NO_DANGEROUSLY_SET_INNERHTML",

const [firstChild] = node.children;
return node.children.length > 0 && !tools.Prd.isNullable(firstChild) && !jsx.isLineBreak(firstChild);
return node.children.length > 0 && !isNullable(firstChild) && !jsx.isLineBreak(firstChild);
}

@@ -223,12 +1172,12 @@ var noDangerouslySetInnerHTMLWithChildren = createRule({

]), (n)=>{
return "properties" in n ? tools.O.some(n.properties) : tools.O.none();
return "properties" in n ? some(n.properties) : none();
}).when(ast.is(ast.NodeType.Identifier), (n)=>{
const initialScope = context.sourceCode.getScope?.(n) ?? context.getScope();
return tools.F.pipe(_var.findVariable(n.name, initialScope), tools.O.flatMap(_var.getVariableInit(0)), tools.O.flatMap((n)=>"properties" in n ? tools.O.fromNullable(n.properties) : tools.O.none()));
}).otherwise(tools.O.none);
if (tools.O.isNone(maybeProperties)) return;
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), flatMap((n)=>"properties" in n ? fromNullable(n.properties) : none()));
}).otherwise(none);
if (isNone(maybeProperties)) return;
const properties = maybeProperties.value;
const hasDanger = tools.O.isSome(jsx.findPropInProperties(properties, context, initialScope)("dangerouslySetInnerHTML"));
const hasDanger = isSome(jsx.findPropInProperties(properties, context, initialScope)("dangerouslySetInnerHTML"));
const hasRestChildren = node.arguments.length > 2;
if (hasDanger && (hasRestChildren || tools.O.isSome(jsx.findPropInProperties(properties, context, initialScope)("children")))) {
if (hasDanger && (hasRestChildren || isSome(jsx.findPropInProperties(properties, context, initialScope)("children")))) {
context.report({

@@ -280,3 +1229,3 @@ messageId: "NO_DANGEROUSLY_SET_INNERHTML_WITH_CHILDREN",

type: ast.NodeType.MemberExpression
}, ({ property })=>"name" in property && property.name === "findDOMNode").otherwise(tools.F.constFalse);
}, ({ property })=>"name" in property && property.name === "findDOMNode").otherwise(constFalse);
if (!isFindDOMNode) return;

@@ -331,3 +1280,3 @@ context.report({

const maybeTypeProperty = jsx.findPropInProperties(props.properties, context, initialScope)("type");
if (tools.O.isNone(maybeTypeProperty)) {
if (isNone(maybeTypeProperty)) {
context.report({

@@ -359,3 +1308,3 @@ messageId: "NO_MISSING_BUTTON_TYPE",

const maybeTypeAttribute = jsx.findPropInAttributes(attributes, context, initialScope)("type");
if (tools.O.isNone(maybeTypeAttribute)) {
if (isNone(maybeTypeAttribute)) {
context.report({

@@ -368,3 +1317,3 @@ messageId: "NO_MISSING_BUTTON_TYPE",

const typeAttribute = maybeTypeAttribute.value;
const hasValidType = tools.F.pipe(jsx.getPropValue(typeAttribute, context), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.exists((value)=>validTypes$1.some((type)=>type === value)));
const hasValidType = pipe(jsx.getPropValue(typeAttribute, context), flatMapNullable((v)=>v?.value), filter(isString), exists((value)=>validTypes$1.some((type)=>type === value)));
if (hasValidType) return;

@@ -431,3 +1380,3 @@ context.report({

const maybeSandboxProperty = jsx.findPropInProperties(props.properties, context, initialScope)("sandbox");
if (tools.O.isNone(maybeSandboxProperty)) {
if (isNone(maybeSandboxProperty)) {
context.report({

@@ -459,3 +1408,3 @@ messageId: "NO_MISSING_IFRAME_SANDBOX",

const maybeSandboxAttribute = jsx.findPropInAttributes(attributes, context, initialScope)("sandbox");
if (tools.O.isNone(maybeSandboxAttribute)) {
if (isNone(maybeSandboxAttribute)) {
context.report({

@@ -468,3 +1417,3 @@ messageId: "NO_MISSING_IFRAME_SANDBOX",

const sandboxAttribute = maybeSandboxAttribute.value;
const hasValidSandbox = tools.F.pipe(jsx.getPropValue(sandboxAttribute, context), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.map((value)=>value.split(" ")), tools.O.exists((values)=>values.every((value)=>validTypes.some((validType)=>validType === value))));
const hasValidSandbox = pipe(jsx.getPropValue(sandboxAttribute, context), flatMapNullable((v)=>v?.value), filter(isString), map((value)=>value.split(" ")), exists((values)=>values.every((value)=>validTypes.some((validType)=>validType === value))));
if (hasValidSandbox) return;

@@ -499,3 +1448,3 @@ context.report({

const name = node.arguments[0].value;
if (!tools.Prd.isString(name) || !name.includes(":")) return;
if (!isString(name) || !name.includes(":")) return;
context.report({

@@ -512,3 +1461,3 @@ data: {

const name = jsx.elementType(node);
if (!tools.Prd.isString(name) || !name.includes(":")) return;
if (!isString(name) || !name.includes(":")) return;
context.report({

@@ -549,3 +1498,3 @@ data: {

if (node.name.type !== ast.NodeType.JSXIdentifier || !node.value) return;
const isJavaScript = tools.F.pipe(jsx.getPropValue(node, context), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.exists((v)=>shared.RE_JAVASCRIPT_PROTOCOL.test(v)));
const isJavaScript = pipe(jsx.getPropValue(node, context), flatMapNullable((v)=>v?.value), filter(isString), exists((v)=>shared.RE_JAVASCRIPT_PROTOCOL.test(v)));
if (isJavaScript) {

@@ -596,4 +1545,4 @@ context.report({

const maybeSandboxProperty = jsx.findPropInProperties(props.properties, context, initialScope)("sandbox");
if (tools.O.isNone(maybeSandboxProperty)) return;
const isSafeSandboxValue = !tools.F.pipe(maybeSandboxProperty, tools.O.filter(isMatching({
if (isNone(maybeSandboxProperty)) return;
const isSafeSandboxValue = !pipe(maybeSandboxProperty, filter(isMatching({
type: ast.NodeType.Property,

@@ -604,3 +1553,3 @@ value: {

}
})), tools.O.flatMapNullable((v)=>"value" in v ? v.value : null), tools.O.flatMapNullable((v)=>"value" in v ? v.value : null), tools.O.filter(tools.Prd.isString), tools.O.map((v)=>v.split(" ")), tools.O.exists((values)=>unsafeCombinations.some((combinations)=>combinations.every((unsafeValue)=>values.includes(unsafeValue)))));
})), flatMapNullable((v)=>"value" in v ? v.value : null), flatMapNullable((v)=>"value" in v ? v.value : null), filter(isString), map((v)=>v.split(" ")), exists((values)=>unsafeCombinations.some((combinations)=>combinations.every((unsafeValue)=>values.includes(unsafeValue)))));
if (isSafeSandboxValue) return;

@@ -618,4 +1567,4 @@ context.report({

const maybeSandboxAttribute = jsx.findPropInAttributes(attributes, context, initialScope)("sandbox");
if (tools.O.isNone(maybeSandboxAttribute)) return;
const isSafeSandboxValue = !tools.F.pipe(jsx.getPropValue(maybeSandboxAttribute.value, context), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.map((value)=>value.split(" ")), tools.O.exists((values)=>unsafeCombinations.some((combinations)=>combinations.every((unsafeValue)=>values.includes(unsafeValue)))));
if (isNone(maybeSandboxAttribute)) return;
const isSafeSandboxValue = !pipe(jsx.getPropValue(maybeSandboxAttribute.value, context), flatMapNullable((v)=>v?.value), filter(isString), map((value)=>value.split(" ")), exists((values)=>unsafeCombinations.some((combinations)=>combinations.every((unsafeValue)=>values.includes(unsafeValue)))));
if (isSafeSandboxValue) return;

@@ -658,10 +1607,10 @@ context.report({

const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
const hasTargetBlank = tools.F.pipe(jsx.findPropInAttributes(attributes, context, initialScope)("target"), tools.O.flatMap((attr)=>jsx.getPropValue(attr, context)), tools.O.exists((v)=>v?.value === "_blank"));
const hasTargetBlank = pipe(jsx.findPropInAttributes(attributes, context, initialScope)("target"), flatMap((attr)=>jsx.getPropValue(attr, context)), exists((v)=>v?.value === "_blank"));
if (!hasTargetBlank) return;
const hasExternalLinkLike = attributes.some((attr)=>{
if (attr.type !== ast.NodeType.JSXAttribute) return false;
return tools.F.pipe(jsx.getPropValue(attr, context), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.exists(isExternalLinkLike));
return pipe(jsx.getPropValue(attr, context), flatMapNullable((v)=>v?.value), filter(isString), exists(isExternalLinkLike));
});
if (!hasExternalLinkLike) return;
const hasUnsafeRel = !tools.F.pipe(jsx.findPropInAttributes(attributes, context, initialScope)("rel"), tools.O.flatMap((attr)=>jsx.getPropValue(attr, context)), tools.O.flatMapNullable((v)=>v?.value), tools.O.filter(tools.Prd.isString), tools.O.exists(isSafeRel));
const hasUnsafeRel = !pipe(jsx.findPropInAttributes(attributes, context, initialScope)("rel"), flatMap((attr)=>jsx.getPropValue(attr, context)), flatMapNullable((v)=>v?.value), filter(isString), exists(isSafeRel));
if (!hasUnsafeRel) return;

@@ -668,0 +1617,0 @@ context.report({

19

package.json
{
"name": "eslint-plugin-react-dom",
"version": "1.5.0",
"version": "1.5.1-next.1",
"description": "ESLint React's ESLint plugin for ReactDOM related rules.",

@@ -43,10 +43,13 @@ "homepage": "https://github.com/rel1cx/eslint-react",

"string-ts": "2.0.0",
"@eslint-react/ast": "1.5.0",
"@eslint-react/core": "1.5.0",
"@eslint-react/jsx": "1.5.0",
"@eslint-react/shared": "1.5.0",
"@eslint-react/tools": "1.5.0",
"@eslint-react/types": "1.5.0",
"@eslint-react/var": "1.5.0"
"@eslint-react/ast": "1.5.1-next.1",
"@eslint-react/core": "1.5.1-next.1",
"@eslint-react/jsx": "1.5.1-next.1",
"@eslint-react/shared": "1.5.1-next.1",
"@eslint-react/tools": "1.5.1-next.1",
"@eslint-react/types": "1.5.1-next.1",
"@eslint-react/var": "1.5.1-next.1"
},
"devDependencies": {
"effect": "2.2.2"
},
"peerDependencies": {

@@ -53,0 +56,0 @@ "@typescript-eslint/parser": ">=6.19.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc