eslint-plugin-react-web-api 3.0.0-next.71 → 3.0.0-next.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +122 -2
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ import { findEnclosingAssignmentTarget, isAssignmentTargetEqual, isValueEqual, r
5
5
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
6
6
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
- import { dual, or } from "@eslint-react/eff";
9
8
  import birecord from "birecord";
10
9
 
11
10
  //#region \0rolldown/runtime.js
@@ -27,7 +26,128 @@ var __exportAll = (all, no_symbols) => {
27
26
  //#endregion
28
27
  //#region package.json
29
28
  var name$1 = "eslint-plugin-react-web-api";
30
- var version = "3.0.0-next.71";
29
+ var version = "3.0.0-next.76";
30
+
31
+ //#endregion
32
+ //#region ../../../.pkgs/eff/dist/index.js
33
+ function or(a, b) {
34
+ return (data) => a(data) || b(data);
35
+ }
36
+ /**
37
+ * Creates a function that can be used in a data-last (aka `pipe`able) or
38
+ * data-first style.
39
+ *
40
+ * The first parameter to `dual` is either the arity of the uncurried function
41
+ * or a predicate that determines if the function is being used in a data-first
42
+ * or data-last style.
43
+ *
44
+ * Using the arity is the most common use case, but there are some cases where
45
+ * you may want to use a predicate. For example, if you have a function that
46
+ * takes an optional argument, you can use a predicate to determine if the
47
+ * function is being used in a data-first or data-last style.
48
+ *
49
+ * You can pass either the arity of the uncurried function or a predicate
50
+ * which determines if the function is being used in a data-first or
51
+ * data-last style.
52
+ *
53
+ * **Example** (Using arity to determine data-first or data-last style)
54
+ *
55
+ * ```ts
56
+ * import { dual, pipe } from "effect/Function"
57
+ *
58
+ * const sum = dual<
59
+ * (that: number) => (self: number) => number,
60
+ * (self: number, that: number) => number
61
+ * >(2, (self, that) => self + that)
62
+ *
63
+ * console.log(sum(2, 3)) // 5
64
+ * console.log(pipe(2, sum(3))) // 5
65
+ * ```
66
+ *
67
+ * **Example** (Using call signatures to define the overloads)
68
+ *
69
+ * ```ts
70
+ * import { dual, pipe } from "effect/Function"
71
+ *
72
+ * const sum: {
73
+ * (that: number): (self: number) => number
74
+ * (self: number, that: number): number
75
+ * } = dual(2, (self: number, that: number): number => self + that)
76
+ *
77
+ * console.log(sum(2, 3)) // 5
78
+ * console.log(pipe(2, sum(3))) // 5
79
+ * ```
80
+ *
81
+ * **Example** (Using a predicate to determine data-first or data-last style)
82
+ *
83
+ * ```ts
84
+ * import { dual, pipe } from "effect/Function"
85
+ *
86
+ * const sum = dual<
87
+ * (that: number) => (self: number) => number,
88
+ * (self: number, that: number) => number
89
+ * >(
90
+ * (args) => args.length === 2,
91
+ * (self, that) => self + that
92
+ * )
93
+ *
94
+ * console.log(sum(2, 3)) // 5
95
+ * console.log(pipe(2, sum(3))) // 5
96
+ * ```
97
+ *
98
+ * @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.
99
+ * @param body - The function to be curried.
100
+ * @since 1.0.0
101
+ */
102
+ const dual = function(arity, body) {
103
+ if (typeof arity === "function") return function() {
104
+ return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
105
+ };
106
+ switch (arity) {
107
+ case 0:
108
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
109
+ case 2: return function(a, b) {
110
+ if (arguments.length >= 2) return body(a, b);
111
+ return function(self) {
112
+ return body(self, a);
113
+ };
114
+ };
115
+ case 3: return function(a, b, c) {
116
+ if (arguments.length >= 3) return body(a, b, c);
117
+ return function(self) {
118
+ return body(self, a, b);
119
+ };
120
+ };
121
+ default: return function() {
122
+ if (arguments.length >= arity) return body.apply(this, arguments);
123
+ const args = arguments;
124
+ return function(self) {
125
+ return body(self, ...args);
126
+ };
127
+ };
128
+ }
129
+ };
130
+ /**
131
+ * 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`.
132
+ * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
133
+ *
134
+ * @param self - The first function to apply (or the composed function in data-last style).
135
+ * @param bc - The second function to apply.
136
+ * @returns A composed function that applies both functions in sequence.
137
+ * @example
138
+ * ```ts
139
+ * import * as assert from "node:assert"
140
+ * import { compose } from "effect/Function"
141
+ *
142
+ * const increment = (n: number) => n + 1;
143
+ * const square = (n: number) => n * n;
144
+ *
145
+ * assert.strictEqual(compose(increment, square)(2), 9);
146
+ * ```
147
+ *
148
+ * @since 1.0.0
149
+ */
150
+ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
31
151
 
32
152
  //#endregion
33
153
  //#region src/types/component-phase.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "3.0.0-next.71",
3
+ "version": "3.0.0-next.76",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,11 +43,11 @@
43
43
  "@typescript-eslint/utils": "canary",
44
44
  "birecord": "^0.1.1",
45
45
  "ts-pattern": "^5.9.0",
46
- "@eslint-react/ast": "3.0.0-next.71",
47
- "@eslint-react/eff": "3.0.0-next.71",
48
- "@eslint-react/var": "3.0.0-next.71",
49
- "@eslint-react/core": "3.0.0-next.71",
50
- "@eslint-react/shared": "3.0.0-next.71"
46
+ "@eslint-react/ast": "3.0.0-next.76",
47
+ "@eslint-react/core": "3.0.0-next.76",
48
+ "@eslint-react/shared": "3.0.0-next.76",
49
+ "@eslint-react/var": "3.0.0-next.76",
50
+ "@local/eff": "3.0.0-beta.72"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",
@@ -57,8 +57,8 @@
57
57
  "@local/configs": "0.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
61
- "typescript": ">=4.8.4 <6.0.0"
60
+ "eslint": "^10.0.0",
61
+ "typescript": "*"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22.0.0"