@eslint-react/shared 3.0.0-next.9 → 3.0.0-rc.0

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 (3) hide show
  1. package/dist/index.d.ts +69 -180
  2. package/dist/index.js +353 -92
  3. package/package.json +9 -8
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { unit } from "@eslint-react/eff";
2
1
  import { z } from "zod/v4";
3
2
  import * as tseslint from "@typescript-eslint/utils/ts-eslint";
4
3
  import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener } from "@typescript-eslint/utils/ts-eslint";
@@ -21,115 +20,6 @@ declare class IdGenerator {
21
20
  next(): string;
22
21
  }
23
22
  //#endregion
24
- //#region src/types.d.ts
25
- /**
26
- * Rule severity.
27
- * @since 0.0.1
28
- */
29
- type SeverityName = "off" | "warn" | "error";
30
- /**
31
- * The numeric severity level for a rule.
32
- *
33
- * - `0` means off.
34
- * - `1` means warn.
35
- * - `2` means error.
36
- */
37
- type SeverityLevel = 0 | 1 | 2;
38
- /**
39
- * The severity of a rule in a configuration.
40
- */
41
- type Severity = SeverityName | SeverityLevel;
42
- /**
43
- * Rule declaration.
44
- * @internal
45
- * @since 0.0.1
46
- */
47
- type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
48
- /**
49
- * Rule context.
50
- * @since 0.0.1
51
- */
52
- type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
53
- /**
54
- * Rule feature.
55
- * @since 1.20.0
56
- */
57
- type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
58
- /**
59
- * The numeric policy value for a rule (severity level).
60
- */
61
- type RulePolicy = number;
62
- /**
63
- * A suggestion for fixing a reported issue.
64
- */
65
- type RuleSuggest<MessageIds extends string = string> = {
66
- /** The message ID for the suggestion. */messageId: MessageIds; /** Optional data to pass to the message formatter. */
67
- data?: Record<string, unknown>; /** The fix function to apply the suggestion. */
68
- fix: tseslint.ReportFixFunction;
69
- };
70
- /**
71
- * A collection of settings.
72
- */
73
- interface SettingsConfig {
74
- [key: string]: unknown;
75
- }
76
- /**
77
- * A rule with a compatible shape for use with `defineConfig()` and `tseslint.config()`.
78
- * Intentionally wide/inaccurate for compatibility purposes.
79
- */
80
- interface CompatibleRule {
81
- meta: Record<string, any>;
82
- create: (...args: any[]) => any;
83
- }
84
- /**
85
- * A plugin with a compatible shape for use with `defineConfig()` and `tseslint.config()`.
86
- * Intentionally wide/inaccurate for compatibility purposes.
87
- */
88
- interface CompatiblePlugin {
89
- meta: {
90
- name: string;
91
- version: string;
92
- };
93
- rules: Record<string, CompatibleRule>;
94
- }
95
- /**
96
- * A configuration object with a compatible shape for use with `defineConfig()` and `tseslint.config()`.
97
- * Intentionally wide/inaccurate for compatibility purposes.
98
- */
99
- interface CompatibleConfig {
100
- /** Optional configuration name. */
101
- name?: string;
102
- /** Rule configurations. */
103
- rules?: Record<string, RuleConfig>;
104
- /** Shared settings. */
105
- settings?: SettingsConfig;
106
- }
107
- type CompilationMode = "off" | "infer" | "annotation" | "syntax" | "all";
108
- //#endregion
109
- //#region src/config-adapters.d.ts
110
- /**
111
- * Get configuration adapters for converting between flat and legacy config formats
112
- * @param pluginName The name of the plugin
113
- * @param plugin The plugin instance
114
- * @returns Object with toFlatConfig and toLegacyConfig functions
115
- */
116
- declare function getConfigAdapters(pluginName: string, plugin: CompatiblePlugin): {
117
- readonly toFlatConfig: (config: CompatibleConfig) => {
118
- plugins: {
119
- [pluginName]: CompatiblePlugin;
120
- };
121
- name?: string;
122
- rules?: Record<string, RuleConfig>;
123
- settings?: SettingsConfig;
124
- };
125
- readonly toLegacyConfig: ({
126
- rules
127
- }: CompatibleConfig) => {
128
- plugins: string[];
129
- rules: Record<string, RuleConfig<unknown[]>> | undefined;
130
- };
131
- };
132
- //#endregion
133
23
  //#region src/constants.d.ts
134
24
  /**
135
25
  * The NPM scope for this project.
@@ -215,11 +105,19 @@ declare const RE_HOOK_NAME: RegExp;
215
105
  /**
216
106
  * Known impure functions
217
107
  */
218
- declare const IMPURE_FUNCTIONS: ReadonlyMap<string, ReadonlySet<string>>;
108
+ declare const IMPURE_FUNCS: ReadonlyMap<string, ReadonlySet<string>>;
219
109
  /**
220
110
  * Known impure global constructors used with `new`
221
111
  */
222
- declare const IMPURE_CONSTRUCTORS: ReadonlySet<string>;
112
+ declare const IMPURE_CTORS: ReadonlySet<string>;
113
+ /**
114
+ * Known pure functions
115
+ */
116
+ declare const PURE_FUNCS: ReadonlyMap<string, ReadonlySet<string>>;
117
+ /**
118
+ Known pure global constructors used with `new`
119
+ */
120
+ declare const PURE_CTORS: ReadonlySet<string>;
223
121
  //#endregion
224
122
  //#region src/define-rule-listener.d.ts
225
123
  /**
@@ -256,13 +154,13 @@ type RegExpLike = {
256
154
  };
257
155
  /**
258
156
  * Convert a string to the `RegExp`.
259
- * Normal strings (e.g., `"foo"`) is converted to `/^foo$/` of `RegExp`.
157
+ * Normal strings (ex: `"foo"`) is converted to `/^foo$/` of `RegExp`.
260
158
  * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
261
159
  * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
262
160
  * @param string The string to convert.
263
161
  * @returns Returns the `RegExp`.
264
162
  */
265
- declare function toRegExp(string: string | unit): RegExpLike;
163
+ declare function toRegExp(string: string | null | undefined): RegExpLike;
266
164
  /**
267
165
  * Check whether given string is regexp string
268
166
  * @param string The string to check
@@ -270,6 +168,55 @@ declare function toRegExp(string: string | unit): RegExpLike;
270
168
  */
271
169
  declare function isRegExp(string: string): boolean;
272
170
  //#endregion
171
+ //#region src/types.d.ts
172
+ /**
173
+ * Rule severity.
174
+ * @since 0.0.1
175
+ */
176
+ type SeverityName = "off" | "warn" | "error";
177
+ /**
178
+ * The numeric severity level for a rule.
179
+ *
180
+ * - `0` means off.
181
+ * - `1` means warn.
182
+ * - `2` means error.
183
+ */
184
+ type SeverityLevel = 0 | 1 | 2;
185
+ /**
186
+ * The severity of a rule in a configuration.
187
+ */
188
+ type Severity = SeverityName | SeverityLevel;
189
+ /**
190
+ * Rule declaration.
191
+ * @internal
192
+ * @since 0.0.1
193
+ */
194
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
195
+ /**
196
+ * Rule context.
197
+ * @since 0.0.1
198
+ */
199
+ type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
200
+ /**
201
+ * Rule feature.
202
+ * @since 1.20.0
203
+ */
204
+ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
205
+ /**
206
+ * A suggestion for fixing a reported issue.
207
+ */
208
+ type RuleSuggest<MessageIds extends string = string> = {
209
+ /** Optional data to pass to the message formatter. */data?: Record<string, unknown>; /** The fix function to apply the suggestion. */
210
+ fix: tseslint.ReportFixFunction; /** The message ID for the suggestion. */
211
+ messageId: MessageIds;
212
+ };
213
+ /**
214
+ * A collection of settings.
215
+ */
216
+ interface SettingsConfig {
217
+ [key: string]: unknown;
218
+ }
219
+ //#endregion
273
220
  //#region src/report.d.ts
274
221
  /**
275
222
  * Creates a report function for the given rule context.
@@ -280,13 +227,11 @@ declare function report(context: RuleContext): (descriptor?: null | ReportDescri
280
227
  //#endregion
281
228
  //#region src/settings.d.ts
282
229
  /**
283
- * Schema for ESLint React settings configuration
284
230
  * @internal
285
231
  */
286
232
  declare const ESLintReactSettingsSchema: z.ZodObject<{
287
233
  importSource: z.ZodOptional<z.ZodString>;
288
234
  compilationMode: z.ZodOptional<z.ZodEnum<{
289
- off: "off";
290
235
  infer: "infer";
291
236
  annotation: "annotation";
292
237
  syntax: "syntax";
@@ -295,117 +240,61 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
295
240
  polymorphicPropName: z.ZodOptional<z.ZodString>;
296
241
  version: z.ZodOptional<z.ZodString>;
297
242
  additionalStateHooks: z.ZodOptional<z.ZodString>;
243
+ additionalEffectHooks: z.ZodOptional<z.ZodString>;
298
244
  }, z.core.$strip>;
299
245
  /**
300
- * Schema for ESLint settings
301
246
  * @internal
302
247
  */
303
248
  declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
304
249
  "react-x": z.ZodOptional<z.ZodUnknown>;
305
250
  }, z.core.$strip>>;
