@eslint-react/shared
Advanced tools
Comparing version
@@ -6,2 +6,12 @@ import { unit } from '@eslint-react/eff'; | ||
/** | ||
* @internal | ||
*/ | ||
declare const getId: () => string; | ||
/** | ||
* @internal | ||
*/ | ||
declare const _require: NodeJS.Require; | ||
/** | ||
* The NPM scope for this project. | ||
@@ -27,4 +37,2 @@ */ | ||
declare const getId: () => string; | ||
declare function getReactVersion(fallback: string): string; | ||
@@ -769,4 +777,2 @@ | ||
importSource: z.ZodOptional<z.ZodString>; | ||
jsxPragma: z.ZodOptional<z.ZodString>; | ||
jsxPragmaFrag: z.ZodOptional<z.ZodString>; | ||
polymorphicPropName: z.ZodOptional<z.ZodString>; | ||
@@ -918,4 +924,2 @@ strict: z.ZodOptional<z.ZodBoolean>; | ||
readonly version: string; | ||
readonly jsxPragma?: string | undefined; | ||
readonly jsxPragmaFrag?: string | undefined; | ||
}; | ||
@@ -935,2 +939,2 @@ declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized; | ||
export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings }; | ||
export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings }; |
@@ -1,14 +0,13 @@ | ||
'use strict'; | ||
import module from 'module'; | ||
import path from 'path'; | ||
import { identity, getOrElseUpdate } from '@eslint-react/eff'; | ||
import { match, P } from 'ts-pattern'; | ||
import { RegExp } from '@eslint-react/kit'; | ||
import { z } from 'zod/v4'; | ||
var module$1 = require('module'); | ||
var eff = require('@eslint-react/eff'); | ||
var tsPattern = require('ts-pattern'); | ||
var kit = require('@eslint-react/kit'); | ||
var v4 = require('zod/v4'); | ||
// src/_id.ts | ||
var id = 0n; | ||
var getId = () => (id++).toString(); | ||
var _require = module.createRequire(process.cwd() + path.sep); | ||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; | ||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
var module__default = /*#__PURE__*/_interopDefault(module$1); | ||
// src/constants.ts | ||
@@ -26,10 +25,5 @@ var NPM_SCOPE = "@eslint-react"; | ||
}; | ||
// src/get-id.ts | ||
var id = 0n; | ||
var getId = () => (id++).toString(); | ||
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))); | ||
function getReactVersion(fallback) { | ||
try { | ||
return tsPattern.match(_require("react")).with({ version: tsPattern.P.select(tsPattern.P.string) }, eff.identity).otherwise(() => fallback); | ||
return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback); | ||
} catch { | ||
@@ -39,3 +33,3 @@ return fallback; | ||
} | ||
var CustomComponentPropSchema = v4.z.object({ | ||
var CustomComponentPropSchema = z.object({ | ||
/** | ||
@@ -46,3 +40,3 @@ * The name of the prop in the user-defined component. | ||
*/ | ||
name: v4.z.string(), | ||
name: z.string(), | ||
/** | ||
@@ -53,3 +47,3 @@ * The name of the prop in the host component. | ||
*/ | ||
as: v4.z.optional(v4.z.string()), | ||
as: z.optional(z.string()), | ||
/** | ||
@@ -61,3 +55,3 @@ * Whether the prop is controlled or not in the user-defined component. | ||
*/ | ||
controlled: v4.z.optional(v4.z.boolean()), | ||
controlled: z.optional(z.boolean()), | ||
/** | ||
@@ -68,5 +62,5 @@ * The default value of the prop in the user-defined component. | ||
*/ | ||
defaultValue: v4.z.optional(v4.z.string()) | ||
defaultValue: z.optional(z.string()) | ||
}); | ||
var CustomComponentSchema = v4.z.object({ | ||
var CustomComponentSchema = z.object({ | ||
/** | ||
@@ -77,3 +71,3 @@ * The name of the user-defined component. | ||
*/ | ||
name: v4.z.string(), | ||
name: z.string(), | ||
/** | ||
@@ -84,3 +78,3 @@ * The name of the host component that the user-defined component represents. | ||
*/ | ||
as: v4.z.optional(v4.z.string()), | ||
as: z.optional(z.string()), | ||
/** | ||
@@ -91,3 +85,3 @@ * Attributes mapping between the user-defined component and the host component. | ||
*/ | ||
attributes: v4.z.optional(v4.z.array(CustomComponentPropSchema)), | ||
attributes: z.optional(z.array(CustomComponentPropSchema)), | ||
/** | ||
@@ -99,26 +93,26 @@ * The ESQuery selector to select the component precisely. | ||
*/ | ||
selector: v4.z.optional(v4.z.string()) | ||
selector: z.optional(z.string()) | ||
}); | ||
var CustomHooksSchema = v4.z.object({ | ||
use: v4.z.optional(v4.z.array(v4.z.string())), | ||
useActionState: v4.z.optional(v4.z.array(v4.z.string())), | ||
useCallback: v4.z.optional(v4.z.array(v4.z.string())), | ||
useContext: v4.z.optional(v4.z.array(v4.z.string())), | ||
useDebugValue: v4.z.optional(v4.z.array(v4.z.string())), | ||
useDeferredValue: v4.z.optional(v4.z.array(v4.z.string())), | ||
useEffect: v4.z.optional(v4.z.array(v4.z.string())), | ||
useFormStatus: v4.z.optional(v4.z.array(v4.z.string())), | ||
useId: v4.z.optional(v4.z.array(v4.z.string())), | ||
useImperativeHandle: v4.z.optional(v4.z.array(v4.z.string())), | ||
useInsertionEffect: v4.z.optional(v4.z.array(v4.z.string())), | ||
useLayoutEffect: v4.z.optional(v4.z.array(v4.z.string())), | ||
useMemo: v4.z.optional(v4.z.array(v4.z.string())), | ||
useOptimistic: v4.z.optional(v4.z.array(v4.z.string())), | ||
useReducer: v4.z.optional(v4.z.array(v4.z.string())), | ||
useRef: v4.z.optional(v4.z.array(v4.z.string())), | ||
useState: v4.z.optional(v4.z.array(v4.z.string())), | ||
useSyncExternalStore: v4.z.optional(v4.z.array(v4.z.string())), | ||
useTransition: v4.z.optional(v4.z.array(v4.z.string())) | ||
var CustomHooksSchema = z.object({ | ||
use: z.optional(z.array(z.string())), | ||
useActionState: z.optional(z.array(z.string())), | ||
useCallback: z.optional(z.array(z.string())), | ||
useContext: z.optional(z.array(z.string())), | ||
useDebugValue: z.optional(z.array(z.string())), | ||
useDeferredValue: z.optional(z.array(z.string())), | ||
useEffect: z.optional(z.array(z.string())), | ||
useFormStatus: z.optional(z.array(z.string())), | ||
useId: z.optional(z.array(z.string())), | ||
useImperativeHandle: z.optional(z.array(z.string())), | ||
useInsertionEffect: z.optional(z.array(z.string())), | ||
useLayoutEffect: z.optional(z.array(z.string())), | ||
useMemo: z.optional(z.array(z.string())), | ||
useOptimistic: z.optional(z.array(z.string())), | ||
useReducer: z.optional(z.array(z.string())), | ||
useRef: z.optional(z.array(z.string())), | ||
useState: z.optional(z.array(z.string())), | ||
useSyncExternalStore: z.optional(z.array(z.string())), | ||
useTransition: z.optional(z.array(z.string())) | ||
}); | ||
var ESLintReactSettingsSchema = v4.z.object({ | ||
var ESLintReactSettingsSchema = z.object({ | ||
/** | ||
@@ -130,17 +124,4 @@ * The source where React is imported from. | ||
*/ | ||
importSource: v4.z.optional(v4.z.string()), | ||
importSource: z.optional(z.string()), | ||
/** | ||
* The identifier that's used for JSX Element creation. | ||
* @default `"createElement"` | ||
* @deprecated | ||
*/ | ||
jsxPragma: v4.z.optional(v4.z.string()), | ||
/** | ||
* The identifier that's used for JSX fragment elements. | ||
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment"). | ||
* @default `"Fragment"` | ||
* @deprecated | ||
*/ | ||
jsxPragmaFrag: v4.z.optional(v4.z.string()), | ||
/** | ||
* The name of the prop that is used for polymorphic components. | ||
@@ -150,3 +131,3 @@ * @description This is used to determine the type of the component. | ||
*/ | ||
polymorphicPropName: v4.z.optional(v4.z.string()), | ||
polymorphicPropName: z.optional(z.string()), | ||
/** | ||
@@ -156,3 +137,3 @@ * @default `true` | ||
*/ | ||
strict: v4.z.optional(v4.z.boolean()), | ||
strict: z.optional(z.boolean()), | ||
/** | ||
@@ -163,3 +144,3 @@ * Check both the shape and the import to determine if an API is from React. | ||
*/ | ||
skipImportCheck: v4.z.optional(v4.z.boolean()), | ||
skipImportCheck: z.optional(z.boolean()), | ||
/** | ||
@@ -171,3 +152,3 @@ * React version to use, "detect" means auto detect React version from the project's dependencies. | ||
*/ | ||
version: v4.z.optional(v4.z.string()), | ||
version: z.optional(z.string()), | ||
/** | ||
@@ -178,3 +159,3 @@ * A object to define additional hooks that are equivalent to the built-in React Hooks. | ||
*/ | ||
additionalHooks: v4.z.optional(CustomHooksSchema), | ||
additionalHooks: z.optional(CustomHooksSchema), | ||
/** | ||
@@ -185,7 +166,7 @@ * An array of user-defined components | ||
*/ | ||
additionalComponents: v4.z.optional(v4.z.array(CustomComponentSchema)) | ||
additionalComponents: z.optional(z.array(CustomComponentSchema)) | ||
}); | ||
var ESLintSettingsSchema = v4.z.optional( | ||
v4.z.object({ | ||
"react-x": v4.z.optional(v4.z.unknown()) | ||
var ESLintSettingsSchema = z.optional( | ||
z.object({ | ||
"react-x": z.optional(z.unknown()) | ||
}) | ||
@@ -246,3 +227,3 @@ ); | ||
const { name, as = name, attributes = [], ...rest2 } = component; | ||
const re = kit.RegExp.toRegExp(name); | ||
const re = RegExp.toRegExp(name); | ||
return { | ||
@@ -265,3 +246,3 @@ ...rest2, | ||
strict, | ||
version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(eff.identity) | ||
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(identity) | ||
}; | ||
@@ -272,3 +253,3 @@ }; | ||
const settings = context.settings; | ||
return eff.getOrElseUpdate( | ||
return getOrElseUpdate( | ||
cache, | ||
@@ -279,25 +260,4 @@ settings["react-x"], | ||
} | ||
var defineSettings = eff.identity; | ||
var defineSettings = identity; | ||
exports.CustomComponentPropSchema = CustomComponentPropSchema; | ||
exports.CustomComponentSchema = CustomComponentSchema; | ||
exports.CustomHooksSchema = CustomHooksSchema; | ||
exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS; | ||
exports.DEFAULT_ESLINT_SETTINGS = DEFAULT_ESLINT_SETTINGS; | ||
exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema; | ||
exports.ESLintSettingsSchema = ESLintSettingsSchema; | ||
exports.GITHUB_URL = GITHUB_URL; | ||
exports.NPM_SCOPE = NPM_SCOPE; | ||
exports.WEBSITE_URL = WEBSITE_URL; | ||
exports.coerceESLintSettings = coerceESLintSettings; | ||
exports.coerceSettings = coerceSettings; | ||
exports.decodeESLintSettings = decodeESLintSettings; | ||
exports.decodeSettings = decodeSettings; | ||
exports.defineSettings = defineSettings; | ||
exports.getDocsUrl = getDocsUrl; | ||
exports.getId = getId; | ||
exports.getReactVersion = getReactVersion; | ||
exports.getSettingsFromContext = getSettingsFromContext; | ||
exports.isESLintReactSettings = isESLintReactSettings; | ||
exports.isESLintSettings = isESLintSettings; | ||
exports.normalizeSettings = normalizeSettings; | ||
export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings }; |
{ | ||
"name": "@eslint-react/shared", | ||
"version": "1.52.3-next.6", | ||
"version": "2.0.0-beta.0", | ||
"description": "ESLint React's Shared constants and functions.", | ||
@@ -17,18 +17,10 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
@@ -39,7 +31,7 @@ "dist", | ||
"dependencies": { | ||
"@typescript-eslint/utils": "^8.34.1", | ||
"@typescript-eslint/utils": "^8.35.0", | ||
"ts-pattern": "^5.7.1", | ||
"zod": "^3.25.67", | ||
"@eslint-react/eff": "1.52.3-next.6", | ||
"@eslint-react/kit": "1.52.3-next.6" | ||
"@eslint-react/eff": "2.0.0-beta.0", | ||
"@eslint-react/kit": "2.0.0-beta.0" | ||
}, | ||
@@ -55,3 +47,3 @@ "devDependencies": { | ||
"bun": ">=1.0.15", | ||
"node": ">=18.18.0" | ||
"node": ">=20.19.0" | ||
}, | ||
@@ -58,0 +50,0 @@ "scripts": { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2
-50%Yes
NaN41722
-50.15%4
-33.33%1026
-21.74%+ Added
+ Added
- Removed
- Removed