eslint-plugin-react-debug
Advanced tools
+148
-2
@@ -5,3 +5,2 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener, getSettingsFromContext, report } from "@eslint-react/shared"; | ||
| import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils"; | ||
| import { flow } from "@eslint-react/eff"; | ||
| import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/types"; | ||
@@ -29,3 +28,3 @@ import { P, match } from "ts-pattern"; | ||
| var name$1 = "eslint-plugin-react-debug"; | ||
| var version = "3.0.0-beta.71"; | ||
| var version = "3.0.0-beta.74"; | ||
@@ -226,2 +225,149 @@ //#endregion | ||
| //#endregion | ||
| //#region ../../../.pkgs/eff/dist/index.js | ||
| /** | ||
| * 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. | ||
| * | ||
| * You can pass 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. | ||
| * | ||
| * **Example** (Using arity to determine data-first or data-last style) | ||
| * | ||
| * ```ts | ||
| * import { dual, pipe } from "effect/Function" | ||
| * | ||
| * const sum = dual< | ||
| * (that: number) => (self: number) => number, | ||
| * (self: number, that: number) => number | ||
| * >(2, (self, that) => self + that) | ||
| * | ||
| * console.log(sum(2, 3)) // 5 | ||
| * console.log(pipe(2, sum(3))) // 5 | ||
| * ``` | ||
| * | ||
| * **Example** (Using call signatures to define the overloads) | ||
| * | ||
| * ```ts | ||
| * import { dual, pipe } from "effect/Function" | ||
| * | ||
| * const sum: { | ||
| * (that: number): (self: number) => number | ||
| * (self: number, that: number): number | ||
| * } = dual(2, (self: number, that: number): number => self + that) | ||
| * | ||
| * console.log(sum(2, 3)) // 5 | ||
| * console.log(pipe(2, sum(3))) // 5 | ||
| * ``` | ||
| * | ||
| * **Example** (Using a predicate to determine data-first or data-last style) | ||
| * | ||
| * ```ts | ||
| * import { dual, pipe } from "effect/Function" | ||
| * | ||
| * const sum = dual< | ||
| * (that: number) => (self: number) => number, | ||
| * (self: number, that: number) => number | ||
| * >( | ||
| * (args) => args.length === 2, | ||
| * (self, that) => self + that | ||
| * ) | ||
| * | ||
| * console.log(sum(2, 3)) // 5 | ||
| * console.log(pipe(2, sum(3))) // 5 | ||
| * ``` | ||
| * | ||
| * @param arity - 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. | ||
| * @param body - The function to be curried. | ||
| * @since 1.0.0 | ||
| */ | ||
| const dual = function(arity, body) { | ||
| if (typeof arity === "function") return function() { | ||
| return arity(arguments) ? body.apply(this, arguments) : ((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); | ||
| }; | ||
| }; | ||
| default: return function() { | ||
| if (arguments.length >= arity) return body.apply(this, arguments); | ||
| const args = arguments; | ||
| return function(self) { | ||
| return body(self, ...args); | ||
| }; | ||
| }; | ||
| } | ||
| }; | ||
| /** | ||
| * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`. | ||
| * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`. | ||
| * | ||
| * @param self - The first function to apply (or the composed function in data-last style). | ||
| * @param bc - The second function to apply. | ||
| * @returns A composed function that applies both functions in sequence. | ||
| * @example | ||
| * ```ts | ||
| * import * as assert from "node:assert" | ||
| * import { compose } from "effect/Function" | ||
| * | ||
| * const increment = (n: number) => n + 1; | ||
| * const square = (n: number) => n * n; | ||
| * | ||
| * assert.strictEqual(compose(increment, square)(2), 9); | ||
| * ``` | ||
| * | ||
| * @since 1.0.0 | ||
| */ | ||
| const compose = dual(2, (ab, bc) => (a) => bc(ab(a))); | ||
| 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))))))))); | ||
| }; | ||
| } | ||
| } | ||
| //#endregion | ||
| //#region src/rules/jsx/jsx.ts | ||
@@ -228,0 +374,0 @@ const RULE_NAME = "jsx"; |
+8
-8
| { | ||
| "name": "eslint-plugin-react-debug", | ||
| "version": "3.0.0-beta.71", | ||
| "version": "3.0.0-beta.74", | ||
| "description": "ESLint React's ESLint plugin for debugging related rules.", | ||
@@ -46,7 +46,7 @@ "keywords": [ | ||
| "ts-pattern": "^5.9.0", | ||
| "@eslint-react/ast": "3.0.0-beta.71", | ||
| "@eslint-react/core": "3.0.0-beta.71", | ||
| "@eslint-react/eff": "3.0.0-beta.71", | ||
| "@eslint-react/shared": "3.0.0-beta.71", | ||
| "@eslint-react/var": "3.0.0-beta.71" | ||
| "@eslint-react/ast": "3.0.0-beta.74", | ||
| "@eslint-react/core": "3.0.0-beta.74", | ||
| "@eslint-react/shared": "3.0.0-beta.74", | ||
| "@eslint-react/var": "3.0.0-beta.74", | ||
| "@local/eff": "3.0.0-beta.72" | ||
| }, | ||
@@ -61,4 +61,4 @@ "devDependencies": { | ||
| "peerDependencies": { | ||
| "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", | ||
| "typescript": ">=4.8.4 <6.0.0" | ||
| "eslint": "^10.0.0", | ||
| "typescript": "*" | ||
| }, | ||
@@ -65,0 +65,0 @@ "engines": { |
18169
32.43%441
48.99%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed