@eslint-react/shared 3.0.0-next.55 → 3.0.0-next.57

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.
package/dist/index.d.ts CHANGED
@@ -21,115 +21,6 @@ declare class IdGenerator {
21
21
  next(): string;
22
22
  }
23
23
  //#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 = "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
24
  //#region src/constants.d.ts
134
25
  /**
135
26
  * The NPM scope for this project.
@@ -270,6 +161,55 @@ declare function toRegExp(string: string | unit): RegExpLike;
270
161
  */
271
162
  declare function isRegExp(string: string): boolean;
272
163
  //#endregion
164
+ //#region src/types.d.ts
165
+ /**
166
+ * Rule severity.
167
+ * @since 0.0.1
168
+ */
169
+ type SeverityName = "off" | "warn" | "error";
170
+ /**
171
+ * The numeric severity level for a rule.
172
+ *
173
+ * - `0` means off.
174
+ * - `1` means warn.
175
+ * - `2` means error.
176
+ */
177
+ type SeverityLevel = 0 | 1 | 2;
178
+ /**
179
+ * The severity of a rule in a configuration.
180
+ */
181
+ type Severity = SeverityName | SeverityLevel;
182
+ /**
183
+ * Rule declaration.
184
+ * @internal
185
+ * @since 0.0.1
186
+ */
187
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
188
+ /**
189
+ * Rule context.
190
+ * @since 0.0.1
191
+ */
192
+ type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
193
+ /**
194
+ * Rule feature.
195
+ * @since 1.20.0
196
+ */
197
+ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
198
+ /**
199
+ * A suggestion for fixing a reported issue.
200
+ */
201
+ type RuleSuggest<MessageIds extends string = string> = {
202
+ /** The message ID for the suggestion. */messageId: MessageIds; /** Optional data to pass to the message formatter. */
203
+ data?: Record<string, unknown>; /** The fix function to apply the suggestion. */
204
+ fix: tseslint.ReportFixFunction;
205
+ };
206
+ /**
207
+ * A collection of settings.
208
+ */
209
+ interface SettingsConfig {
210
+ [key: string]: unknown;
211
+ }
212
+ //#endregion
273
213
  //#region src/report.d.ts
274
214
  /**
275
215
  * Creates a report function for the given rule context.
@@ -280,7 +220,6 @@ declare function report(context: RuleContext): (descriptor?: null | ReportDescri
280
220
  //#endregion
281
221
  //#region src/settings.d.ts
282
222
  /**
283
- * Schema for ESLint React settings configuration
284
223
  * @internal
285
224
  */
286
225
  declare const ESLintReactSettingsSchema: z.ZodObject<{
@@ -297,42 +236,26 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
297
236
  additionalEffectHooks: z.ZodOptional<z.ZodString>;
298
237
  }, z.core.$strip>;
299
238
  /**
300
- * Schema for ESLint settings
301
239
  * @internal
302
240
  */
303
241
  declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
304
242
  "react-x": z.ZodOptional<z.ZodUnknown>;
305
243
  }, z.core.$strip>>;
306
- /**
307
- * ESLint settings type inferred from the settings schema.
308
- */
309
244
  type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
310
- /**
311
- * ESLint React settings type inferred from the React settings schema.
312
- */
313
245
  type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
314
- /**
315
- * Normalized ESLint React settings with processed values
316
- */
317
246
  interface ESLintReactSettingsNormalized {
318
247
  version: string;
319
248
  importSource: string;
320
- compilationMode: CompilationMode | "off";
249
+ compilationMode: ESLintReactSettings["compilationMode"] | "off";
321
250
  polymorphicPropName: string | unit;
322
251
  additionalStateHooks: RegExpLike;
323
252
  additionalEffectHooks: RegExpLike;
324
253
  }
325
- /**
326
- * Default ESLint React settings
327
- */
328
254
  declare const DEFAULT_ESLINT_REACT_SETTINGS: {
329
255
  readonly version: "detect";
330
256
  readonly importSource: "react";
331
257
  readonly polymorphicPropName: "as";
332
258
  };
