eslint-plugin-react-rsc 5.10.4 → 5.11.2

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 +346 -3
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ const rules$4 = { "react-rsc/function-definition": "off" };
34
34
  //#endregion
35
35
  //#region package.json
36
36
  var name$4 = "eslint-plugin-react-rsc";
37
- var version = "5.10.4";
37
+ var version = "5.11.2";
38
38
 
39
39
  //#endregion
40
40
  //#region src/utils/create-rule.ts
@@ -43,6 +43,346 @@ function getDocsUrl(ruleName) {
43
43
  }
44
44
  const createRule = ESLintUtils.RuleCreator(getDocsUrl);
45
45
 
46
+ //#endregion
47
+ //#region ../../node_modules/.pnpm/ts-pattern@5.9.0/node_modules/ts-pattern/dist/index.js
48
+ const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVariadic"), n = "@ts-pattern/anonymous-select-key", r = (t) => Boolean(t && "object" == typeof t), i = (e) => e && !!e[t], o = (n, s, c) => {
49
+ if (i(n)) {
50
+ const { matched: r, selections: i } = n[t]().match(s);
51
+ return r && i && Object.keys(i).forEach((t) => c(t, i[t])), r;
52
+ }
53
+ if (r(n)) {
54
+ if (!r(s)) return !1;
55
+ if (Array.isArray(n)) {
56
+ if (!Array.isArray(s)) return !1;
57
+ let t = [], r = [], u = [];
58
+ for (const o of n.keys()) {
59
+ const s = n[o];
60
+ i(s) && s[e] ? u.push(s) : u.length ? r.push(s) : t.push(s);
61
+ }
62
+ if (u.length) {
63
+ if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
64
+ if (s.length < t.length + r.length) return !1;
65
+ const e = s.slice(0, t.length), n = 0 === r.length ? [] : s.slice(-r.length), i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
66
+ return t.every((t, n) => o(t, e[n], c)) && r.every((t, e) => o(t, n[e], c)) && (0 === u.length || o(u[0], i, c));
67
+ }
68
+ return n.length === s.length && n.every((t, e) => o(t, s[e], c));
69
+ }
70
+ return Reflect.ownKeys(n).every((e) => {
71
+ const r = n[e];
72
+ return (e in s || i(u = r) && "optional" === u[t]().matcherType) && o(r, s[e], c);
73
+ var u;
74
+ });
75
+ }
76
+ return Object.is(s, n);
77
+ }, s = (e) => {
78
+ var n, o, u;
79
+ return r(e) ? i(e) ? null != (n = null == (o = (u = e[t]()).getSelectionKeys) ? void 0 : o.call(u)) ? n : [] : Array.isArray(e) ? c(e, s) : c(Object.values(e), s) : [];
80
+ }, c = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
81
+ function u(...t) {
82
+ if (1 === t.length) {
83
+ const [e] = t;
84
+ return (t) => o(e, t, () => {});
85
+ }
86
+ if (2 === t.length) {
87
+ const [e, n] = t;
88
+ return o(e, n, () => {});
89
+ }
90
+ throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
91
+ }
92
+ function a(t) {
93
+ return Object.assign(t, {
94
+ optional: () => h(t),
95
+ and: (e) => d(t, e),
96
+ or: (e) => y(t, e),
97
+ select: (e) => void 0 === e ? v(t) : v(e, t)
98
+ });
99
+ }
100
+ function l(t) {
101
+ return Object.assign(((t) => Object.assign(t, { [Symbol.iterator]() {
102
+ let n = 0;
103
+ const r = [{
104
+ value: Object.assign(t, { [e]: !0 }),
105
+ done: !1
106
+ }, {
107
+ done: !0,
108
+ value: void 0
109
+ }];
110
+ return { next: () => {
111
+ var t;
112
+ return null != (t = r[n++]) ? t : r.at(-1);
113
+ } };
114
+ } }))(t), {
115
+ optional: () => l(h(t)),
116
+ select: (e) => l(void 0 === e ? v(t) : v(e, t))
117
+ });
118
+ }
119
+ function h(e) {
120
+ return a({ [t]: () => ({
121
+ match: (t) => {
122
+ let n = {};
123
+ const r = (t, e) => {
124
+ n[t] = e;
125
+ };
126
+ return void 0 === t ? (s(e).forEach((t) => r(t, void 0)), {
127
+ matched: !0,
128
+ selections: n
129
+ }) : {
130
+ matched: o(e, t, r),
131
+ selections: n
132
+ };
133
+ },
134
+ getSelectionKeys: () => s(e),
135
+ matcherType: "optional"
136
+ }) });
137
+ }
138
+ const f = (t, e) => {
139
+ for (const n of t) if (!e(n)) return !1;
140
+ return !0;
141
+ }, g = (t, e) => {
142
+ for (const [n, r] of t.entries()) if (!e(r, n)) return !1;
143
+ return !0;
144
+ }, m = (t, e) => {
145
+ const n = Reflect.ownKeys(t);
146
+ for (const r of n) if (!e(r, t[r])) return !1;
147
+ return !0;
148
+ };
149
+ function d(...e) {
150
+ return a({ [t]: () => ({
151
+ match: (t) => {
152
+ let n = {};
153
+ const r = (t, e) => {
154
+ n[t] = e;
155
+ };
156
+ return {
157
+ matched: e.every((e) => o(e, t, r)),
158
+ selections: n
159
+ };
160
+ },
161
+ getSelectionKeys: () => c(e, s),
162
+ matcherType: "and"
163
+ }) });
164
+ }
165
+ function y(...e) {
166
+ return a({ [t]: () => ({
167
+ match: (t) => {
168
+ let n = {};
169
+ const r = (t, e) => {
170
+ n[t] = e;
171
+ };
172
+ return c(e, s).forEach((t) => r(t, void 0)), {
173
+ matched: e.some((e) => o(e, t, r)),
174
+ selections: n
175
+ };
176
+ },
177
+ getSelectionKeys: () => c(e, s),
178
+ matcherType: "or"
179
+ }) });
180
+ }
181
+ function p(e) {
182
+ return { [t]: () => ({ match: (t) => ({ matched: Boolean(e(t)) }) }) };
183
+ }
184
+ function v(...e) {
185
+ const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
186
+ return a({ [t]: () => ({
187
+ match: (t) => {
188
+ let e = { [null != r ? r : n]: t };
189
+ return {
190
+ matched: void 0 === i || o(i, t, (t, n) => {
191
+ e[t] = n;
192
+ }),
193
+ selections: e
194
+ };
195
+ },
196
+ getSelectionKeys: () => [null != r ? r : n].concat(void 0 === i ? [] : s(i))
197
+ }) });
198
+ }
199
+ function b(t) {
200
+ return !0;
201
+ }
202
+ function w(t) {
203
+ return "number" == typeof t;
204
+ }
205
+ function S(t) {
206
+ return "string" == typeof t;
207
+ }
208
+ function j(t) {
209
+ return "bigint" == typeof t;
210
+ }
211
+ const K = a(p(b)), O = a(p(b)), E = K, x = (t) => Object.assign(a(t), {
212
+ startsWith: (e) => {
213
+ return x(d(t, (n = e, p((t) => S(t) && t.startsWith(n)))));
214
+ var n;
215
+ },
216
+ endsWith: (e) => {
217
+ return x(d(t, (n = e, p((t) => S(t) && t.endsWith(n)))));
218
+ var n;
219
+ },
220
+ minLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length >= t))(e))),
221
+ length: (e) => x(d(t, ((t) => p((e) => S(e) && e.length === t))(e))),
222
+ maxLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length <= t))(e))),
223
+ includes: (e) => {
224
+ return x(d(t, (n = e, p((t) => S(t) && t.includes(n)))));
225
+ var n;
226
+ },
227
+ regex: (e) => {
228
+ return x(d(t, (n = e, p((t) => S(t) && Boolean(t.match(n))))));
229
+ var n;
230
+ }
231
+ }), A = x(p(S)), N = (t) => Object.assign(a(t), {
232
+ between: (e, n) => N(d(t, ((t, e) => p((n) => w(n) && t <= n && e >= n))(e, n))),
233
+ lt: (e) => N(d(t, ((t) => p((e) => w(e) && e < t))(e))),
234
+ gt: (e) => N(d(t, ((t) => p((e) => w(e) && e > t))(e))),
235
+ lte: (e) => N(d(t, ((t) => p((e) => w(e) && e <= t))(e))),
236
+ gte: (e) => N(d(t, ((t) => p((e) => w(e) && e >= t))(e))),
237
+ int: () => N(d(t, p((t) => w(t) && Number.isInteger(t)))),
238
+ finite: () => N(d(t, p((t) => w(t) && Number.isFinite(t)))),
239
+ positive: () => N(d(t, p((t) => w(t) && t > 0))),
240
+ negative: () => N(d(t, p((t) => w(t) && t < 0)))
241
+ }), P = N(p(w)), k = (t) => Object.assign(a(t), {
242
+ between: (e, n) => k(d(t, ((t, e) => p((n) => j(n) && t <= n && e >= n))(e, n))),
243
+ lt: (e) => k(d(t, ((t) => p((e) => j(e) && e < t))(e))),
244
+ gt: (e) => k(d(t, ((t) => p((e) => j(e) && e > t))(e))),
245
+ lte: (e) => k(d(t, ((t) => p((e) => j(e) && e <= t))(e))),
246
+ gte: (e) => k(d(t, ((t) => p((e) => j(e) && e >= t))(e))),
247
+ positive: () => k(d(t, p((t) => j(t) && t > 0))),
248
+ negative: () => k(d(t, p((t) => j(t) && t < 0)))
249
+ });
250
+ var z = {
251
+ __proto__: null,
252
+ matcher: t,
253
+ optional: h,
254
+ array: function(...e) {
255
+ return l({ [t]: () => ({
256
+ match: (t) => {
257
+ if (!Array.isArray(t)) return { matched: !1 };
258
+ if (0 === e.length) return { matched: !0 };
259
+ const n = e[0];
260
+ let r = {};
261
+ if (0 === t.length) return s(n).forEach((t) => {
262
+ r[t] = [];
263
+ }), {
264
+ matched: !0,
265
+ selections: r
266
+ };
267
+ const i = (t, e) => {
268
+ r[t] = (r[t] || []).concat([e]);
269
+ };
270
+ return {
271
+ matched: t.every((t) => o(n, t, i)),
272
+ selections: r
273
+ };
274
+ },
275
+ getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
276
+ }) });
277
+ },
278
+ set: function(...e) {
279
+ return a({ [t]: () => ({
280
+ match: (t) => {
281
+ if (!(t instanceof Set)) return { matched: !1 };
282
+ let n = {};
283
+ if (0 === t.size) return {
284
+ matched: !0,
285
+ selections: n
286
+ };
287
+ if (0 === e.length) return { matched: !0 };
288
+ const r = (t, e) => {
289
+ n[t] = (n[t] || []).concat([e]);
290
+ }, i = e[0];
291
+ return {
292
+ matched: f(t, (t) => o(i, t, r)),
293
+ selections: n
294
+ };
295
+ },
296
+ getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
297
+ }) });
298
+ },
299
+ map: function(...e) {
300
+ return a({ [t]: () => ({
301
+ match: (t) => {
302
+ if (!(t instanceof Map)) return { matched: !1 };
303
+ let n = {};
304
+ if (0 === t.size) return {
305
+ matched: !0,
306
+ selections: n
307
+ };
308
+ const r = (t, e) => {
309
+ n[t] = (n[t] || []).concat([e]);
310
+ };
311
+ if (0 === e.length) return { matched: !0 };
312
+ var i;
313
+ if (1 === e.length) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i = e[0]) ? void 0 : i.toString()}`);
314
+ const [s, c] = e;
315
+ return {
316
+ matched: g(t, (t, e) => {
317
+ const n = o(s, e, r), i = o(c, t, r);
318
+ return n && i;
319
+ }),
320
+ selections: n
321
+ };
322
+ },
323
+ getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
324
+ }) });
325
+ },
326
+ record: function(...e) {
327
+ return a({ [t]: () => ({
328
+ match: (t) => {
329
+ if (null === t || "object" != typeof t || Array.isArray(t)) return { matched: !1 };
330
+ var n;
331
+ if (0 === e.length) throw new Error(`\`P.record\` wasn't given enough arguments. Expected (value) or (key, value), received ${null == (n = e[0]) ? void 0 : n.toString()}`);
332
+ let r = {};
333
+ const i = (t, e) => {
334
+ r[t] = (r[t] || []).concat([e]);
335
+ }, [s, c] = 1 === e.length ? [A, e[0]] : e;
336
+ return {
337
+ matched: m(t, (t, e) => {
338
+ const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t), r = null !== n && o(s, n, i), u = o(s, t, i), a = o(c, e, i);
339
+ return (u || r) && a;
340
+ }),
341
+ selections: r
342
+ };
343
+ },
344
+ getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
345
+ }) });
346
+ },
347
+ intersection: d,
348
+ union: y,
349
+ not: function(e) {
350
+ return a({ [t]: () => ({
351
+ match: (t) => ({ matched: !o(e, t, () => {}) }),
352
+ getSelectionKeys: () => [],
353
+ matcherType: "not"
354
+ }) });
355
+ },
356
+ when: p,
357
+ select: v,
358
+ any: K,
359
+ unknown: O,
360
+ _: E,
361
+ string: A,
362
+ number: P,
363
+ bigint: k(p(j)),
364
+ boolean: a(p(function(t) {
365
+ return "boolean" == typeof t;
366
+ })),
367
+ symbol: a(p(function(t) {
368
+ return "symbol" == typeof t;
369
+ })),
370
+ nullish: a(p(function(t) {
371
+ return null == t;
372
+ })),
373
+ nonNullable: a(p(function(t) {
374
+ return null != t;
375
+ })),
376
+ instanceOf: function(t) {
377
+ return a(p(function(t) {
378
+ return (e) => e instanceof t;
379
+ }(t)));
380
+ },
381
+ shape: function(t) {
382
+ return a(p(u(t)));
383
+ }
384
+ };
385
+
46
386
  //#endregion
