@eslint-react/shared 3.0.0-next.6 → 3.0.0-next.60
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 +59 -177
- package/dist/index.js +9 -89
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unit } from "@eslint-react/eff";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
import * as tseslint from "@typescript-eslint/utils/ts-eslint";
|
|
4
|
-
import { ReportDescriptor, RuleListener } from "@typescript-eslint/utils/ts-eslint";
|
|
4
|
+
import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener } from "@typescript-eslint/utils/ts-eslint";
|
|
5
5
|
|
|
6
6
|
//#region src/_id.d.ts
|
|
7
7
|
/**
|
|
@@ -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 = "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
24
|
//#region src/constants.d.ts
|
|
134
25
|
/**
|
|
135
26
|
* The NPM scope for this project.
|
|
@@ -215,11 +106,11 @@ declare const RE_HOOK_NAME: RegExp;
|
|
|
215
106
|
/**
|
|
216
107
|
* Known impure functions
|
|
217
108
|
*/
|
|
218
|
-
declare const
|
|
109
|
+
declare const IMPURE_FUNCS: ReadonlyMap<string, ReadonlySet<string>>;
|
|
219
110
|
/**
|
|
220
111
|
* Known impure global constructors used with `new`
|
|
221
112
|
*/
|
|
222
|
-
declare const
|
|
113
|
+
declare const IMPURE_CTORS: ReadonlySet<string>;
|
|
223
114
|
//#endregion
|
|
224
115
|
//#region src/define-rule-listener.d.ts
|
|
225
116
|
/**
|
|
@@ -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
|
+
/** Optional data to pass to the message formatter. */data?: Record<string, unknown>; /** The fix function to apply the suggestion. */
|
|
203
|
+
fix: tseslint.ReportFixFunction; /** The message ID for the suggestion. */
|
|
204
|
+
messageId: MessageIds;
|
|
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,13 +220,11 @@ 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<{
|
|
287
226
|
importSource: z.ZodOptional<z.ZodString>;
|
|
288
227
|
compilationMode: z.ZodOptional<z.ZodEnum<{
|
|
289
|
-
off: "off";
|
|
290
228
|
infer: "infer";
|
|
291
229
|
annotation: "annotation";
|
|
292
230
|
syntax: "syntax";
|
|
@@ -295,117 +233,61 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
295
233
|
polymorphicPropName: z.ZodOptional<z.ZodString>;
|
|
296
234
|
version: z.ZodOptional<z.ZodString>;
|
|
297
235
|
additionalStateHooks: z.ZodOptional<z.ZodString>;
|
|
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:
|
|
321
|
-
isCompilerEnabled: boolean;
|
|
249
|
+
compilationMode: ESLintReactSettings["compilationMode"] | "off";
|
|
322
250
|
polymorphicPropName: string | unit;
|
|
323
251
|
additionalStateHooks: RegExpLike;
|
|
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
|
-
readonly compilationMode: "annotation";
|
|
332
257
|
readonly polymorphicPropName: "as";
|
|
333
258
|
};
|
|
334
|
-
/**
|
|
335
|
-
* Default ESLint settings with React settings included
|
|
336
|
-
*/
|
|
337
259
|
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
338
260
|
readonly "react-x": {
|
|
339
261
|
readonly version: "detect";
|
|
340
262
|
readonly importSource: "react";
|
|
341
|
-
readonly compilationMode: "annotation";
|
|
342
263
|
readonly polymorphicPropName: "as";
|
|
343
264
|
};
|
|
344
265
|
};
|
|
345
|
-
/**
|
|
346
|
-
* Check if the provided settings conform to ESLintSettings schema
|
|
347
|
-
* @param settings The settings object to validate
|
|
348
|
-
*/
|
|
349
266
|
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
267
|
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
268
|
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
269
|
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
270
|
declare const normalizeSettings: ({
|
|
380
271
|
importSource,
|
|
381
272
|
compilationMode,
|
|
382
273
|
polymorphicPropName,
|
|
383
274
|
version,
|
|
384
275
|
additionalStateHooks,
|
|
276
|
+
additionalEffectHooks,
|
|
385
277
|
...rest
|
|
386
278
|
}: ESLintReactSettings) => {
|
|
387
279
|
readonly importSource: string;
|
|
388
|
-
readonly compilationMode: "
|
|
389
|
-
readonly isCompilerEnabled: boolean;
|
|
280
|
+
readonly compilationMode: "infer" | "annotation" | "syntax" | "all" | "off";
|
|
390
281
|
readonly polymorphicPropName: string;
|
|
391
282
|
readonly version: string;
|
|
392
283
|
readonly additionalStateHooks: RegExpLike;
|
|
284
|
+
readonly additionalEffectHooks: RegExpLike;
|
|
393
285
|
};
|
|
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
286
|
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
287
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
406
288
|
interface SharedConfigurationSettings {
|
|
407
289
|
["react-x"]?: Partial<ESLintReactSettings>;
|
|
408
290
|
}
|
|
409
291
|
}
|
|
410
292
|
//#endregion
|
|
411
|
-
export {
|
|
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
|
/**
|
|
@@ -141,7 +114,7 @@ const RE_HOOK_NAME = /^use/u;
|
|
|
141
114
|
/**
|
|
142
115
|
* Known impure functions
|
|
143
116
|
*/
|
|
144
|
-
const
|
|
117
|
+
const IMPURE_FUNCS = new Map([
|
|
145
118
|
["Atomics", new Set([
|
|
146
119
|
"add",
|
|
147
120
|
"and",
|
|
@@ -379,7 +352,7 @@ const IMPURE_FUNCTIONS = new Map([
|
|
|
379
352
|
/**
|
|
380
353
|
* Known impure global constructors used with `new`
|
|
381
354
|
*/
|
|
382
|
-
const
|
|
355
|
+
const IMPURE_CTORS = new Set([
|
|
383
356
|
"AbortController",
|
|
384
357
|
"Audio",
|
|
385
358
|
"AudioContext",
|
|
@@ -492,13 +465,11 @@ 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({
|
|
499
471
|
importSource: z.optional(z.string()),
|
|
500
472
|
compilationMode: z.optional(z.enum([
|
|
501
|
-
"off",
|
|
502
473
|
"infer",
|
|
503
474
|
"annotation",
|
|
504
475
|
"syntax",
|
|
@@ -506,100 +477,49 @@ const ESLintReactSettingsSchema = z.object({
|
|
|
506
477
|
])),
|
|
507
478
|
polymorphicPropName: z.optional(z.string()),
|
|
508
479
|
version: z.optional(z.string()),
|
|
509
|
-
additionalStateHooks: z.optional(z.string())
|
|
480
|
+
additionalStateHooks: z.optional(z.string()),
|
|
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
|
-
compilationMode: "annotation",
|
|
523
490
|
polymorphicPropName: "as"
|
|
524
491
|
};
|
|
525
|
-
/**
|
|
526
|
-
* Default ESLint settings with React settings included
|
|
527
|
-
*/
|
|
528
492
|
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
493
|
function isESLintSettings(settings) {
|
|
534
494
|
return ESLintSettingsSchema.safeParse(settings).success;
|
|
535
495
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Check if the provided settings conform to ESLintReactSettings schema
|
|
538
|
-
* @param settings The settings object to validate
|
|
539
|
-
*/
|
|
540
496
|
function isESLintReactSettings(settings) {
|
|
541
497
|
return ESLintReactSettingsSchema.safeParse(settings).success;
|
|
542
498
|
}
|
|
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
499
|
const decodeESLintSettings = (settings) => {
|
|
555
500
|
if (isESLintSettings(settings)) return settings;
|
|
556
501
|
return DEFAULT_ESLINT_SETTINGS;
|
|
557
502
|
};
|
|
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
503
|
const decodeSettings = (settings) => {
|
|
570
504
|
if (isESLintReactSettings(settings)) return settings;
|
|
571
505
|
return DEFAULT_ESLINT_REACT_SETTINGS;
|
|
572
506
|
};
|
|
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 }) => {
|
|
507
|
+
const normalizeSettings = ({ importSource = "react", compilationMode, polymorphicPropName = "as", version, additionalStateHooks, additionalEffectHooks, ...rest }) => {
|
|
578
508
|
return {
|
|
579
509
|
...rest,
|
|
580
510
|
importSource,
|
|
581
|
-
compilationMode,
|
|
582
|
-
isCompilerEnabled: compilationMode !== "off",
|
|
511
|
+
compilationMode: compilationMode ?? "off",
|
|
583
512
|
polymorphicPropName,
|
|
584
513
|
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.2.4")).otherwise(identity),
|
|
585
|
-
additionalStateHooks: toRegExp(additionalStateHooks)
|
|
514
|
+
additionalStateHooks: toRegExp(additionalStateHooks),
|
|
515
|
+
additionalEffectHooks: toRegExp(additionalEffectHooks)
|
|
586
516
|
};
|
|
587
517
|
};
|
|
588
518
|
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
519
|
function getSettingsFromContext(context) {
|
|
595
520
|
const settings = context.settings;
|
|
596
521
|
return getOrElseUpdate(cache, settings["react-x"], () => normalizeSettings(decodeSettings(settings["react-x"])));
|
|
597
522
|
}
|
|
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
523
|
|
|
604
524
|
//#endregion
|
|
605
|
-
export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL,
|
|
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.
|
|
3
|
+
"version": "3.0.0-next.60",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@typescript-eslint/utils": "canary",
|
|
34
34
|
"ts-pattern": "^5.9.0",
|
|
35
|
-
"zod": "^
|
|
36
|
-
"@eslint-react/eff": "3.0.0-next.
|
|
35
|
+
"zod": "^4.3.6",
|
|
36
|
+
"@eslint-react/eff": "3.0.0-next.60"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@tsconfig/node24": "^24.0.4",
|
|
40
|
+
"@types/node": "^25.3.2",
|
|
40
41
|
"@types/picomatch": "^4.0.2",
|
|
41
|
-
"tsdown": "^0.
|
|
42
|
+
"tsdown": "^0.21.0-beta.2",
|
|
42
43
|
"@local/configs": "0.0.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
@@ -52,6 +53,6 @@
|
|
|
52
53
|
"build": "tsdown --dts-resolve",
|
|
53
54
|
"build:docs": "typedoc",
|
|
54
55
|
"lint:publish": "publint",
|
|
55
|
-
"lint:ts": "
|
|
56
|
+
"lint:ts": "tsl"
|
|
56
57
|
}
|
|
57
58
|
}
|