306
- /**
307
- * ESLint settings type inferred from the settings schema.
308
- */
309
251
  type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
310
- /**
311
- * ESLint React settings type inferred from the React settings schema.
312
- */
313
252
  type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
314
- /**
315
- * Normalized ESLint React settings with processed values
316
- */
317
253
  interface ESLintReactSettingsNormalized {
318
254
  version: string;
319
255
  importSource: string;
320
- compilationMode: CompilationMode;
321
- isCompilerEnabled: boolean;
322
- polymorphicPropName: string | unit;
256
+ compilationMode: ESLintReactSettings["compilationMode"] | "off";
257
+ polymorphicPropName: string | null;
323
258
  additionalStateHooks: RegExpLike;
259
+ additionalEffectHooks: RegExpLike;
324
260
  }
325
- /**
326
- * Default ESLint React settings
327
- */
328
261
  declare const DEFAULT_ESLINT_REACT_SETTINGS: {
329
262
  readonly version: "detect";
330
263
  readonly importSource: "react";
331
- readonly compilationMode: "annotation";
332
264
  readonly polymorphicPropName: "as";
333
265
  };
334
- /**
335
- * Default ESLint settings with React settings included
336
- */
337
266
  declare const DEFAULT_ESLINT_SETTINGS: {
338
267
  readonly "react-x": {
339
268
  readonly version: "detect";
340
269
  readonly importSource: "react";
341
- readonly compilationMode: "annotation";
342
270
  readonly polymorphicPropName: "as";
343
271
  };
344
272
  };
345
- /**
346
- * Check if the provided settings conform to ESLintSettings schema
347
- * @param settings The settings object to validate
348
- */
349
273
  declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
350
- /**
351
- * Check if the provided settings conform to ESLintReactSettings schema
352
- * @param settings The settings object to validate
353
- */
354
274
  declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
355
- /**
356
- * Coerces unknown input to ESLintSettings type
357
- * @param settings The settings object to coerce
358
- */
359
- declare const coerceESLintSettings: (settings: unknown) => Partial<ESLintSettings>;
360
- /**
361
- * Decodes and validates ESLint settings, using defaults if invalid
362
- * @param settings The settings object to decode
363
- */
364
275
  declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
365
- /**
366
- * Coerces unknown input to ESLintReactSettings type
367
- * @param settings The settings object to coerce
368
- */
369
- declare const coerceSettings: (settings: unknown) => Partial<ESLintReactSettings>;
370
- /**
371
- * Decodes and validates ESLint React settings, using defaults if invalid
372
- * @param settings The settings object to decode
373
- */
374
276
  declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
375
- /**
376
- * Normalizes ESLint React settings to a consistent internal format
377
- * Transforms component definitions and resolves version information
378
- */
379
277
  declare const normalizeSettings: ({
380
278
  importSource,
381
279
  compilationMode,
382
280
  polymorphicPropName,
383
281
  version,
384
282
  additionalStateHooks,
283
+ additionalEffectHooks,
385
284
  ...rest
386
285
  }: ESLintReactSettings) => {
387
286
  readonly importSource: string;
388
- readonly compilationMode: "off" | "infer" | "annotation" | "syntax" | "all";
389
- readonly isCompilerEnabled: boolean;
287
+ readonly compilationMode: "infer" | "annotation" | "syntax" | "all" | "off";
390
288
  readonly polymorphicPropName: string;
391
289
  readonly version: string;
392
290
  readonly additionalStateHooks: RegExpLike;
291
+ readonly additionalEffectHooks: RegExpLike;
393
292
  };
394
- /**
395
- * Retrieves normalized ESLint React settings from the rule context
396
- * Uses caching for performance optimization
397
- * @param context The ESLint rule context
398
- */
399
293
  declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
400
- /**
401
- * Helper function for defining typed settings for "react-x" in JavaScript files
402
- * Provides type checking without runtime transformation
403
- */
404
- declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
405
294
  declare module "@typescript-eslint/utils/ts-eslint" {
406
295
  interface SharedConfigurationSettings {
407
296
  ["react-x"]?: Partial<ESLintReactSettings>;
408
297
  }
409
298
  }