47
387
  //#region src/rules/function-definition/function-definition.ts
48
388
  const RULE_NAME = "function-definition";
@@ -77,7 +417,10 @@ function isDirectiveName(value) {
77
417
  function matchDirective(stmt) {
78
418
  if (stmt.type !== AST_NODE_TYPES.ExpressionStatement) return null;
79
419
  const { expression } = stmt;
80
- if (Check.isStringLiteral(expression)) {
420
+ if (u({
421
+ type: AST_NODE_TYPES.Literal,
422
+ value: z.string
423
+ }, expression)) {
81
424
  if (!isDirectiveName(expression.value)) return null;
82
425
  return {
83
426
  kind: stmt.directive != null ? "well-formed" : "misplaced",
@@ -99,7 +442,7 @@ function matchDirective(stmt) {
99
442
  function create(context) {
100
443
  const text = context.sourceCode.text;
101
444
  if (!text.includes("use server") && !text.includes("use client")) return {};
102
- const hasFileLevelUseServerDirective = context.sourceCode.ast.body.some(Check.isDirective("use server"));
445
+ const hasFileLevelUseServerDirective = context.sourceCode.ast.body.some((stmt) => Check.isDirective(stmt, "use server"));
103
446
  /**
104
447
  * Build a fix that makes `node` an async function
105
448
  * @param node The function node to fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-rsc",
3
- "version": "5.10.4",
3
+ "version": "5.11.2",
4
4
  "description": "ESLint React's ESLint plugin for RSC related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -38,11 +38,11 @@
38
38
  "dependencies": {
39
39
  "@typescript-eslint/types": "^8.62.1",
40
40
  "@typescript-eslint/utils": "^8.62.1",
41
- "@eslint-react/ast": "5.10.4",
42
- "@eslint-react/core": "5.10.4",
43
- "@eslint-react/shared": "5.10.4",
44
- "@eslint-react/var": "5.10.4",
45
- "@eslint-react/eslint": "5.10.4"
41
+ "@eslint-react/eslint": "5.11.2",
42
+ "@eslint-react/ast": "5.11.2",
43
+ "@eslint-react/shared": "5.11.2",
44
+ "@eslint-react/var": "5.11.2",
45
+ "@eslint-react/core": "5.11.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/react": "^19.2.17",