@eslint-react/shared 2.0.0-next.168 → 2.0.0-next.169
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 +1 -76
- package/dist/index.js +4 -41
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -61,31 +61,6 @@ declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
|
|
|
61
61
|
declare function getReactVersion(fallback: string): string;
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/settings.d.ts
|
|
64
|
-
/**
|
|
65
|
-
* Schema for component prop mapping between user-defined components and host components
|
|
66
|
-
*/
|
|
67
|
-
declare const CustomComponentPropSchema: z.ZodObject<{
|
|
68
|
-
name: z.ZodString;
|
|
69
|
-
as: z.ZodOptional<z.ZodString>;
|
|
70
|
-
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
-
defaultValue: z.ZodOptional<z.ZodString>;
|
|
72
|
-
}, z.core.$strip>;
|
|
73
|
-
/**
|
|
74
|
-
* Schema for custom components configuration
|
|
75
|
-
* Provides key information about user-defined components before validation
|
|
76
|
-
* Example: Which prop is used as the `href` prop in a custom `Link` component
|
|
77
|
-
*/
|
|
78
|
-
declare const CustomComponentSchema: z.ZodObject<{
|
|
79
|
-
name: z.ZodString;
|
|
80
|
-
as: z.ZodOptional<z.ZodString>;
|
|
81
|
-
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
82
|
-
name: z.ZodString;
|
|
83
|
-
as: z.ZodOptional<z.ZodString>;
|
|
84
|
-
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
-
defaultValue: z.ZodOptional<z.ZodString>;
|
|
86
|
-
}, z.core.$strip>>>;
|
|
87
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
88
|
-
}, z.core.$strip>;
|
|
89
64
|
/**
|
|
90
65
|
* Schema for custom hooks aliases that should be treated as React Hooks
|
|
91
66
|
*/
|
|
@@ -141,17 +116,6 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
141
116
|
useSyncExternalStore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
117
|
useTransition: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
143
118
|
}, z.core.$strip>>;
|
|
144
|
-
additionalComponents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
145
|
-
name: z.ZodString;
|
|
146
|
-
as: z.ZodOptional<z.ZodString>;
|
|
147
|
-
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
148
|
-
name: z.ZodString;
|
|
149
|
-
as: z.ZodOptional<z.ZodString>;
|
|
150
|
-
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
151
|
-
defaultValue: z.ZodOptional<z.ZodString>;
|
|
152
|
-
}, z.core.$strip>>>;
|
|
153
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
154
|
-
}, z.core.$strip>>>;
|
|
155
119
|
}, z.core.$strip>;
|
|
156
120
|
/**
|
|
157
121
|
* Schema for ESLint settings
|
|
@@ -160,36 +124,14 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
160
124
|
declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
|
|
161
125
|
"react-x": z.ZodOptional<z.ZodUnknown>;
|
|
162
126
|
}, z.core.$strip>>;
|
|
163
|
-
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
164
|
-
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
165
127
|
type CustomHooks = z.infer<typeof CustomHooksSchema>;
|
|
166
128
|
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
167
129
|
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
168
|
-
/**
|
|
169
|
-
* Normalized representation of a custom component prop
|
|
170
|
-
*/
|
|
171
|
-
interface CustomComponentPropNormalized {
|
|
172
|
-
name: string;
|
|
173
|
-
as: string;
|
|
174
|
-
defaultValue?: string | unit;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Normalized representation of a custom component with RegExp for matching
|
|
178
|
-
*/
|
|
179
|
-
interface CustomComponentNormalized {
|
|
180
|
-
name: string;
|
|
181
|
-
as: string;
|
|
182
|
-
attributes: CustomComponentPropNormalized[];
|
|
183
|
-
re: {
|
|
184
|
-
test(s: string): boolean;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
130
|
/**
|
|
188
131
|
* Normalized ESLint React settings with processed values
|
|
189
132
|
*/
|
|
190
133
|
interface ESLintReactSettingsNormalized {
|
|
191
134
|
additionalHooks: CustomHooks;
|
|
192
|
-
components: CustomComponentNormalized[];
|
|
193
135
|
importSource: string;
|
|
194
136
|
polymorphicPropName: string | unit;
|
|
195
137
|
skipImportCheck: boolean;
|
|
@@ -205,7 +147,6 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
|
205
147
|
readonly strict: true;
|
|
206
148
|
readonly skipImportCheck: true;
|
|
207
149
|
readonly polymorphicPropName: "as";
|
|
208
|
-
readonly additionalComponents: [];
|
|
209
150
|
readonly additionalHooks: {
|
|
210
151
|
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
211
152
|
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
@@ -221,7 +162,6 @@ declare const DEFAULT_ESLINT_SETTINGS: {
|
|
|
221
162
|
readonly strict: true;
|
|
222
163
|
readonly skipImportCheck: true;
|
|
223
164
|
readonly polymorphicPropName: "as";
|
|
224
|
-
readonly additionalComponents: [];
|
|
225
165
|
readonly additionalHooks: {
|
|
226
166
|
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
227
167
|
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
@@ -263,7 +203,6 @@ declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
|
263
203
|
* Transforms component definitions and resolves version information
|
|
264
204
|
*/
|
|
265
205
|
declare const normalizeSettings: ({
|
|
266
|
-
additionalComponents,
|
|
267
206
|
additionalHooks,
|
|
268
207
|
importSource,
|
|
269
208
|
polymorphicPropName,
|
|
@@ -272,20 +211,6 @@ declare const normalizeSettings: ({
|
|
|
272
211
|
version,
|
|
273
212
|
...rest
|
|
274
213
|
}: ESLintReactSettings) => {
|
|
275
|
-
readonly components: {
|
|
276
|
-
name: string;
|
|
277
|
-
re: {
|
|
278
|
-
test(s: string): boolean;
|
|
279
|
-
};
|
|
280
|
-
as: string;
|
|
281
|
-
attributes: {
|
|
282
|
-
name: string;
|
|
283
|
-
as: string;
|
|
284
|
-
controlled?: boolean | undefined;
|
|
285
|
-
defaultValue?: string | undefined;
|
|
286
|
-
}[];
|
|
287
|
-
selector?: string | undefined;
|
|
288
|
-
}[];
|
|
289
214
|
readonly additionalHooks: {
|
|
290
215
|
use?: string[] | undefined;
|
|
291
216
|
useActionState?: string[] | undefined;
|
|
@@ -330,4 +255,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
330
255
|
}
|
|
331
256
|
}
|
|
332
257
|
//#endregion
|
|
333
|
-
export {
|
|
258
|
+
export { CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import module from "node:module";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { getOrElseUpdate, identity } from "@eslint-react/eff";
|
|
4
4
|
import { P, match } from "ts-pattern";
|
|
5
|
-
import
|
|
5
|
+
import "@eslint-react/kit";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
7
|
|
|
8
8
|
//#region src/_id.ts
|
|
@@ -81,26 +81,6 @@ function getReactVersion(fallback) {
|
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/settings.ts
|
|
83
83
|
/**
|
|
84
|
-
* Schema for component prop mapping between user-defined components and host components
|
|
85
|
-
*/
|
|
86
|
-
const CustomComponentPropSchema = z.object({
|
|
87
|
-
name: z.string(),
|
|
88
|
-
as: z.optional(z.string()),
|
|
89
|
-
controlled: z.optional(z.boolean()),
|
|
90
|
-
defaultValue: z.optional(z.string())
|
|
91
|
-
});
|
|
92
|
-
/**
|
|
93
|
-
* Schema for custom components configuration
|
|
94
|
-
* Provides key information about user-defined components before validation
|
|
95
|
-
* Example: Which prop is used as the `href` prop in a custom `Link` component
|
|
96
|
-
*/
|
|
97
|
-
const CustomComponentSchema = z.object({
|
|
98
|
-
name: z.string(),
|
|
99
|
-
as: z.optional(z.string()),
|
|
100
|
-
attributes: z.optional(z.array(CustomComponentPropSchema)),
|
|
101
|
-
selector: z.optional(z.string())
|
|
102
|
-
});
|
|
103
|
-
/**
|
|
104
84
|
* Schema for custom hooks aliases that should be treated as React Hooks
|
|
105
85
|
*/
|
|
106
86
|
const CustomHooksSchema = z.object({
|
|
@@ -134,8 +114,7 @@ const ESLintReactSettingsSchema = z.object({
|
|
|
134
114
|
strict: z.optional(z.boolean()),
|
|
135
115
|
skipImportCheck: z.optional(z.boolean()),
|
|
136
116
|
version: z.optional(z.string()),
|
|
137
|
-
additionalHooks: z.optional(CustomHooksSchema)
|
|
138
|
-
additionalComponents: z.optional(z.array(CustomComponentSchema))
|
|
117
|
+
additionalHooks: z.optional(CustomHooksSchema)
|
|
139
118
|
});
|
|
140
119
|
/**
|
|
141
120
|
* Schema for ESLint settings
|
|
@@ -151,7 +130,6 @@ const DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
|
151
130
|
strict: true,
|
|
152
131
|
skipImportCheck: true,
|
|
153
132
|
polymorphicPropName: "as",
|
|
154
|
-
additionalComponents: [],
|
|
155
133
|
additionalHooks: {
|
|
156
134
|
useEffect: ["useIsomorphicLayoutEffect"],
|
|
157
135
|
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
@@ -209,24 +187,9 @@ const decodeSettings = (settings) => {
|
|
|
209
187
|
* Normalizes ESLint React settings to a consistent internal format
|
|
210
188
|
* Transforms component definitions and resolves version information
|
|
211
189
|
*/
|
|
212
|
-
const normalizeSettings = ({
|
|
190
|
+
const normalizeSettings = ({ additionalHooks = {}, importSource = "react", polymorphicPropName = "as", skipImportCheck = true, strict = true, version,...rest }) => {
|
|
213
191
|
return {
|
|
214
192
|
...rest,
|
|
215
|
-
components: additionalComponents.map((component) => {
|
|
216
|
-
const { name, as = name, attributes = [],...rest$1 } = component;
|
|
217
|
-
const re = RegExp.toRegExp(name);
|
|
218
|
-
return {
|
|
219
|
-
...rest$1,
|
|
220
|
-
name,
|
|
221
|
-
re,
|
|
222
|
-
as,
|
|
223
|
-
attributes: attributes.map(({ name: name$1, as: as$1 = name$1,...rest$2 }) => ({
|
|
224
|
-
...rest$2,
|
|
225
|
-
name: name$1,
|
|
226
|
-
as: as$1
|
|
227
|
-
}))
|
|
228
|
-
};
|
|
229
|
-
}),
|
|
230
193
|
additionalHooks,
|
|
231
194
|
importSource,
|
|
232
195
|
polymorphicPropName,
|
|
@@ -252,4 +215,4 @@ function getSettingsFromContext(context) {
|
|
|
252
215
|
const defineSettings = identity;
|
|
253
216
|
|
|
254
217
|
//#endregion
|
|
255
|
-
export {
|
|
218
|
+
export { CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.169",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@typescript-eslint/utils": "^8.42.0",
|
|
31
31
|
"ts-pattern": "^5.8.0",
|
|
32
32
|
"zod": "^4.1.5",
|
|
33
|
-
"@eslint-react/eff": "2.0.0-next.
|
|
34
|
-
"@eslint-react/kit": "2.0.0-next.
|
|
33
|
+
"@eslint-react/eff": "2.0.0-next.169",
|
|
34
|
+
"@eslint-react/kit": "2.0.0-next.169"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tsconfig/node22": "^22.0.2",
|