@eslint-react/shared 1.12.1-next.0 → 1.12.2-next.0
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 +299 -172
- package/dist/index.d.ts +299 -172
- package/dist/index.js +61 -41
- package/dist/index.mjs +59 -40
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -377,6 +377,25 @@ function boolean(message) {
|
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
+
function instance(class_, message) {
|
|
381
|
+
return {
|
|
382
|
+
kind: "schema",
|
|
383
|
+
type: "instance",
|
|
384
|
+
reference: instance,
|
|
385
|
+
expects: class_.name,
|
|
386
|
+
async: false,
|
|
387
|
+
class: class_,
|
|
388
|
+
message,
|
|
389
|
+
_run(dataset, config2) {
|
|
390
|
+
if (dataset.value instanceof this.class) {
|
|
391
|
+
dataset.typed = true;
|
|
392
|
+
} else {
|
|
393
|
+
_addIssue(this, "type", dataset, config2);
|
|
394
|
+
}
|
|
395
|
+
return dataset;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
380
399
|
function object(entries, message) {
|
|
381
400
|
return {
|
|
382
401
|
kind: "schema",
|
|
@@ -550,6 +569,13 @@ var CustomComponentSchema = object({
|
|
|
550
569
|
*/
|
|
551
570
|
attributes: optional(array(CustomAttributeSchema), [])
|
|
552
571
|
});
|
|
572
|
+
var CustomComponentNormalizedSchema = object({
|
|
573
|
+
name: string(),
|
|
574
|
+
as: optional(string()),
|
|
575
|
+
attributes: optional(array(CustomAttributeSchema), []),
|
|
576
|
+
re: instance(RegExp),
|
|
577
|
+
selector: optional(string())
|
|
578
|
+
});
|
|
553
579
|
var ESLintReactSettingsSchema = object({
|
|
554
580
|
/**
|
|
555
581
|
* The source where React is imported from.
|
|
@@ -625,10 +651,7 @@ var ESLintReactSettingsSchema = object({
|
|
|
625
651
|
var ESLintSettingsSchema = optional(
|
|
626
652
|
object({
|
|
627
653
|
"react-x": optional(ESLintReactSettingsSchema),
|
|
628
|
-
/**
|
|
629
|
-
* @internal
|
|
630
|
-
* @deprecated
|
|
631
|
-
*/
|
|
654
|
+
/** @deprecated Use `react-x` instead */
|
|
632
655
|
reactOptions: optional(ESLintReactSettingsSchema)
|
|
633
656
|
}),
|
|
634
657
|
{}
|
|
@@ -1284,52 +1307,48 @@ function createMemoizedFunction(fn, options) {
|
|
|
1284
1307
|
var INITIAL_ESLINT_REACT_SETTINGS = {
|
|
1285
1308
|
skipImportCheck: false
|
|
1286
1309
|
};
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
},
|
|
1291
|
-
polymorphicPropName: "as",
|
|
1292
|
-
skipImportCheck: false,
|
|
1293
|
-
version: "detect"
|
|
1294
|
-
};
|
|
1295
|
-
var defineSettings = tools.F.identity;
|
|
1310
|
+
function unsafeReadSettings(data) {
|
|
1311
|
+
return tools.Data.struct(data?.["react-x"] ?? {});
|
|
1312
|
+
}
|
|
1296
1313
|
var decodeSettings = createMemoizedFunction((data) => {
|
|
1297
1314
|
return tools.Data.struct({
|
|
1298
1315
|
...INITIAL_ESLINT_REACT_SETTINGS,
|
|
1299
1316
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1300
1317
|
});
|
|
1301
1318
|
}, { isEqual: (a, b) => a === b });
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
...component,
|
|
1312
|
-
attributes: component.attributes.map((attr) => ({
|
|
1313
|
-
...attr,
|
|
1314
|
-
as: attr.as ?? attr.name
|
|
1315
|
-
})),
|
|
1316
|
-
re: pm__default.default.makeRe(component.name, { fastpaths: true })
|
|
1319
|
+
var normalizeSettings = createMemoizedFunction((settings) => {
|
|
1320
|
+
const additionalComponents = settings.additionalComponents ?? [];
|
|
1321
|
+
return tools.Data.struct({
|
|
1322
|
+
...settings,
|
|
1323
|
+
additionalComponents: additionalComponents.map((component) => ({
|
|
1324
|
+
...component,
|
|
1325
|
+
attributes: component.attributes.map((attr) => ({
|
|
1326
|
+
...attr,
|
|
1327
|
+
as: attr.as ?? attr.name
|
|
1317
1328
|
})),
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
);
|
|
1329
|
+
re: pm__default.default.makeRe(component.name, { fastpaths: true })
|
|
1330
|
+
})),
|
|
1331
|
+
components: additionalComponents.reduce((acc, component) => {
|
|
1332
|
+
const { name, as, attributes, selector } = component;
|
|
1333
|
+
if (!name || !as || selector || attributes.length > 0) return acc;
|
|
1334
|
+
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
1335
|
+
return acc.set(name, as);
|
|
1336
|
+
}, /* @__PURE__ */ new Map())
|
|
1337
|
+
});
|
|
1338
|
+
}, { isEqual: shallowEqual });
|
|
1339
|
+
function findAttrInCustomAttributes(name, attributes) {
|
|
1340
|
+
return tools.F.pipe(
|
|
1341
|
+
tools.O.fromNullable(attributes.findLast((a) => a.as === name)),
|
|
1342
|
+
tools.O.map((a) => [a.name, a.defaultValue]),
|
|
1343
|
+
tools.O.getOrElse(() => [name])
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
var defineSettings = tools.F.identity;
|
|
1328
1347
|
|
|
1329
1348
|
exports.CustomAttributeSchema = CustomAttributeSchema;
|
|
1349
|
+
exports.CustomComponentNormalizedSchema = CustomComponentNormalizedSchema;
|
|
1330
1350
|
exports.CustomComponentSchema = CustomComponentSchema;
|
|
1331
1351
|
exports.CustomHookSchema = CustomHookSchema;
|
|
1332
|
-
exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
|
|
1333
1352
|
exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema;
|
|
1334
1353
|
exports.ESLintSettingsSchema = ESLintSettingsSchema;
|
|
1335
1354
|
exports.GITHUB_URL = GITHUB_URL;
|
|
@@ -1348,5 +1367,6 @@ exports.WEBSITE_URL = WEBSITE_URL;
|
|
|
1348
1367
|
exports.createRuleForPlugin = createRuleForPlugin;
|
|
1349
1368
|
exports.decodeSettings = decodeSettings;
|
|
1350
1369
|
exports.defineSettings = defineSettings;
|
|
1351
|
-
exports.
|
|
1352
|
-
exports.
|
|
1370
|
+
exports.findAttrInCustomAttributes = findAttrInCustomAttributes;
|
|
1371
|
+
exports.normalizeSettings = normalizeSettings;
|
|
1372
|
+
exports.unsafeReadSettings = unsafeReadSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import { F, Data } from '@eslint-react/tools';
|
|
2
|
+
import { F, Data, O } from '@eslint-react/tools';
|
|
3
3
|
import pm from 'picomatch';
|
|
4
4
|
|
|
5
5
|
// src/constants.ts
|
|
@@ -371,6 +371,25 @@ function boolean(message) {
|
|
|
371
371
|
}
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
+
function instance(class_, message) {
|
|
375
|
+
return {
|
|
376
|
+
kind: "schema",
|
|
377
|
+
type: "instance",
|
|
378
|
+
reference: instance,
|
|
379
|
+
expects: class_.name,
|
|
380
|
+
async: false,
|
|
381
|
+
class: class_,
|
|
382
|
+
message,
|
|
383
|
+
_run(dataset, config2) {
|
|
384
|
+
if (dataset.value instanceof this.class) {
|
|
385
|
+
dataset.typed = true;
|
|
386
|
+
} else {
|
|
387
|
+
_addIssue(this, "type", dataset, config2);
|
|
388
|
+
}
|
|
389
|
+
return dataset;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
374
393
|
function object(entries, message) {
|
|
375
394
|
return {
|
|
376
395
|
kind: "schema",
|
|
@@ -544,6 +563,13 @@ var CustomComponentSchema = object({
|
|
|
544
563
|
*/
|
|
545
564
|
attributes: optional(array(CustomAttributeSchema), [])
|
|
546
565
|
});
|
|
566
|
+
var CustomComponentNormalizedSchema = object({
|
|
567
|
+
name: string(),
|
|
568
|
+
as: optional(string()),
|
|
569
|
+
attributes: optional(array(CustomAttributeSchema), []),
|
|
570
|
+
re: instance(RegExp),
|
|
571
|
+
selector: optional(string())
|
|
572
|
+
});
|
|
547
573
|
var ESLintReactSettingsSchema = object({
|
|
548
574
|
/**
|
|
549
575
|
* The source where React is imported from.
|
|
@@ -619,10 +645,7 @@ var ESLintReactSettingsSchema = object({
|
|
|
619
645
|
var ESLintSettingsSchema = optional(
|
|
620
646
|
object({
|
|
621
647
|
"react-x": optional(ESLintReactSettingsSchema),
|
|
622
|
-
/**
|
|
623
|
-
* @internal
|
|
624
|
-
* @deprecated
|
|
625
|
-
*/
|
|
648
|
+
/** @deprecated Use `react-x` instead */
|
|
626
649
|
reactOptions: optional(ESLintReactSettingsSchema)
|
|
627
650
|
}),
|
|
628
651
|
{}
|
|
@@ -1278,46 +1301,42 @@ function createMemoizedFunction(fn, options) {
|
|
|
1278
1301
|
var INITIAL_ESLINT_REACT_SETTINGS = {
|
|
1279
1302
|
skipImportCheck: false
|
|
1280
1303
|
};
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
},
|
|
1285
|
-
polymorphicPropName: "as",
|
|
1286
|
-
skipImportCheck: false,
|
|
1287
|
-
version: "detect"
|
|
1288
|
-
};
|
|
1289
|
-
var defineSettings = F.identity;
|
|
1304
|
+
function unsafeReadSettings(data) {
|
|
1305
|
+
return Data.struct(data?.["react-x"] ?? {});
|
|
1306
|
+
}
|
|
1290
1307
|
var decodeSettings = createMemoizedFunction((data) => {
|
|
1291
1308
|
return Data.struct({
|
|
1292
1309
|
...INITIAL_ESLINT_REACT_SETTINGS,
|
|
1293
1310
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1294
1311
|
});
|
|
1295
1312
|
}, { isEqual: (a, b) => a === b });
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
...component,
|
|
1306
|
-
attributes: component.attributes.map((attr) => ({
|
|
1307
|
-
...attr,
|
|
1308
|
-
as: attr.as ?? attr.name
|
|
1309
|
-
})),
|
|
1310
|
-
re: pm.makeRe(component.name, { fastpaths: true })
|
|
1313
|
+
var normalizeSettings = createMemoizedFunction((settings) => {
|
|
1314
|
+
const additionalComponents = settings.additionalComponents ?? [];
|
|
1315
|
+
return Data.struct({
|
|
1316
|
+
...settings,
|
|
1317
|
+
additionalComponents: additionalComponents.map((component) => ({
|
|
1318
|
+
...component,
|
|
1319
|
+
attributes: component.attributes.map((attr) => ({
|
|
1320
|
+
...attr,
|
|
1321
|
+
as: attr.as ?? attr.name
|
|
1311
1322
|
})),
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
);
|
|
1323
|
+
re: pm.makeRe(component.name, { fastpaths: true })
|
|
1324
|
+
})),
|
|
1325
|
+
components: additionalComponents.reduce((acc, component) => {
|
|
1326
|
+
const { name, as, attributes, selector } = component;
|
|
1327
|
+
if (!name || !as || selector || attributes.length > 0) return acc;
|
|
1328
|
+
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
1329
|
+
return acc.set(name, as);
|
|
1330
|
+
}, /* @__PURE__ */ new Map())
|
|
1331
|
+
});
|
|
1332
|
+
}, { isEqual: shallowEqual });
|
|
1333
|
+
function findAttrInCustomAttributes(name, attributes) {
|
|
1334
|
+
return F.pipe(
|
|
1335
|
+
O.fromNullable(attributes.findLast((a) => a.as === name)),
|
|
1336
|
+
O.map((a) => [a.name, a.defaultValue]),
|
|
1337
|
+
O.getOrElse(() => [name])
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
var defineSettings = F.identity;
|
|
1322
1341
|
|
|
1323
|
-
export { CustomAttributeSchema, CustomComponentSchema, CustomHookSchema,
|
|
1342
|
+
export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, INITIAL_ESLINT_REACT_SETTINGS, 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, findAttrInCustomAttributes, normalizeSettings, unsafeReadSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2-next.0",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@typescript-eslint/utils": "^8.2.0",
|
|
39
39
|
"picomatch": "^4.0.2",
|
|
40
|
-
"@eslint-react/tools": "1.12.
|
|
40
|
+
"@eslint-react/tools": "1.12.2-next.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/picomatch": "^3.0.1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"micro-memoize": "^4.1.2",
|
|
46
46
|
"tsup": "^8.2.4",
|
|
47
47
|
"type-fest": "^4.25.0",
|
|
48
|
-
"valibot": "^0.
|
|
48
|
+
"valibot": "^0.39.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsup --dts-resolve",
|