@eslint-react/shared 1.24.0-beta.1 → 1.24.0-beta.18
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.mts +304 -308
- package/dist/index.d.ts +304 -308
- package/dist/index.js +101 -105
- package/dist/index.mjs +98 -102
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -221,6 +221,10 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
221
221
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
222
222
|
};
|
|
223
223
|
var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
224
|
+
|
|
225
|
+
// src/get-id.ts
|
|
226
|
+
var id = 0n;
|
|
227
|
+
var getId = () => (id++).toString();
|
|
224
228
|
var _require = module__default.default.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
225
229
|
function getReactVersion(fallback = "19.0.0") {
|
|
226
230
|
try {
|
|
@@ -230,7 +234,7 @@ function getReactVersion(fallback = "19.0.0") {
|
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
|
|
233
|
-
// ../../node_modules/.pnpm/valibot@1.0.0-beta.
|
|
237
|
+
// ../../node_modules/.pnpm/valibot@1.0.0-beta.12_typescript@5.7.3/node_modules/valibot/dist/index.js
|
|
234
238
|
var store;
|
|
235
239
|
// @__NO_SIDE_EFFECTS__
|
|
236
240
|
function getGlobalConfig(config2) {
|
|
@@ -417,29 +421,6 @@ function boolean(message) {
|
|
|
417
421
|
};
|
|
418
422
|
}
|
|
419
423
|
// @__NO_SIDE_EFFECTS__
|
|
420
|
-
function instance(class_, message) {
|
|
421
|
-
return {
|
|
422
|
-
kind: "schema",
|
|
423
|
-
type: "instance",
|
|
424
|
-
reference: instance,
|
|
425
|
-
expects: class_.name,
|
|
426
|
-
async: false,
|
|
427
|
-
class: class_,
|
|
428
|
-
message,
|
|
429
|
-
get "~standard"() {
|
|
430
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
431
|
-
},
|
|
432
|
-
"~run"(dataset, config2) {
|
|
433
|
-
if (dataset.value instanceof this.class) {
|
|
434
|
-
dataset.typed = true;
|
|
435
|
-
} else {
|
|
436
|
-
_addIssue(this, "type", dataset, config2);
|
|
437
|
-
}
|
|
438
|
-
return dataset;
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
// @__NO_SIDE_EFFECTS__
|
|
443
424
|
function object(entries, message) {
|
|
444
425
|
return {
|
|
445
426
|
kind: "schema",
|
|
@@ -547,7 +528,6 @@ function string(message) {
|
|
|
547
528
|
}
|
|
548
529
|
};
|
|
549
530
|
}
|
|
550
|
-
// @__NO_SIDE_EFFECTS__
|
|
551
531
|
function parse(schema, input, config2) {
|
|
552
532
|
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
553
533
|
if (dataset.issues) {
|
|
@@ -557,30 +537,27 @@ function parse(schema, input, config2) {
|
|
|
557
537
|
}
|
|
558
538
|
|
|
559
539
|
// src/schemas.ts
|
|
560
|
-
var
|
|
561
|
-
// TODO: Define the schema for custom Hooks
|
|
562
|
-
});
|
|
563
|
-
var CustomAttributeSchema = object({
|
|
540
|
+
var CustomComponentPropSchema = object({
|
|
564
541
|
/**
|
|
565
|
-
* The name of the
|
|
542
|
+
* The name of the prop in the user-defined component.
|
|
566
543
|
* @example
|
|
567
544
|
* "to"
|
|
568
545
|
*/
|
|
569
546
|
name: string(),
|
|
570
547
|
/**
|
|
571
|
-
* The name of the
|
|
548
|
+
* The name of the prop in the built-in component.
|
|
572
549
|
* @example
|
|
573
550
|
* "href"
|
|
574
551
|
*/
|
|
575
552
|
as: optional(string()),
|
|
576
553
|
/**
|
|
577
|
-
* Whether the
|
|
554
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
578
555
|
* @example
|
|
579
556
|
* `true`
|
|
580
557
|
*/
|
|
581
558
|
controlled: optional(boolean()),
|
|
582
559
|
/**
|
|
583
|
-
* The default value of the
|
|
560
|
+
* The default value of the prop in the user-defined component.
|
|
584
561
|
* @example
|
|
585
562
|
* `"/"`
|
|
586
563
|
*/
|
|
@@ -593,12 +570,6 @@ var CustomComponentSchema = object({
|
|
|
593
570
|
* "Link"
|
|
594
571
|
*/
|
|
595
572
|
name: string(),
|
|
596
|
-
/**
|
|
597
|
-
* The ESQuery selector to select the component precisely.
|
|
598
|
-
* @example
|
|
599
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
600
|
-
*/
|
|
601
|
-
selector: optional(string()),
|
|
602
573
|
/**
|
|
603
574
|
* The name of the built-in component that the user-defined component represents.
|
|
604
575
|
* @example
|
|
@@ -606,19 +577,40 @@ var CustomComponentSchema = object({
|
|
|
606
577
|
*/
|
|
607
578
|
as: optional(string()),
|
|
608
579
|
/**
|
|
609
|
-
*
|
|
580
|
+
* Attributes mapping between the user-defined component and the built-in component.
|
|
610
581
|
* @example
|
|
611
582
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
612
583
|
*/
|
|
613
|
-
attributes: optional(array(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
584
|
+
attributes: optional(array(CustomComponentPropSchema)),
|
|
585
|
+
/**
|
|
586
|
+
* The ESQuery selector to select the component precisely.
|
|
587
|
+
* @internal
|
|
588
|
+
* @example
|
|
589
|
+
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
590
|
+
*/
|
|
620
591
|
selector: optional(string())
|
|
621
592
|
});
|
|
593
|
+
var CustomHooksSchema = object({
|
|
594
|
+
use: optional(array(string())),
|
|
595
|
+
useActionState: optional(array(string())),
|
|
596
|
+
useCallback: optional(array(string())),
|
|
597
|
+
useContext: optional(array(string())),
|
|
598
|
+
useDebugValue: optional(array(string())),
|
|
599
|
+
useDeferredValue: optional(array(string())),
|
|
600
|
+
useEffect: optional(array(string())),
|
|
601
|
+
useFormStatus: optional(array(string())),
|
|
602
|
+
useId: optional(array(string())),
|
|
603
|
+
useImperativeHandle: optional(array(string())),
|
|
604
|
+
useInsertionEffect: optional(array(string())),
|
|
605
|
+
useLayoutEffect: optional(array(string())),
|
|
606
|
+
useMemo: optional(array(string())),
|
|
607
|
+
useOptimistic: optional(array(string())),
|
|
608
|
+
useReducer: optional(array(string())),
|
|
609
|
+
useRef: optional(array(string())),
|
|
610
|
+
useState: optional(array(string())),
|
|
611
|
+
useSyncExternalStore: optional(array(string())),
|
|
612
|
+
useTransition: optional(array(string()))
|
|
613
|
+
});
|
|
622
614
|
var ESLintReactSettingsSchema = object({
|
|
623
615
|
/**
|
|
624
616
|
* The source where React is imported from.
|
|
@@ -649,11 +641,11 @@ var ESLintReactSettingsSchema = object({
|
|
|
649
641
|
/**
|
|
650
642
|
* @internal
|
|
651
643
|
*/
|
|
652
|
-
strict: optional(boolean()),
|
|
644
|
+
strict: optional(boolean(), false),
|
|
653
645
|
/**
|
|
654
646
|
* @internal
|
|
655
647
|
*/
|
|
656
|
-
strictImportCheck: optional(boolean()),
|
|
648
|
+
strictImportCheck: optional(boolean(), false),
|
|
657
649
|
/**
|
|
658
650
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
659
651
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
@@ -661,38 +653,18 @@ var ESLintReactSettingsSchema = object({
|
|
|
661
653
|
* @default `"detect"`
|
|
662
654
|
*/
|
|
663
655
|
version: optional(string()),
|
|
656
|
+
/**
|
|
657
|
+
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
658
|
+
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
659
|
+
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
660
|
+
*/
|
|
661
|
+
additionalHooks: optional(CustomHooksSchema),
|
|
664
662
|
/**
|
|
665
663
|
* An array of user-defined components
|
|
666
664
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
667
665
|
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
668
666
|
*/
|
|
669
|
-
additionalComponents: optional(array(CustomComponentSchema))
|
|
670
|
-
/**
|
|
671
|
-
* A object of aliases for React built-in hooks.
|
|
672
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
673
|
-
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
674
|
-
*/
|
|
675
|
-
additionalHooks: optional(object({
|
|
676
|
-
use: optional(array(string())),
|
|
677
|
-
useActionState: optional(array(string())),
|
|
678
|
-
useCallback: optional(array(string())),
|
|
679
|
-
useContext: optional(array(string())),
|
|
680
|
-
useDebugValue: optional(array(string())),
|
|
681
|
-
useDeferredValue: optional(array(string())),
|
|
682
|
-
useEffect: optional(array(string())),
|
|
683
|
-
useFormStatus: optional(array(string())),
|
|
684
|
-
useId: optional(array(string())),
|
|
685
|
-
useImperativeHandle: optional(array(string())),
|
|
686
|
-
useInsertionEffect: optional(array(string())),
|
|
687
|
-
useLayoutEffect: optional(array(string())),
|
|
688
|
-
useMemo: optional(array(string())),
|
|
689
|
-
useOptimistic: optional(array(string())),
|
|
690
|
-
useReducer: optional(array(string())),
|
|
691
|
-
useRef: optional(array(string())),
|
|
692
|
-
useState: optional(array(string())),
|
|
693
|
-
useSyncExternalStore: optional(array(string())),
|
|
694
|
-
useTransition: optional(array(string()))
|
|
695
|
-
}))
|
|
667
|
+
additionalComponents: optional(array(CustomComponentSchema))
|
|
696
668
|
});
|
|
697
669
|
var ESLintSettingsSchema = optional(
|
|
698
670
|
object({
|
|
@@ -702,6 +674,19 @@ var ESLintSettingsSchema = optional(
|
|
|
702
674
|
}),
|
|
703
675
|
{}
|
|
704
676
|
);
|
|
677
|
+
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
678
|
+
...parse(ESLintReactSettingsSchema, {}),
|
|
679
|
+
importSource: "react",
|
|
680
|
+
jsxPragma: "createElement",
|
|
681
|
+
jsxPragmaFrag: "Fragment",
|
|
682
|
+
polymorphicPropName: "as",
|
|
683
|
+
strict: false,
|
|
684
|
+
strictImportCheck: false,
|
|
685
|
+
version: "detect",
|
|
686
|
+
additionalHooks: {
|
|
687
|
+
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
688
|
+
}
|
|
689
|
+
};
|
|
705
690
|
|
|
706
691
|
// ../../node_modules/.pnpm/fast-equals@5.2.2/node_modules/fast-equals/dist/esm/index.mjs
|
|
707
692
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
@@ -1396,14 +1381,6 @@ function createMemoizedFunction(fn, options) {
|
|
|
1396
1381
|
memoized.options = normalizedOptions;
|
|
1397
1382
|
return memoized;
|
|
1398
1383
|
}
|
|
1399
|
-
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
1400
|
-
additionalHooks: {
|
|
1401
|
-
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
1402
|
-
},
|
|
1403
|
-
polymorphicPropName: "as",
|
|
1404
|
-
strictImportCheck: false,
|
|
1405
|
-
version: "detect"
|
|
1406
|
-
};
|
|
1407
1384
|
function unsafeDecodeSettings(data) {
|
|
1408
1385
|
return data?.["react-x"] ?? {};
|
|
1409
1386
|
}
|
|
@@ -1413,31 +1390,49 @@ var decodeSettings = createMemoizedFunction((data) => {
|
|
|
1413
1390
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1414
1391
|
};
|
|
1415
1392
|
}, { isEqual: (a, b) => a === b });
|
|
1416
|
-
var
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1393
|
+
var toNormalizedSettings = createMemoizedFunction(
|
|
1394
|
+
({
|
|
1395
|
+
additionalComponents = [],
|
|
1396
|
+
additionalHooks = {},
|
|
1397
|
+
importSource = "react",
|
|
1398
|
+
polymorphicPropName = "as",
|
|
1399
|
+
version,
|
|
1400
|
+
...rest
|
|
1401
|
+
}) => {
|
|
1402
|
+
return {
|
|
1403
|
+
...rest,
|
|
1404
|
+
additionalComponents: additionalComponents.map(({
|
|
1405
|
+
name,
|
|
1406
|
+
as = name,
|
|
1407
|
+
attributes = [],
|
|
1408
|
+
...rest2
|
|
1409
|
+
}) => ({
|
|
1410
|
+
...rest2,
|
|
1411
|
+
name,
|
|
1412
|
+
as,
|
|
1413
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
1414
|
+
...rest3,
|
|
1415
|
+
name: name2,
|
|
1416
|
+
as: as2
|
|
1417
|
+
})),
|
|
1418
|
+
re: pm__default.default.makeRe(name, { fastpaths: true })
|
|
1419
|
+
})),
|
|
1420
|
+
additionalHooks,
|
|
1421
|
+
importSource,
|
|
1422
|
+
polymorphicPropName,
|
|
1423
|
+
version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(eff.identity)
|
|
1424
|
+
};
|
|
1425
|
+
},
|
|
1426
|
+
{ isEqual: shallowEqual }
|
|
1427
|
+
);
|
|
1432
1428
|
function getSettingsFromContext(context) {
|
|
1433
|
-
return
|
|
1429
|
+
return toNormalizedSettings(decodeSettings(context.settings));
|
|
1434
1430
|
}
|
|
1435
1431
|
var defineSettings = eff.identity;
|
|
1436
1432
|
|
|
1437
|
-
exports.
|
|
1438
|
-
exports.CustomComponentNormalizedSchema = CustomComponentNormalizedSchema;
|
|
1433
|
+
exports.CustomComponentPropSchema = CustomComponentPropSchema;
|
|
1439
1434
|
exports.CustomComponentSchema = CustomComponentSchema;
|
|
1440
|
-
exports.
|
|
1435
|
+
exports.CustomHooksSchema = CustomHooksSchema;
|
|
1441
1436
|
exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
|
|
1442
1437
|
exports.DOM_HTML_COMPONENT_TYPES = DOM_HTML_COMPONENT_TYPES;
|
|
1443
1438
|
exports.DOM_SVG_COMPONENT_TYPES = DOM_SVG_COMPONENT_TYPES;
|
|
@@ -1456,7 +1451,8 @@ exports.WEBSITE_URL = WEBSITE_URL;
|
|
|
1456
1451
|
exports.createRuleForPlugin = createRuleForPlugin;
|
|
1457
1452
|
exports.decodeSettings = decodeSettings;
|
|
1458
1453
|
exports.defineSettings = defineSettings;
|
|
1454
|
+
exports.getId = getId;
|
|
1459
1455
|
exports.getReactVersion = getReactVersion;
|
|
1460
1456
|
exports.getSettingsFromContext = getSettingsFromContext;
|
|
1461
|
-
exports.
|
|
1457
|
+
exports.toNormalizedSettings = toNormalizedSettings;
|
|
1462
1458
|
exports.unsafeDecodeSettings = unsafeDecodeSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -213,6 +213,10 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
213
213
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
214
214
|
};
|
|
215
215
|
var createRuleForPlugin = (pluginName) => ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
216
|
+
|
|
217
|
+
// src/get-id.ts
|
|
218
|
+
var id = 0n;
|
|
219
|
+
var getId = () => (id++).toString();
|
|
216
220
|
var _require = module.createRequire(import.meta.url);
|
|
217
221
|
function getReactVersion(fallback = "19.0.0") {
|
|
218
222
|
try {
|
|
@@ -222,7 +226,7 @@ function getReactVersion(fallback = "19.0.0") {
|
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
|
|
225
|
-
// ../../node_modules/.pnpm/valibot@1.0.0-beta.
|
|
229
|
+
// ../../node_modules/.pnpm/valibot@1.0.0-beta.12_typescript@5.7.3/node_modules/valibot/dist/index.js
|
|
226
230
|
var store;
|
|
227
231
|
// @__NO_SIDE_EFFECTS__
|
|
228
232
|
function getGlobalConfig(config2) {
|
|
@@ -409,29 +413,6 @@ function boolean(message) {
|
|
|
409
413
|
};
|
|
410
414
|
}
|
|
411
415
|
// @__NO_SIDE_EFFECTS__
|
|
412
|
-
function instance(class_, message) {
|
|
413
|
-
return {
|
|
414
|
-
kind: "schema",
|
|
415
|
-
type: "instance",
|
|
416
|
-
reference: instance,
|
|
417
|
-
expects: class_.name,
|
|
418
|
-
async: false,
|
|
419
|
-
class: class_,
|
|
420
|
-
message,
|
|
421
|
-
get "~standard"() {
|
|
422
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
423
|
-
},
|
|
424
|
-
"~run"(dataset, config2) {
|
|
425
|
-
if (dataset.value instanceof this.class) {
|
|
426
|
-
dataset.typed = true;
|
|
427
|
-
} else {
|
|
428
|
-
_addIssue(this, "type", dataset, config2);
|
|
429
|
-
}
|
|
430
|
-
return dataset;
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
// @__NO_SIDE_EFFECTS__
|
|
435
416
|
function object(entries, message) {
|
|
436
417
|
return {
|
|
437
418
|
kind: "schema",
|
|
@@ -539,7 +520,6 @@ function string(message) {
|
|
|
539
520
|
}
|
|
540
521
|
};
|
|
541
522
|
}
|
|
542
|
-
// @__NO_SIDE_EFFECTS__
|
|
543
523
|
function parse(schema, input, config2) {
|
|
544
524
|
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
545
525
|
if (dataset.issues) {
|
|
@@ -549,30 +529,27 @@ function parse(schema, input, config2) {
|
|
|
549
529
|
}
|
|
550
530
|
|
|
551
531
|
// src/schemas.ts
|
|
552
|
-
var
|
|
553
|
-
// TODO: Define the schema for custom Hooks
|
|
554
|
-
});
|
|
555
|
-
var CustomAttributeSchema = object({
|
|
532
|
+
var CustomComponentPropSchema = object({
|
|
556
533
|
/**
|
|
557
|
-
* The name of the
|
|
534
|
+
* The name of the prop in the user-defined component.
|
|
558
535
|
* @example
|
|
559
536
|
* "to"
|
|
560
537
|
*/
|
|
561
538
|
name: string(),
|
|
562
539
|
/**
|
|
563
|
-
* The name of the
|
|
540
|
+
* The name of the prop in the built-in component.
|
|
564
541
|
* @example
|
|
565
542
|
* "href"
|
|
566
543
|
*/
|
|
567
544
|
as: optional(string()),
|
|
568
545
|
/**
|
|
569
|
-
* Whether the
|
|
546
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
570
547
|
* @example
|
|
571
548
|
* `true`
|
|
572
549
|
*/
|
|
573
550
|
controlled: optional(boolean()),
|
|
574
551
|
/**
|
|
575
|
-
* The default value of the
|
|
552
|
+
* The default value of the prop in the user-defined component.
|
|
576
553
|
* @example
|
|
577
554
|
* `"/"`
|
|
578
555
|
*/
|
|
@@ -585,12 +562,6 @@ var CustomComponentSchema = object({
|
|
|
585
562
|
* "Link"
|
|
586
563
|
*/
|
|
587
564
|
name: string(),
|
|
588
|
-
/**
|
|
589
|
-
* The ESQuery selector to select the component precisely.
|
|
590
|
-
* @example
|
|
591
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
592
|
-
*/
|
|
593
|
-
selector: optional(string()),
|
|
594
565
|
/**
|
|
595
566
|
* The name of the built-in component that the user-defined component represents.
|
|
596
567
|
* @example
|
|
@@ -598,19 +569,40 @@ var CustomComponentSchema = object({
|
|
|
598
569
|
*/
|
|
599
570
|
as: optional(string()),
|
|
600
571
|
/**
|
|
601
|
-
*
|
|
572
|
+
* Attributes mapping between the user-defined component and the built-in component.
|
|
602
573
|
* @example
|
|
603
574
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
604
575
|
*/
|
|
605
|
-
attributes: optional(array(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
576
|
+
attributes: optional(array(CustomComponentPropSchema)),
|
|
577
|
+
/**
|
|
578
|
+
* The ESQuery selector to select the component precisely.
|
|
579
|
+
* @internal
|
|
580
|
+
* @example
|
|
581
|
+
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
582
|
+
*/
|
|
612
583
|
selector: optional(string())
|
|
613
584
|
});
|
|
585
|
+
var CustomHooksSchema = object({
|
|
586
|
+
use: optional(array(string())),
|
|
587
|
+
useActionState: optional(array(string())),
|
|
588
|
+
useCallback: optional(array(string())),
|
|
589
|
+
useContext: optional(array(string())),
|
|
590
|
+
useDebugValue: optional(array(string())),
|
|
591
|
+
useDeferredValue: optional(array(string())),
|
|
592
|
+
useEffect: optional(array(string())),
|
|
593
|
+
useFormStatus: optional(array(string())),
|
|
594
|
+
useId: optional(array(string())),
|
|
595
|
+
useImperativeHandle: optional(array(string())),
|
|
596
|
+
useInsertionEffect: optional(array(string())),
|
|
597
|
+
useLayoutEffect: optional(array(string())),
|
|
598
|
+
useMemo: optional(array(string())),
|
|
599
|
+
useOptimistic: optional(array(string())),
|
|
600
|
+
useReducer: optional(array(string())),
|
|
601
|
+
useRef: optional(array(string())),
|
|
602
|
+
useState: optional(array(string())),
|
|
603
|
+
useSyncExternalStore: optional(array(string())),
|
|
604
|
+
useTransition: optional(array(string()))
|
|
605
|
+
});
|
|
614
606
|
var ESLintReactSettingsSchema = object({
|
|
615
607
|
/**
|
|
616
608
|
* The source where React is imported from.
|
|
@@ -641,11 +633,11 @@ var ESLintReactSettingsSchema = object({
|
|
|
641
633
|
/**
|
|
642
634
|
* @internal
|
|
643
635
|
*/
|
|
644
|
-
strict: optional(boolean()),
|
|
636
|
+
strict: optional(boolean(), false),
|
|
645
637
|
/**
|
|
646
638
|
* @internal
|
|
647
639
|
*/
|
|
648
|
-
strictImportCheck: optional(boolean()),
|
|
640
|
+
strictImportCheck: optional(boolean(), false),
|
|
649
641
|
/**
|
|
650
642
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
651
643
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
@@ -653,38 +645,18 @@ var ESLintReactSettingsSchema = object({
|
|
|
653
645
|
* @default `"detect"`
|
|
654
646
|
*/
|
|
655
647
|
version: optional(string()),
|
|
648
|
+
/**
|
|
649
|
+
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
650
|
+
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
651
|
+
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
652
|
+
*/
|
|
653
|
+
additionalHooks: optional(CustomHooksSchema),
|
|
656
654
|
/**
|
|
657
655
|
* An array of user-defined components
|
|
658
656
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
659
657
|
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
660
658
|
*/
|
|
661
|
-
additionalComponents: optional(array(CustomComponentSchema))
|
|
662
|
-
/**
|
|
663
|
-
* A object of aliases for React built-in hooks.
|
|
664
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
665
|
-
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
666
|
-
*/
|
|
667
|
-
additionalHooks: optional(object({
|
|
668
|
-
use: optional(array(string())),
|
|
669
|
-
useActionState: optional(array(string())),
|
|
670
|
-
useCallback: optional(array(string())),
|
|
671
|
-
useContext: optional(array(string())),
|
|
672
|
-
useDebugValue: optional(array(string())),
|
|
673
|
-
useDeferredValue: optional(array(string())),
|
|
674
|
-
useEffect: optional(array(string())),
|
|
675
|
-
useFormStatus: optional(array(string())),
|
|
676
|
-
useId: optional(array(string())),
|
|
677
|
-
useImperativeHandle: optional(array(string())),
|
|
678
|
-
useInsertionEffect: optional(array(string())),
|
|
679
|
-
useLayoutEffect: optional(array(string())),
|
|
680
|
-
useMemo: optional(array(string())),
|
|
681
|
-
useOptimistic: optional(array(string())),
|
|
682
|
-
useReducer: optional(array(string())),
|
|
683
|
-
useRef: optional(array(string())),
|
|
684
|
-
useState: optional(array(string())),
|
|
685
|
-
useSyncExternalStore: optional(array(string())),
|
|
686
|
-
useTransition: optional(array(string()))
|
|
687
|
-
}))
|
|
659
|
+
additionalComponents: optional(array(CustomComponentSchema))
|
|
688
660
|
});
|
|
689
661
|
var ESLintSettingsSchema = optional(
|
|
690
662
|
object({
|
|
@@ -694,6 +666,19 @@ var ESLintSettingsSchema = optional(
|
|
|
694
666
|
}),
|
|
695
667
|
{}
|
|
696
668
|
);
|
|
669
|
+
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
670
|
+
...parse(ESLintReactSettingsSchema, {}),
|
|
671
|
+
importSource: "react",
|
|
672
|
+
jsxPragma: "createElement",
|
|
673
|
+
jsxPragmaFrag: "Fragment",
|
|
674
|
+
polymorphicPropName: "as",
|
|
675
|
+
strict: false,
|
|
676
|
+
strictImportCheck: false,
|
|
677
|
+
version: "detect",
|
|
678
|
+
additionalHooks: {
|
|
679
|
+
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
680
|
+
}
|
|
681
|
+
};
|
|
697
682
|
|
|
698
683
|
// ../../node_modules/.pnpm/fast-equals@5.2.2/node_modules/fast-equals/dist/esm/index.mjs
|
|
699
684
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
@@ -1388,14 +1373,6 @@ function createMemoizedFunction(fn, options) {
|
|
|
1388
1373
|
memoized.options = normalizedOptions;
|
|
1389
1374
|
return memoized;
|
|
1390
1375
|
}
|
|
1391
|
-
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
1392
|
-
additionalHooks: {
|
|
1393
|
-
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
1394
|
-
},
|
|
1395
|
-
polymorphicPropName: "as",
|
|
1396
|
-
strictImportCheck: false,
|
|
1397
|
-
version: "detect"
|
|
1398
|
-
};
|
|
1399
1376
|
function unsafeDecodeSettings(data) {
|
|
1400
1377
|
return data?.["react-x"] ?? {};
|
|
1401
1378
|
}
|
|
@@ -1405,25 +1382,44 @@ var decodeSettings = createMemoizedFunction((data) => {
|
|
|
1405
1382
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1406
1383
|
};
|
|
1407
1384
|
}, { isEqual: (a, b) => a === b });
|
|
1408
|
-
var
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1385
|
+
var toNormalizedSettings = createMemoizedFunction(
|
|
1386
|
+
({
|
|
1387
|
+
additionalComponents = [],
|
|
1388
|
+
additionalHooks = {},
|
|
1389
|
+
importSource = "react",
|
|
1390
|
+
polymorphicPropName = "as",
|
|
1391
|
+
version,
|
|
1392
|
+
...rest
|
|
1393
|
+
}) => {
|
|
1394
|
+
return {
|
|
1395
|
+
...rest,
|
|
1396
|
+
additionalComponents: additionalComponents.map(({
|
|
1397
|
+
name,
|
|
1398
|
+
as = name,
|
|
1399
|
+
attributes = [],
|
|
1400
|
+
...rest2
|
|
1401
|
+
}) => ({
|
|
1402
|
+
...rest2,
|
|
1403
|
+
name,
|
|
1404
|
+
as,
|
|
1405
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
1406
|
+
...rest3,
|
|
1407
|
+
name: name2,
|
|
1408
|
+
as: as2
|
|
1409
|
+
})),
|
|
1410
|
+
re: pm.makeRe(name, { fastpaths: true })
|
|
1411
|
+
})),
|
|
1412
|
+
additionalHooks,
|
|
1413
|
+
importSource,
|
|
1414
|
+
polymorphicPropName,
|
|
1415
|
+
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(identity)
|
|
1416
|
+
};
|
|
1417
|
+
},
|
|
1418
|
+
{ isEqual: shallowEqual }
|
|
1419
|
+
);
|
|
1424
1420
|
function getSettingsFromContext(context) {
|
|
1425
|
-
return
|
|
1421
|
+
return toNormalizedSettings(decodeSettings(context.settings));
|
|
1426
1422
|
}
|
|
1427
1423
|
var defineSettings = identity;
|
|
1428
1424
|
|
|
1429
|
-
export {
|
|
1425
|
+
export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DOM_HTML_COMPONENT_TYPES, DOM_SVG_COMPONENT_TYPES, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, defineSettings, getId, getReactVersion, getSettingsFromContext, toNormalizedSettings, unsafeDecodeSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.24.0-beta.
|
|
3
|
+
"version": "1.24.0-beta.18",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"./package.json"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@typescript-eslint/utils": "^8.
|
|
36
|
+
"@typescript-eslint/utils": "^8.20.0",
|
|
37
37
|
"picomatch": "^4.0.2",
|
|
38
|
-
"ts-pattern": "^5.6.
|
|
39
|
-
"@eslint-react/eff": "1.24.0-beta.
|
|
38
|
+
"ts-pattern": "^5.6.1",
|
|
39
|
+
"@eslint-react/eff": "1.24.0-beta.18"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/picomatch": "^3.0.
|
|
42
|
+
"@types/picomatch": "^3.0.2",
|
|
43
43
|
"fast-equals": "^5.2.2",
|
|
44
44
|
"micro-memoize": "^4.1.3",
|
|
45
45
|
"tsup": "^8.3.5",
|
|
46
46
|
"type-fest": "^4.32.0",
|
|
47
|
-
"valibot": "^1.0.0-beta.
|
|
47
|
+
"valibot": "^1.0.0-beta.12",
|
|
48
48
|
"@workspace/configs": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|