410
299
  //#endregion
411
- export { CompatibleConfig, CompatiblePlugin, CompatibleRule, CompilationMode, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, IMPURE_CONSTRUCTORS, IMPURE_FUNCTIONS, IdGenerator, NPM_SCOPE, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, RegExpLike, type ReportFixFunction, RuleConfig, RuleContext, RuleFeature, type RuleFix, type RuleFixer, RulePolicy, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineRuleListener, defineSettings, getConfigAdapters, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
300
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, IdGenerator, NPM_SCOPE, PURE_CTORS, PURE_FUNCS, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, RegExpLike, type ReportFixFunction, RuleConfig, RuleContext, RuleFeature, type RuleFix, type RuleFixer, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import module from "node:module";
2
2
  import path from "node:path";
3
- import { constFalse, getOrElseUpdate, identity } from "@eslint-react/eff";
4
3
  import { P, match } from "ts-pattern";
5
4
  import { z } from "zod/v4";
6
5
 
@@ -28,33 +27,6 @@ var IdGenerator = class {
28
27
  }
29
28
  };
30
29
 
31
- //#endregion
32
- //#region src/config-adapters.ts
33
- /**
34
- * Get configuration adapters for converting between flat and legacy config formats
35
- * @param pluginName The name of the plugin
36
- * @param plugin The plugin instance
37
- * @returns Object with toFlatConfig and toLegacyConfig functions
38
- */
39
- function getConfigAdapters(pluginName, plugin) {
40
- function toFlatConfig(config) {
41
- return {
42
- ...config,
43
- plugins: { [pluginName]: plugin }
44
- };
45
- }
46
- function toLegacyConfig({ rules }) {
47
- return {
48
- plugins: [pluginName],
49
- rules
50
- };
51
- }
52
- return {
53
- toFlatConfig,
54
- toLegacyConfig
55
- };
56
- }
57
-
58
30
  //#endregion
59
31
  //#region src/constants.ts
60
32
  /**
@@ -141,7 +113,7 @@ const RE_HOOK_NAME = /^use/u;
141
113
  /**
142
114
  * Known impure functions
143
115
  */