333
- /**
334
- * Default ESLint settings with React settings included
335
- */
336
259
  declare const DEFAULT_ESLINT_SETTINGS: {
337
260
  readonly "react-x": {
338
261
  readonly version: "detect";
@@ -340,40 +263,10 @@ declare const DEFAULT_ESLINT_SETTINGS: {
340
263
  readonly polymorphicPropName: "as";
341
264
  };
342
265
  };
343
- /**
344
- * Check if the provided settings conform to ESLintSettings schema
345
- * @param settings The settings object to validate
346
- */
347
266
  declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
348
- /**
349
- * Check if the provided settings conform to ESLintReactSettings schema
350
- * @param settings The settings object to validate
351
- */
352
267
  declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
353
- /**
354
- * Coerces unknown input to ESLintSettings type
355
- * @param settings The settings object to coerce
356
- */
357
- declare const coerceESLintSettings: (settings: unknown) => Partial<ESLintSettings>;
358
- /**
359
- * Decodes and validates ESLint settings, using defaults if invalid
360
- * @param settings The settings object to decode
361
- */
362
268
  declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
363
- /**
364
- * Coerces unknown input to ESLintReactSettings type
365
- * @param settings The settings object to coerce
366
- */
367
- declare const coerceSettings: (settings: unknown) => Partial<ESLintReactSettings>;
368
- /**
369
- * Decodes and validates ESLint React settings, using defaults if invalid
370
- * @param settings The settings object to decode
371
- */
372
269
  declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
373
- /**
374
- * Normalizes ESLint React settings to a consistent internal format
375
- * Transforms component definitions and resolves version information
376
- */
377
270
  declare const normalizeSettings: ({
378
271
  importSource,
379
272
  compilationMode,
@@ -384,27 +277,17 @@ declare const normalizeSettings: ({
384
277
  ...rest
385
278
  }: ESLintReactSettings) => {
386
279
  readonly importSource: string;
387
- readonly compilationMode: "off" | "infer" | "annotation" | "syntax" | "all";
280
+ readonly compilationMode: "infer" | "annotation" | "syntax" | "all" | "off";
388
281
  readonly polymorphicPropName: string;
389
282
  readonly version: string;
390
283
  readonly additionalStateHooks: RegExpLike;
391
284
  readonly additionalEffectHooks: RegExpLike;
392
285
  };
393
- /**
394
- * Retrieves normalized ESLint React settings from the rule context
395
- * Uses caching for performance optimization
396
- * @param context The ESLint rule context
397
- */
398
286
  declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
399
- /**
400
- * Helper function for defining typed settings for "react-x" in JavaScript files
401
- * Provides type checking without runtime transformation
402
- */
403
- declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
404
287
  declare module "@typescript-eslint/utils/ts-eslint" {
405
288
  interface SharedConfigurationSettings {
406
289
  ["react-x"]?: Partial<ESLintReactSettings>;
407
290
  }
408
291
  }
409
292
  //#endregion
410
- export { CompatibleConfig, CompatiblePlugin, CompatibleRule, CompilationMode, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, 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 };
293
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, 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, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/dist/index.js CHANGED
@@ -28,33 +28,6 @@ var IdGenerator = class {
28
28
  }
29
29
  };
30
30
 
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
31
  //#endregion
59
32
  //#region src/constants.ts
60
33
  /**
@@ -492,7 +465,6 @@ function report(context) {
492
465
  //#endregion
493
466
  //#region src/settings.ts
494
467
  /**
495
- * Schema for ESLint React settings configuration
496
468
  * @internal
497
469
  */
498
470
  const ESLintReactSettingsSchema = z.object({
@@ -509,70 +481,29 @@ const ESLintReactSettingsSchema = z.object({
509
481
  additionalEffectHooks: z.optional(z.string())
510
482
  });
511
483
  /**
512
- * Schema for ESLint settings
513
484
  * @internal
514
485
  */
515
486
  const ESLintSettingsSchema = z.optional(z.object({ "react-x": z.optional(z.unknown()) }));
516
- /**
517
- * Default ESLint React settings
518
- */
519
487
  const DEFAULT_ESLINT_REACT_SETTINGS = {
520
488
  version: "detect",
521
489
  importSource: "react",
522
490
  polymorphicPropName: "as"
523
491
  };
524
- /**
525
- * Default ESLint settings with React settings included
526
- */
527
492
  const DEFAULT_ESLINT_SETTINGS = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
528
- /**
529
- * Check if the provided settings conform to ESLintSettings schema
530
- * @param settings The settings object to validate
531
- */
532
493
  function isESLintSettings(settings) {
533
494
  return ESLintSettingsSchema.safeParse(settings).success;
534
495
  }
535
- /**
536
- * Check if the provided settings conform to ESLintReactSettings schema
537
- * @param settings The settings object to validate
538
- */
539
496
  function isESLintReactSettings(settings) {
540
497
  return ESLintReactSettingsSchema.safeParse(settings).success;
541
498
  }
542
- /**
543
- * Coerces unknown input to ESLintSettings type
544
- * @param settings The settings object to coerce
545
- */
546
- const coerceESLintSettings = (settings) => {
547
- return settings;
548
- };
549
- /**
550
- * Decodes and validates ESLint settings, using defaults if invalid
551
- * @param settings The settings object to decode
552
- */
553
499
  const decodeESLintSettings = (settings) => {
554
500
  if (isESLintSettings(settings)) return settings;
555
501
  return DEFAULT_ESLINT_SETTINGS;
556
502
  };
557
- /**
558
- * Coerces unknown input to ESLintReactSettings type
559
- * @param settings The settings object to coerce
560
- */
561
- const coerceSettings = (settings) => {
562
- return settings;
563
- };
564
- /**
565
- * Decodes and validates ESLint React settings, using defaults if invalid
566
- * @param settings The settings object to decode
567
- */
568
503
  const decodeSettings = (settings) => {
569
504
  if (isESLintReactSettings(settings)) return settings;
570
505
  return DEFAULT_ESLINT_REACT_SETTINGS;
571
506
  };
572
- /**
573
- * Normalizes ESLint React settings to a consistent internal format
574
- * Transforms component definitions and resolves version information
575
- */
576
507
  const normalizeSettings = ({ importSource = "react", compilationMode, polymorphicPropName = "as", version, additionalStateHooks, additionalEffectHooks, ...rest }) => {
577
508
  return {
578
509
  ...rest,
@@ -585,20 +516,10 @@ const normalizeSettings = ({ importSource = "react", compilationMode, polymorphi
585
516
  };
586
517
  };
587
518
  const cache = /* @__PURE__ */ new Map();
588
- /**
589
- * Retrieves normalized ESLint React settings from the rule context
590
- * Uses caching for performance optimization
591
- * @param context The ESLint rule context
592
- */
593
519
  function getSettingsFromContext(context) {
594
520
  const settings = context.settings;
595
521
  return getOrElseUpdate(cache, settings["react-x"], () => normalizeSettings(decodeSettings(settings["react-x"])));
596
522
  }
597
- /**
598
- * Helper function for defining typed settings for "react-x" in JavaScript files
599
- * Provides type checking without runtime transformation
600
- */
601
- const defineSettings = identity;
602
523
 
603
524
  //#endregion
604
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, 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 };
525
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, 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, 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.55",
3
+ "version": "3.0.0-next.57",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -33,13 +33,13 @@
33
33
  "@typescript-eslint/utils": "canary",
34
34
  "ts-pattern": "^5.9.0",
35
35
  "zod": "^3.25.0 || ^4.0.0",
36
- "@eslint-react/eff": "3.0.0-next.55"
36
+ "@eslint-react/eff": "3.0.0-next.57"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@tsconfig/node24": "^24.0.4",
40
40
  "@types/node": "^25.3.1",
41
41
  "@types/picomatch": "^4.0.2",
42
- "tsdown": "^0.21.0-beta.1",
42
+ "tsdown": "^0.21.0-beta.2",
43
43
  "@local/configs": "0.0.0"
44
44
  },
45
45
  "peerDependencies": {