@eslint-react/shared 3.0.0-next.56 → 3.0.0-next.58
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 +2 -60
- package/dist/index.js +1 -53
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -220,7 +220,6 @@ declare function report(context: RuleContext): (descriptor?: null | ReportDescri
|
|
|
220
220
|
//#endregion
|
|
221
221
|
//#region src/settings.d.ts
|
|
222
222
|
/**
|
|
223
|
-
* Schema for ESLint React settings configuration
|
|
224
223
|
* @internal
|
|
225
224
|
*/
|
|
226
225
|
declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
@@ -237,43 +236,26 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
237
236
|
additionalEffectHooks: z.ZodOptional<z.ZodString>;
|
|
238
237
|
}, z.core.$strip>;
|
|
239
238
|
/**
|
|
240
|
-
* Schema for ESLint settings
|
|
241
239
|
* @internal
|
|
242
240
|
*/
|
|
243
241
|
declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
|
|
244
242
|
"react-x": z.ZodOptional<z.ZodUnknown>;
|
|
245
243
|
}, z.core.$strip>>;
|
|
246
|
-
/**
|
|
247
|
-
* ESLint settings type inferred from the settings schema.
|
|
248
|
-
*/
|
|
249
244
|
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
250
|
-
/**
|
|
251
|
-
* ESLint React settings type inferred from the React settings schema.
|
|
252
|
-
*/
|
|
253
245
|
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
254
|
-
type CompilationMode = "infer" | "annotation" | "syntax" | "all";
|
|
255
|
-
/**
|
|
256
|
-
* Normalized ESLint React settings with processed values
|
|
257
|
-
*/
|
|
258
246
|
interface ESLintReactSettingsNormalized {
|
|
259
247
|
version: string;
|
|
260
248
|
importSource: string;
|
|
261
|
-
compilationMode:
|
|
249
|
+
compilationMode: ESLintReactSettings["compilationMode"] | "off";
|
|
262
250
|
polymorphicPropName: string | unit;
|
|
263
251
|
additionalStateHooks: RegExpLike;
|
|
264
252
|
additionalEffectHooks: RegExpLike;
|
|
265
253
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Default ESLint React settings
|
|
268
|
-
*/
|
|
269
254
|
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
270
255
|
readonly version: "detect";
|
|
271
256
|
readonly importSource: "react";
|
|
272
257
|
readonly polymorphicPropName: "as";
|
|
273
258
|
};
|
|
274
|
-
/**
|
|
275
|
-
* Default ESLint settings with React settings included
|
|
276
|
-
*/
|
|
277
259
|
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
278
260
|
readonly "react-x": {
|
|
279
261
|
readonly version: "detect";
|
|
@@ -281,40 +263,10 @@ declare const DEFAULT_ESLINT_SETTINGS: {
|
|
|
281
263
|
readonly polymorphicPropName: "as";
|
|
282
264
|
};
|
|
283
265
|
};
|
|
284
|
-
/**
|
|
285
|
-
* Check if the provided settings conform to ESLintSettings schema
|
|
286
|
-
* @param settings The settings object to validate
|
|
287
|
-
*/
|
|
288
266
|
declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
|
|
289
|
-
/**
|
|
290
|
-
* Check if the provided settings conform to ESLintReactSettings schema
|
|
291
|
-
* @param settings The settings object to validate
|
|
292
|
-
*/
|
|
293
267
|
declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
|
|
294
|
-
/**
|
|
295
|
-
* Coerces unknown input to ESLintSettings type
|
|
296
|
-
* @param settings The settings object to coerce
|
|
297
|
-
*/
|
|
298
|
-
declare const coerceESLintSettings: (settings: unknown) => Partial<ESLintSettings>;
|
|
299
|
-
/**
|
|
300
|
-
* Decodes and validates ESLint settings, using defaults if invalid
|
|
301
|
-
* @param settings The settings object to decode
|
|
302
|
-
*/
|
|
303
268
|
declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
|
|
304
|
-
/**
|
|
305
|
-
* Coerces unknown input to ESLintReactSettings type
|
|
306
|
-
* @param settings The settings object to coerce
|
|
307
|
-
*/
|
|
308
|
-
declare const coerceSettings: (settings: unknown) => Partial<ESLintReactSettings>;
|
|
309
|
-
/**
|
|
310
|
-
* Decodes and validates ESLint React settings, using defaults if invalid
|
|
311
|
-
* @param settings The settings object to decode
|
|
312
|
-
*/
|
|
313
269
|
declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
314
|
-
/**
|
|
315
|
-
* Normalizes ESLint React settings to a consistent internal format
|
|
316
|
-
* Transforms component definitions and resolves version information
|
|
317
|
-
*/
|
|
318
270
|
declare const normalizeSettings: ({
|
|
319
271
|
importSource,
|
|
320
272
|
compilationMode,
|
|
@@ -331,21 +283,11 @@ declare const normalizeSettings: ({
|
|
|
331
283
|
readonly additionalStateHooks: RegExpLike;
|
|
332
284
|
readonly additionalEffectHooks: RegExpLike;
|
|
333
285
|
};
|
|
334
|
-
/**
|
|
335
|
-
* Retrieves normalized ESLint React settings from the rule context
|
|
336
|
-
* Uses caching for performance optimization
|
|
337
|
-
* @param context The ESLint rule context
|
|
338
|
-
*/
|
|
339
286
|
declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
|
|
340
|
-
/**
|
|
341
|
-
* Helper function for defining typed settings for "react-x" in JavaScript files
|
|
342
|
-
* Provides type checking without runtime transformation
|
|
343
|
-
*/
|
|
344
|
-
declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
|
|
345
287
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
346
288
|
interface SharedConfigurationSettings {
|
|
347
289
|
["react-x"]?: Partial<ESLintReactSettings>;
|
|
348
290
|
}
|
|
349
291
|
}
|
|
350
292
|
//#endregion
|
|
351
|
-
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
|
@@ -465,7 +465,6 @@ function report(context) {
|
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/settings.ts
|
|
467
467
|
/**
|
|
468
|
-
* Schema for ESLint React settings configuration
|
|
469
468
|
* @internal
|
|
470
469
|
*/
|
|
471
470
|
const ESLintReactSettingsSchema = z.object({
|
|
@@ -482,70 +481,29 @@ const ESLintReactSettingsSchema = z.object({
|
|
|
482
481
|
additionalEffectHooks: z.optional(z.string())
|
|
483
482
|
});
|
|
484
483
|
/**
|
|
485
|
-
* Schema for ESLint settings
|
|
486
484
|
* @internal
|
|
487
485
|
*/
|
|
488
486
|
const ESLintSettingsSchema = z.optional(z.object({ "react-x": z.optional(z.unknown()) }));
|
|
489
|
-
/**
|
|
490
|
-
* Default ESLint React settings
|
|
491
|
-
*/
|
|
492
487
|
const DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
493
488
|
version: "detect",
|
|
494
489
|
importSource: "react",
|
|
495
490
|
polymorphicPropName: "as"
|
|
496
491
|
};
|
|
497
|
-
/**
|
|
498
|
-
* Default ESLint settings with React settings included
|
|
499
|
-
*/
|
|
500
492
|
const DEFAULT_ESLINT_SETTINGS = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
501
|
-
/**
|
|
502
|
-
* Check if the provided settings conform to ESLintSettings schema
|
|
503
|
-
* @param settings The settings object to validate
|
|
504
|
-
*/
|
|
505
493
|
function isESLintSettings(settings) {
|
|
506
494
|
return ESLintSettingsSchema.safeParse(settings).success;
|
|
507
495
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Check if the provided settings conform to ESLintReactSettings schema
|
|
510
|
-
* @param settings The settings object to validate
|
|
511
|
-
*/
|
|
512
496
|
function isESLintReactSettings(settings) {
|
|
513
497
|
return ESLintReactSettingsSchema.safeParse(settings).success;
|
|
514
498
|
}
|
|
515
|
-
/**
|
|
516
|
-
* Coerces unknown input to ESLintSettings type
|
|
517
|
-
* @param settings The settings object to coerce
|
|
518
|
-
*/
|
|
519
|
-
const coerceESLintSettings = (settings) => {
|
|
520
|
-
return settings;
|
|
521
|
-
};
|
|
522
|
-
/**
|
|
523
|
-
* Decodes and validates ESLint settings, using defaults if invalid
|
|
524
|
-
* @param settings The settings object to decode
|
|
525
|
-
*/
|
|
526
499
|
const decodeESLintSettings = (settings) => {
|
|
527
500
|
if (isESLintSettings(settings)) return settings;
|
|
528
501
|
return DEFAULT_ESLINT_SETTINGS;
|
|
529
502
|
};
|
|
530
|
-
/**
|
|
531
|
-
* Coerces unknown input to ESLintReactSettings type
|
|
532
|
-
* @param settings The settings object to coerce
|
|
533
|
-
*/
|
|
534
|
-
const coerceSettings = (settings) => {
|
|
535
|
-
return settings;
|
|
536
|
-
};
|
|
537
|
-
/**
|
|
538
|
-
* Decodes and validates ESLint React settings, using defaults if invalid
|
|
539
|
-
* @param settings The settings object to decode
|
|
540
|
-
*/
|
|
541
503
|
const decodeSettings = (settings) => {
|
|
542
504
|
if (isESLintReactSettings(settings)) return settings;
|
|
543
505
|
return DEFAULT_ESLINT_REACT_SETTINGS;
|
|
544
506
|
};
|
|
545
|
-
/**
|
|
546
|
-
* Normalizes ESLint React settings to a consistent internal format
|
|
547
|
-
* Transforms component definitions and resolves version information
|
|
548
|
-
*/
|
|
549
507
|
const normalizeSettings = ({ importSource = "react", compilationMode, polymorphicPropName = "as", version, additionalStateHooks, additionalEffectHooks, ...rest }) => {
|
|
550
508
|
return {
|
|
551
509
|
...rest,
|
|
@@ -558,20 +516,10 @@ const normalizeSettings = ({ importSource = "react", compilationMode, polymorphi
|
|
|
558
516
|
};
|
|
559
517
|
};
|
|
560
518
|
const cache = /* @__PURE__ */ new Map();
|
|
561
|
-
/**
|
|
562
|
-
* Retrieves normalized ESLint React settings from the rule context
|
|
563
|
-
* Uses caching for performance optimization
|
|
564
|
-
* @param context The ESLint rule context
|
|
565
|
-
*/
|
|
566
519
|
function getSettingsFromContext(context) {
|
|
567
520
|
const settings = context.settings;
|
|
568
521
|
return getOrElseUpdate(cache, settings["react-x"], () => normalizeSettings(decodeSettings(settings["react-x"])));
|
|
569
522
|
}
|
|
570
|
-
/**
|
|
571
|
-
* Helper function for defining typed settings for "react-x" in JavaScript files
|
|
572
|
-
* Provides type checking without runtime transformation
|
|
573
|
-
*/
|
|
574
|
-
const defineSettings = identity;
|
|
575
523
|
|
|
576
524
|
//#endregion
|
|
577
|
-
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,
|
|
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.58",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -33,7 +33,7 @@
|
|
|
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.
|
|
36
|
+
"@eslint-react/eff": "3.0.0-next.58"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@tsconfig/node24": "^24.0.4",
|