144
- const IMPURE_FUNCTIONS = new Map([
116
+ const IMPURE_FUNCS = new Map([
145
117
  ["Atomics", new Set([
146
118
  "add",
147
119
  "and",
@@ -244,6 +216,53 @@ const IMPURE_FUNCTIONS = new Map([
244
216
  "write",
245
217
  "writeln"
246
218
  ])],
219
+ ["globalThis", new Set([
220
+ "addEventListener",
221
+ "alert",
222
+ "alert",
223
+ "blur",
224
+ "cancelAnimationFrame",
225
+ "cancelIdleCallback",
226
+ "clearInterval",
227
+ "clearInterval",
228
+ "clearTimeout",
229
+ "clearTimeout",
230
+ "close",
231
+ "confirm",
232
+ "confirm",
233
+ "dispatchEvent",
234
+ "fetch",
235
+ "fetch",
236
+ "focus",
237
+ "getComputedStyle",
238
+ "getSelection",
239
+ "matchMedia",
240
+ "moveBy",
241
+ "moveTo",
242
+ "open",
243
+ "postMessage",
244
+ "postMessage",
245
+ "print",
246
+ "prompt",
247
+ "prompt",
248
+ "queueMicrotask",
249
+ "queueMicrotask",
250
+ "removeEventListener",
251
+ "reportError",
252
+ "requestAnimationFrame",
253
+ "requestIdleCallback",
254
+ "resizeBy",
255
+ "resizeTo",
256
+ "scroll",
257
+ "scrollBy",
258
+ "scrollTo",
259
+ "setInterval",
260
+ "setInterval",
261
+ "setTimeout",
262
+ "setTimeout",
263
+ "stop",
264
+ "structuredClone"
265
+ ])],
247
266
  ["history", new Set([
248
267
  "back",
249
268
  "forward",
@@ -343,15 +362,20 @@ const IMPURE_FUNCTIONS = new Map([
343
362
  ["window", new Set([
344
363
  "addEventListener",
345
364
  "alert",
365
+ "alert",
346
366
  "blur",
347
367
  "cancelAnimationFrame",
348
368
  "cancelIdleCallback",
349
369
  "clearInterval",
370
+ "clearInterval",
371
+ "clearTimeout",
350
372
  "clearTimeout",
351
373
  "close",
352
374
  "confirm",
375
+ "confirm",
353
376
  "dispatchEvent",
354
377
  "fetch",
378
+ "fetch",
355
379
  "focus",
356
380
  "getComputedStyle",
357
381
  "getSelection",
@@ -360,10 +384,14 @@ const IMPURE_FUNCTIONS = new Map([
360
384
  "moveTo",
361
385
  "open",
362
386
  "postMessage",
387
+ "postMessage",
363
388
  "print",
364
389
  "prompt",
390
+ "prompt",
391
+ "queueMicrotask",
365
392
  "queueMicrotask",
366
393
  "removeEventListener",
394
+ "reportError",
367
395
  "requestAnimationFrame",
368
396
  "requestIdleCallback",
369
397
  "resizeBy",
@@ -372,14 +400,17 @@ const IMPURE_FUNCTIONS = new Map([
372
400
  "scrollBy",
373
401
  "scrollTo",
374
402
  "setInterval",
403
+ "setInterval",
404
+ "setTimeout",
375
405
  "setTimeout",
376
- "stop"
406
+ "stop",
407
+ "structuredClone"
377
408
  ])]
378
409
  ]);
379
410
  /**
380
411
  * Known impure global constructors used with `new`
381
412
  */
382
- const IMPURE_CONSTRUCTORS = new Set([
413
+ const IMPURE_CTORS = new Set([
383
414
  "AbortController",
384
415
  "Audio",
385
416
  "AudioContext",
@@ -405,6 +436,148 @@ const IMPURE_CONSTRUCTORS = new Set([
405
436
  "Worker",
406
437
  "XMLHttpRequest"
407
438
  ]);
439
+ /**
440
+ * Known pure functions
441
+ */
442
+ const PURE_FUNCS = new Map([
443
+ ["Array", new Set([
444
+ "from",
445
+ "isArray",
446
+ "of"
447
+ ])],
448
+ ["Atomics", new Set(["isLockFree"])],
449
+ ["BigInt", new Set(["asIntN", "asUintN"])],
450
+ ["Date", new Set(["parse", "UTC"])],
451
+ ["globalThis", new Set([
452
+ "atob",
453
+ "Boolean",
454
+ "btoa",
455
+ "decodeURI",
456
+ "decodeURIComponent",
457
+ "encodeURI",
458
+ "encodeURIComponent",
459
+ "escape",
460
+ "isFinite",
461
+ "isNaN",
462
+ "Number",
463
+ "parseFloat",
464
+ "parseInt",
465
+ "String",
466
+ "unescape"
467
+ ])],
468
+ ["JSON", new Set(["parse", "stringify"])],
469
+ ["Math", new Set([
470
+ "abs",
471
+ "acos",
472
+ "acosh",
473
+ "asin",
474
+ "asinh",
475
+ "atan",
476
+ "atan2",
477
+ "atanh",
478
+ "cbrt",
479
+ "ceil",
480
+ "clz32",
481
+ "cos",
482
+ "cosh",
483
+ "exp",
484
+ "expm1",
485
+ "floor",
486
+ "fround",
487
+ "hypot",
488
+ "imul",
489
+ "log",
490
+ "log1p",
491
+ "log2",
492
+ "log10",
493
+ "max",
494
+ "min",
495
+ "pow",
496
+ "round",
497
+ "sign",
498
+ "sin",
499
+ "sinh",
500
+ "sqrt",
501
+ "tan",
502
+ "tanh",
503
+ "trunc"
504
+ ])],
505
+ ["Number", new Set([
506
+ "isFinite",
507
+ "isInteger",
508
+ "isNaN",
509
+ "isSafeInteger",
510
+ "parseFloat",
511
+ "parseInt"
512
+ ])],
513
+ ["Object", new Set([
514
+ "entries",
515
+ "fromEntries",
516
+ "getOwnPropertyDescriptor",
517
+ "getOwnPropertyDescriptors",
518
+ "getOwnPropertyNames",
519
+ "getOwnPropertySymbols",
520
+ "getPrototypeOf",
521
+ "groupBy",
522
+ "hasOwn",
523
+ "is",
524
+ "isExtensible",
525
+ "isFrozen",
526
+ "isSealed",
527
+ "keys",
528
+ "values"
529
+ ])],
530
+ ["Reflect", new Set([
531
+ "apply",
532
+ "construct",
533
+ "get",
534
+ "getOwnPropertyDescriptor",
535
+ "getPrototypeOf",
536
+ "has",
537
+ "isExtensible",
538
+ "ownKeys"
539
+ ])],
540
+ ["String", new Set([
541
+ "fromCharCode",
542
+ "fromCodePoint",
543
+ "raw"
544
+ ])]
545
+ ]);
546
+ /**
547
+ Known pure global constructors used with `new`
548
+ */
549
+ const PURE_CTORS = new Set([
550
+ "Array",
551
+ "ArrayBuffer",
552
+ "BigInt64Array",
553
+ "BigUint64Array",
554
+ "DataView",
555
+ "Error",
556
+ "EvalError",
557
+ "FinalizationRegistry",
558
+ "Float32Array",
559
+ "Float64Array",
560
+ "Int8Array",
561
+ "Int16Array",
562
+ "Int32Array",
563
+ "Map",
564
+ "RangeError",
565
+ "ReferenceError",
566
+ "RegExp",
567
+ "Set",
568
+ "SyntaxError",
569
+ "TypeError",
570
+ "Uint8Array",
571
+ "Uint8ClampedArray",
572
+ "Uint16Array",
573
+ "Uint32Array",
574
+ "URIError",
575
+ "URL",
576
+ "URLSearchParams",
577
+ "WeakMap",
578
+ "WeakRef",
579
+ "WeakSet"
580
+ ]);
408
581
 
409
582
  //#endregion
410
583
  //#region src/define-rule-listener.ts
@@ -434,6 +607,147 @@ function defineRuleListener(base, ...rest) {
434
607
  return base;
435
608
  }
436
609
 
610
+ //#endregion
611
+ //#region ../../.pkgs/eff/dist/index.js
612
+ /**
613
+ * Returns its argument.
614
+ *
615
+ * @param x - The value to return.
616
+ * @returns The input value unchanged.
617
+ */
618
+ function identity(x) {
619
+ return x;
620
+ }
621
+ /**
622
+ * Creates a function that can be used in a data-last (aka `pipe`able) or
623
+ * data-first style.
624
+ *
625
+ * The first parameter to `dual` is either the arity of the uncurried function
626
+ * or a predicate that determines if the function is being used in a data-first
627
+ * or data-last style.
628
+ *
629
+ * Using the arity is the most common use case, but there are some cases where
630
+ * you may want to use a predicate. For example, if you have a function that
631
+ * takes an optional argument, you can use a predicate to determine if the
632
+ * function is being used in a data-first or data-last style.
633
+ *
634
+ * You can pass either the arity of the uncurried function or a predicate
635
+ * which determines if the function is being used in a data-first or
636
+ * data-last style.
637
+ *
638
+ * **Example** (Using arity to determine data-first or data-last style)
639
+ *
640
+ * ```ts
641
+ * import { dual, pipe } from "effect/Function"
642
+ *
643
+ * const sum = dual<
644
+ * (that: number) => (self: number) => number,
645
+ * (self: number, that: number) => number
646
+ * >(2, (self, that) => self + that)
647
+ *
648
+ * console.log(sum(2, 3)) // 5
649
+ * console.log(pipe(2, sum(3))) // 5
650
+ * ```
651
+ *
652
+ * **Example** (Using call signatures to define the overloads)
653
+ *
654
+ * ```ts
655
+ * import { dual, pipe } from "effect/Function"
656
+ *
657
+ * const sum: {
658
+ * (that: number): (self: number) => number
659
+ * (self: number, that: number): number
660
+ * } = dual(2, (self: number, that: number): number => self + that)
661
+ *
662
+ * console.log(sum(2, 3)) // 5
663
+ * console.log(pipe(2, sum(3))) // 5
664
+ * ```
665
+ *
666
+ * **Example** (Using a predicate to determine data-first or data-last style)
667
+ *
668
+ * ```ts
669
+ * import { dual, pipe } from "effect/Function"
670
+ *
671
+ * const sum = dual<
672
+ * (that: number) => (self: number) => number,
673
+ * (self: number, that: number) => number
674
+ * >(
675
+ * (args) => args.length === 2,
676
+ * (self, that) => self + that
677
+ * )
678
+ *
679
+ * console.log(sum(2, 3)) // 5
680
+ * console.log(pipe(2, sum(3))) // 5
681
+ * ```
682
+ *
683
+ * @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.
684
+ * @param body - The function to be curried.
685
+ * @since 1.0.0
686
+ */
687
+ const dual = function(arity, body) {
688
+ if (typeof arity === "function") return function() {
689
+ return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
690
+ };
691
+ switch (arity) {
692
+ case 0:
693
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
694
+ case 2: return function(a, b) {
695
+ if (arguments.length >= 2) return body(a, b);
696
+ return function(self) {
697
+ return body(self, a);
698
+ };
699
+ };
700
+ case 3: return function(a, b, c) {
701
+ if (arguments.length >= 3) return body(a, b, c);
702
+ return function(self) {
703
+ return body(self, a, b);
704
+ };
705
+ };
706
+ default: return function() {
707
+ if (arguments.length >= arity) return body.apply(this, arguments);
708
+ const args = arguments;
709
+ return function(self) {
710
+ return body(self, ...args);
711
+ };
712
+ };
713
+ }
714
+ };
715
+ /**
716
+ * Do nothing and return `false`.
717
+ *
718
+ * @returns false
719
+ */
720
+ function constFalse() {
721
+ return false;
722
+ }
723
+ /**
724
+ * 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`.
725
+ * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
726
+ *
727
+ * @param self - The first function to apply (or the composed function in data-last style).
728
+ * @param bc - The second function to apply.
729
+ * @returns A composed function that applies both functions in sequence.
730
+ * @example
731
+ * ```ts
732
+ * import * as assert from "node:assert"
733
+ * import { compose } from "effect/Function"
734
+ *
735
+ * const increment = (n: number) => n + 1;
736
+ * const square = (n: number) => n * n;
737
+ *
738
+ * assert.strictEqual(compose(increment, square)(2), 9);
739
+ * ```
740
+ *
741
+ * @since 1.0.0
742
+ */
743
+ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
744
+ function getOrElseUpdate(map, key, callback) {
745
+ if (map.has(key)) return map.get(key);
746
+ const value = callback();
747
+ map.set(key, value);
748
+ return value;
749
+ }
750
+
437
751
  //#endregion
438
752
  //#region src/react-version.ts
439
753
  const _require = module.createRequire(process.cwd() + path.sep);
@@ -454,7 +768,7 @@ function getReactVersion(fallback) {
454
768
  //#region src/regexp.ts
455
769
  /**
456
770
  * Convert a string to the `RegExp`.
457
- * Normal strings (e.g., `"foo"`) is converted to `/^foo$/` of `RegExp`.
771
+ * Normal strings (ex: `"foo"`) is converted to `/^foo$/` of `RegExp`.
458
772
  * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
459
773
  * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
460
774
  * @param string The string to convert.
@@ -492,13 +806,11 @@ function report(context) {
492
806
  //#endregion
493
807
  //#region src/settings.ts
494
808
  /**
495
- * Schema for ESLint React settings configuration
496
809
  * @internal
497
810
  */
498
811
  const ESLintReactSettingsSchema = z.object({
499
812
  importSource: z.optional(z.string()),
500
813
  compilationMode: z.optional(z.enum([
501
- "off",
502
814
  "infer",
503
815
  "annotation",
504
816
  "syntax",
@@ -506,100 +818,49 @@ const ESLintReactSettingsSchema = z.object({
506
818
  ])),
507
819
  polymorphicPropName: z.optional(z.string()),
508
820
  version: z.optional(z.string()),
509
- additionalStateHooks: z.optional(z.string())
821
+ additionalStateHooks: z.optional(z.string()),
822
+ additionalEffectHooks: z.optional(z.string())
510
823
  });
511
824
  /**
512
- * Schema for ESLint settings
513
825
  * @internal
514
826
  */
515
827
  const ESLintSettingsSchema = z.optional(z.object({ "react-x": z.optional(z.unknown()) }));
516
- /**
517
- * Default ESLint React settings
518
- */
519
828
  const DEFAULT_ESLINT_REACT_SETTINGS = {
520
829
  version: "detect",
521
830
  importSource: "react",
522
- compilationMode: "annotation",
523
831
  polymorphicPropName: "as"
524
832
  };
525
- /**
526
- * Default ESLint settings with React settings included
527
- */
528
833
  const DEFAULT_ESLINT_SETTINGS = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
529
- /**
530
- * Check if the provided settings conform to ESLintSettings schema
531
- * @param settings The settings object to validate
532
- */
533
834
  function isESLintSettings(settings) {
534
835
  return ESLintSettingsSchema.safeParse(settings).success;
535
836
  }
536
- /**
537
- * Check if the provided settings conform to ESLintReactSettings schema
538
- * @param settings The settings object to validate
539
- */
540
837
  function isESLintReactSettings(settings) {
541
838
  return ESLintReactSettingsSchema.safeParse(settings).success;
542
839
  }
543
- /**
544
- * Coerces unknown input to ESLintSettings type
545
- * @param settings The settings object to coerce
546
- */
547
- const coerceESLintSettings = (settings) => {
548
- return settings;
549
- };
550
- /**
551
- * Decodes and validates ESLint settings, using defaults if invalid
552
- * @param settings The settings object to decode
553
- */
554
840
  const decodeESLintSettings = (settings) => {
555
841
  if (isESLintSettings(settings)) return settings;
556
842
  return DEFAULT_ESLINT_SETTINGS;
557
843
  };
558
- /**
559
- * Coerces unknown input to ESLintReactSettings type
560
- * @param settings The settings object to coerce
561
- */
562
- const coerceSettings = (settings) => {
563
- return settings;
564
- };
565
- /**
566
- * Decodes and validates ESLint React settings, using defaults if invalid
567
- * @param settings The settings object to decode
568
- */
569
844
  const decodeSettings = (settings) => {
570
845
  if (isESLintReactSettings(settings)) return settings;
571
846
  return DEFAULT_ESLINT_REACT_SETTINGS;
572
847
  };
573
- /**
574
- * Normalizes ESLint React settings to a consistent internal format
575
- * Transforms component definitions and resolves version information
576
- */
577
- const normalizeSettings = ({ importSource = "react", compilationMode = "annotation", polymorphicPropName = "as", version, additionalStateHooks, ...rest }) => {
848
+ const normalizeSettings = ({ importSource = "react", compilationMode, polymorphicPropName = "as", version, additionalStateHooks, additionalEffectHooks, ...rest }) => {
578
849
  return {
579
850
  ...rest,
580
851
  importSource,
581
- compilationMode,
582
- isCompilerEnabled: compilationMode !== "off",
852
+ compilationMode: compilationMode ?? "off",
583
853
  polymorphicPropName,
584
854
  version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.2.4")).otherwise(identity),
585
- additionalStateHooks: toRegExp(additionalStateHooks)
855
+ additionalStateHooks: toRegExp(additionalStateHooks),
856
+ additionalEffectHooks: toRegExp(additionalEffectHooks)
586
857
  };
587
858
  };
588
859
  const cache = /* @__PURE__ */ new Map();
589
- /**
590
- * Retrieves normalized ESLint React settings from the rule context
591
- * Uses caching for performance optimization
592
- * @param context The ESLint rule context
593
- */
594
860
  function getSettingsFromContext(context) {
595
861
  const settings = context.settings;
596
862
  return getOrElseUpdate(cache, settings["react-x"], () => normalizeSettings(decodeSettings(settings["react-x"])));
597
863
  }
598
- /**
599
- * Helper function for defining typed settings for "react-x" in JavaScript files
600
- * Provides type checking without runtime transformation
601
- */
602
- const defineSettings = identity;
603
864
 
604
865
  //#endregion
605
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, IMPURE_CONSTRUCTORS, IMPURE_FUNCTIONS, IdGenerator, NPM_SCOPE, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineRuleListener, defineSettings, getConfigAdapters, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
866
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, IdGenerator, NPM_SCOPE, PURE_CTORS, PURE_FUNCS, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, WEBSITE_URL, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "3.0.0-next.9",
3
+ "version": "3.0.0-rc.0",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -32,18 +32,19 @@
32
32
  "dependencies": {
33
33
  "@typescript-eslint/utils": "canary",
34
34
  "ts-pattern": "^5.9.0",
35
- "zod": "^3.25.0 || ^4.0.0",
36
- "@eslint-react/eff": "3.0.0-next.9"
35
+ "zod": "^4.3.6"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@tsconfig/node24": "^24.0.4",
39
+ "@types/node": "^25.3.5",
40
40
  "@types/picomatch": "^4.0.2",
41
- "tsdown": "^0.20.3",
42
- "@local/configs": "0.0.0"
41
+ "tsdown": "^0.21.0",
42
+ "@local/configs": "0.0.0",
43
+ "@local/eff": "3.0.0-beta.72"
43
44
  },
44
45
  "peerDependencies": {
45
- "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
46
- "typescript": ">=4.8.4 <6.0.0"
46
+ "eslint": "^10.0.0",
47
+ "typescript": "*"
47
48
  },
48
49
  "engines": {
49
50
  "node": ">=22.0.0"
@@ -52,6 +53,6 @@
52
53
  "build": "tsdown --dts-resolve",
53
54
  "build:docs": "typedoc",
54
55
  "lint:publish": "publint",
55
- "lint:ts": "tsc --noEmit"
56
+ "lint:ts": "tsl"
56
57
  }
57
58
  }