@eslint-react/shared 3.0.0-next.7 → 3.0.0-next.71
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 +61 -180
- package/dist/index.js +9 -89
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
-
import { ReportDescriptor, RuleListener } from "@typescript-eslint/utils/ts-eslint";
|
|
3
|
+
import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener } from "@typescript-eslint/utils/ts-eslint";
|
|
5
4
|
|
|
6
5
|
//#region src/_id.d.ts
|
|
7
6
|
/**
|
|
@@ -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,11 @@ declare const RE_HOOK_NAME: RegExp;
|
|
|
215
105
|
/**
|
|
216
106
|
* Known impure functions
|
|
217
107
|
*/
|
|
218
|
-
declare const
|
|
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
|
|
112
|
+
declare const IMPURE_CTORS: ReadonlySet<string>;
|
|
223
113
|
//#endregion
|
|
224
114
|
//#region src/define-rule-listener.d.ts
|
|
225
115
|
/**
|
|
@@ -262,7 +152,7 @@ type RegExpLike = {
|
|
|
262
152
|
* @param string The string to convert.
|
|
263
153
|
* @returns Returns the `RegExp`.
|
|
264
154
|
*/
|
|
265
|
-
declare function toRegExp(string: string |
|
|
155
|
+
declare function toRegExp(string: string | null | undefined): RegExpLike;
|
|
266
156
|
/**
|
|
267
157
|
* Check whether given string is regexp string
|
|
268
158
|
* @param string The string to check
|
|
@@ -270,6 +160,55 @@ declare function toRegExp(string: string | unit): RegExpLike;
|
|
|
270
160
|
*/
|
|
271
161
|
declare function isRegExp(string: string): boolean;
|
|
272
162
|
//#endregion
|
|
163
|
+
//#region src/types.d.ts
|
|
164
|
+
/**
|
|
165
|
+
* Rule severity.
|
|
166
|
+
* @since 0.0.1
|
|
167
|
+
*/
|
|
168
|
+
type SeverityName = "off" | "warn" | "error";
|
|
169
|
+
/**
|
|
170
|
+
* The numeric severity level for a rule.
|
|
171
|
+
*
|
|
172
|
+
* - `0` means off.
|
|
173
|
+
* - `1` means warn.
|
|
174
|
+
* - `2` means error.
|
|
175
|
+
*/
|
|
176
|
+
type SeverityLevel = 0 | 1 | 2;
|
|
177
|
+
/**
|
|
178
|
+
* The severity of a rule in a configuration.
|
|
179
|
+
*/
|
|
180
|
+
type Severity = SeverityName | SeverityLevel;
|
|
181
|
+
/**
|
|
182
|
+
* Rule declaration.
|
|
183
|
+
* @internal
|
|
184
|
+
* @since 0.0.1
|
|
185
|
+
*/
|
|
186
|
+
type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
|
187
|
+
/**
|
|
188
|
+
* Rule context.
|
|
189
|
+
* @since 0.0.1
|
|
190
|
+
*/
|
|
191
|
+
type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
|
|
192
|
+
/**
|
|
193
|
+
* Rule feature.
|
|
194
|
+
* @since 1.20.0
|
|
195
|
+
*/
|
|
196
|
+
type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
|
|
197
|
+
/**
|
|
198
|
+
* A suggestion for fixing a reported issue.
|
|
199
|
+
*/
|
|
200
|
+
type RuleSuggest<MessageIds extends string = string> = {
|
|
201
|
+
/** Optional data to pass to the message formatter. */data?: Record<string, unknown>; /** The fix function to apply the suggestion. */
|
|
202
|
+
fix: tseslint.ReportFixFunction; /** The message ID for the suggestion. */
|
|
203
|
+
messageId: MessageIds;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* A collection of settings.
|
|
207
|
+
*/
|
|
208
|
+
interface SettingsConfig {
|
|
209
|
+
[key: string]: unknown;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
273
212
|
//#region src/report.d.ts
|
|
274
213
|
/**
|
|
275
214
|
* Creates a report function for the given rule context.
|
|
@@ -280,13 +219,11 @@ declare function report(context: RuleContext): (descriptor?: null | ReportDescri
|
|
|
280
219
|
//#endregion
|
|
281
220
|
//#region src/settings.d.ts
|
|
282
221
|
/**
|
|
283
|
-
* Schema for ESLint React settings configuration
|
|
284
222
|
* @internal
|
|
285
223
|
*/
|
|
286
224
|
declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
287
225
|
importSource: z.ZodOptional<z.ZodString>;
|
|
288
226
|
compilationMode: z.ZodOptional<z.ZodEnum<{
|
|
289
|
-
off: "off";
|
|
290
227
|
infer: "infer";
|
|
291
228
|
annotation: "annotation";
|
|
292
229
|
syntax: "syntax";
|
|
@@ -295,117 +232,61 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
295
232
|
polymorphicPropName: z.ZodOptional<z.ZodString>;
|
|
296
233
|
version: z.ZodOptional<z.ZodString>;
|
|
297
234
|
additionalStateHooks: z.ZodOptional<z.ZodString>;
|
|
235
|
+
additionalEffectHooks: z.ZodOptional<z.ZodString>;
|
|
298
236
|
}, z.core.$strip>;
|
|
299
237
|
/**
|
|
300
|
-
* Schema for ESLint settings
|
|
301
238
|
* @internal
|
|
302
239
|
*/
|
|
303
240
|
declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
|
|
304
241
|
"react-x": z.ZodOptional<z.ZodUnknown>;
|
|
305
242
|
}, z.core.$strip>>;
|
|
306
|
-
/**
|
|
307
|
-
* ESLint settings type inferred from the settings schema.
|
|
308
|
-
*/
|
|
309
243
|
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
310
|
-
/**
|
|
311
|
-
* ESLint React settings type inferred from the React settings schema.
|
|
312
|
-
*/
|
|
313
244
|
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
314
|
-
/**
|
|
315
|
-
* Normalized ESLint React settings with processed values
|
|
316
|
-
*/
|
|
317
245
|
interface ESLintReactSettingsNormalized {
|
|
318
246
|
version: string;
|
|
319
247
|
importSource: string;
|
|
320
|
-
compilationMode:
|
|
321
|
-
|
|
322
|
-
polymorphicPropName: string | unit;
|
|
248
|
+
compilationMode: ESLintReactSettings["compilationMode"] | "off";
|
|
249
|
+
polymorphicPropName: string | null;
|
|
323
250
|
additionalStateHooks: RegExpLike;
|
|
251
|
+
additionalEffectHooks: RegExpLike;
|
|
324
252
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Default ESLint React settings
|
|
327
|
-
*/
|
|
328
253
|
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
329
254
|
readonly version: "detect";
|
|
330
255
|
readonly importSource: "react";
|
|
331
|
-
readonly compilationMode: "annotation";
|
|
332
256
|
readonly polymorphicPropName: "as";
|
|
333
257
|
};
|
|
334
|
-
/**
|
|
335
|
-
* Default ESLint settings with React settings included
|
|
336
|
-
*/
|
|
337
258
|
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
338
259
|
readonly "react-x": {
|
|
339
260
|
readonly version: "detect";
|
|
340
261
|
readonly importSource: "react";
|
|
341
|
-
readonly compilationMode: "annotation";
|
|
342
262
|
readonly polymorphicPropName: "as";
|
|
343
263
|
};
|
|
344
264
|
};
|
|
345
|
-
/**
|
|
346
|
-
* Check if the provided settings conform to ESLintSettings schema
|
|
347
|
-
* @param settings The settings object to validate
|
|
348
|
-
*/
|
|
349
265
|
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
266
|
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
267
|
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
268
|
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
269
|
declare const normalizeSettings: ({
|
|
380
270
|
importSource,
|
|
381
271
|
compilationMode,
|
|
382
272
|
polymorphicPropName,
|
|
383
273
|
version,
|
|
384
274
|
additionalStateHooks,
|
|
275
|
+
additionalEffectHooks,
|
|
385
276
|
...rest
|
|
386
277
|
}: ESLintReactSettings) => {
|
|
387
278
|
readonly importSource: string;
|
|
388
|
-
readonly compilationMode: "
|
|
389
|
-
readonly isCompilerEnabled: boolean;
|
|
279
|
+
readonly compilationMode: "infer" | "annotation" | "syntax" | "all" | "off";
|
|
390
280
|
readonly polymorphicPropName: string;
|
|
391
281
|
readonly version: string;
|
|
392
282
|
readonly additionalStateHooks: RegExpLike;
|
|
283
|
+
readonly additionalEffectHooks: RegExpLike;
|
|
393
284
|
};
|
|
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
285
|
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
286
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
406
287
|
interface SharedConfigurationSettings {
|
|
407
288
|
["react-x"]?: Partial<ESLintReactSettings>;
|
|
408
289
|
}
|
|
409
290
|
}
|
|
410
291
|
//#endregion
|
|
411
|
-
export {
|
|
292
|
+
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.71",
|
|
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.71"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@tsconfig/node24": "^24.0.4",
|
|
40
|
+
"@types/node": "^25.3.3",
|
|
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
|
}
|