@eslint-react/shared 2.6.5-next.0 → 2.7.0-beta.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.ts +12 -4
- package/dist/index.js +7 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -189,6 +189,12 @@ declare const RE_HOOK_NAME: RegExp;
|
|
|
189
189
|
declare function getReactVersion(fallback: string): string;
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region src/regexp.d.ts
|
|
192
|
+
/**
|
|
193
|
+
* A type represents RegExp-like object with `test` method.
|
|
194
|
+
*/
|
|
195
|
+
type RegExpLike = {
|
|
196
|
+
test: (s: string) => boolean;
|
|
197
|
+
};
|
|
192
198
|
/**
|
|
193
199
|
* Convert a string to the `RegExp`.
|
|
194
200
|
* Normal strings (e.g., `"foo"`) is converted to `/^foo$/` of `RegExp`.
|
|
@@ -197,9 +203,7 @@ declare function getReactVersion(fallback: string): string;
|
|
|
197
203
|
* @param string The string to convert.
|
|
198
204
|
* @returns Returns the `RegExp`.
|
|
199
205
|
*/
|
|
200
|
-
declare function toRegExp(string: string):
|
|
201
|
-
test(s: string): boolean;
|
|
202
|
-
};
|
|
206
|
+
declare function toRegExp(string: string | unit): RegExpLike;
|
|
203
207
|
/**
|
|
204
208
|
* Checks whether given string is regexp string
|
|
205
209
|
* @param string The string to check
|
|
@@ -219,6 +223,7 @@ declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
|
219
223
|
importSource: z.ZodOptional<z.ZodString>;
|
|
220
224
|
polymorphicPropName: z.ZodOptional<z.ZodString>;
|
|
221
225
|
version: z.ZodOptional<z.ZodString>;
|
|
226
|
+
additionalStateHooks: z.ZodOptional<z.ZodString>;
|
|
222
227
|
}, z.core.$strip>;
|
|
223
228
|
/**
|
|
224
229
|
* Schema for ESLint settings
|
|
@@ -233,6 +238,7 @@ type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
|
233
238
|
* Normalized ESLint React settings with processed values
|
|
234
239
|
*/
|
|
235
240
|
interface ESLintReactSettingsNormalized {
|
|
241
|
+
additionalStateHooks: RegExpLike;
|
|
236
242
|
importSource: string;
|
|
237
243
|
polymorphicPropName: string | unit;
|
|
238
244
|
version: string;
|
|
@@ -293,11 +299,13 @@ declare const normalizeSettings: ({
|
|
|
293
299
|
importSource,
|
|
294
300
|
polymorphicPropName,
|
|
295
301
|
version,
|
|
302
|
+
additionalStateHooks,
|
|
296
303
|
...rest
|
|
297
304
|
}: ESLintReactSettings) => {
|
|
298
305
|
readonly importSource: string;
|
|
299
306
|
readonly polymorphicPropName: string;
|
|
300
307
|
readonly version: string;
|
|
308
|
+
readonly additionalStateHooks: RegExpLike;
|
|
301
309
|
};
|
|
302
310
|
/**
|
|
303
311
|
* Retrieves normalized ESLint React settings from the rule context
|
|
@@ -316,4 +324,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
326
|
//#endregion
|
|
319
|
-
export { CompatibleConfig, CompatiblePlugin, CompatibleRule, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, 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, RuleConfig, RuleContext, RuleFeature, RulePolicy, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
|
|
327
|
+
export { CompatibleConfig, CompatiblePlugin, CompatibleRule, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, 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, RuleConfig, RuleContext, RuleFeature, RulePolicy, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import module from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { getOrElseUpdate, identity } from "@eslint-react/eff";
|
|
3
|
+
import { constFalse, getOrElseUpdate, identity } from "@eslint-react/eff";
|
|
4
4
|
import { P, match } from "ts-pattern";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
|
|
@@ -155,6 +155,7 @@ function getReactVersion(fallback) {
|
|
|
155
155
|
* @returns Returns the `RegExp`.
|
|
156
156
|
*/
|
|
157
157
|
function toRegExp(string) {
|
|
158
|
+
if (string == null) return { test: constFalse };
|
|
158
159
|
const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
|
|
159
160
|
if (pattern != null) return new RegExp(pattern, flags);
|
|
160
161
|
return { test: (s) => s === string };
|
|
@@ -186,7 +187,8 @@ function report(context) {
|
|
|
186
187
|
const ESLintReactSettingsSchema = z.object({
|
|
187
188
|
importSource: z.optional(z.string()),
|
|
188
189
|
polymorphicPropName: z.optional(z.string()),
|
|
189
|
-
version: z.optional(z.string())
|
|
190
|
+
version: z.optional(z.string()),
|
|
191
|
+
additionalStateHooks: z.optional(z.string())
|
|
190
192
|
});
|
|
191
193
|
/**
|
|
192
194
|
* Schema for ESLint settings
|
|
@@ -253,12 +255,13 @@ const decodeSettings = (settings) => {
|
|
|
253
255
|
* Normalizes ESLint React settings to a consistent internal format
|
|
254
256
|
* Transforms component definitions and resolves version information
|
|
255
257
|
*/
|
|
256
|
-
const normalizeSettings = ({ importSource = "react", polymorphicPropName = "as", version, ...rest }) => {
|
|
258
|
+
const normalizeSettings = ({ importSource = "react", polymorphicPropName = "as", version, additionalStateHooks, ...rest }) => {
|
|
257
259
|
return {
|
|
258
260
|
...rest,
|
|
259
261
|
importSource,
|
|
260
262
|
polymorphicPropName,
|
|
261
|
-
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.2.0")).otherwise(identity)
|
|
263
|
+
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.2.0")).otherwise(identity),
|
|
264
|
+
additionalStateHooks: toRegExp(additionalStateHooks)
|
|
262
265
|
};
|
|
263
266
|
};
|
|
264
267
|
const cache = /* @__PURE__ */ new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0-beta.0",
|
|
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": "^8.53.0",
|
|
34
34
|
"ts-pattern": "^5.9.0",
|
|
35
35
|
"zod": "^3.25.0 || ^4.0.0",
|
|
36
|
-
"@eslint-react/eff": "2.
|
|
36
|
+
"@eslint-react/eff": "2.7.0-beta.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@tsconfig/node22": "^22.0.5",
|