@eslint-react/shared 1.20.0 → 1.20.1-next.1
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +16 -2
- package/dist/index.mjs +14 -3
- package/package.json +4 -5
package/dist/index.d.mts
CHANGED
|
@@ -51,6 +51,8 @@ declare const REACT_BUILD_IN_HOOKS: readonly ["use", "useActionState", "useCallb
|
|
|
51
51
|
*/
|
|
52
52
|
declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
53
53
|
|
|
54
|
+
declare function getReactVersion(at?: string, fallback?: string): string;
|
|
55
|
+
|
|
54
56
|
/**
|
|
55
57
|
* Schema with pipe type.
|
|
56
58
|
*/
|
|
@@ -2195,4 +2197,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
2195
2197
|
}
|
|
2196
2198
|
}
|
|
2197
2199
|
|
|
2198
|
-
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, normalizeSettings, unsafeReadSettings };
|
|
2200
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, getReactVersion, normalizeSettings, unsafeReadSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ declare const REACT_BUILD_IN_HOOKS: readonly ["use", "useActionState", "useCallb
|
|
|
51
51
|
*/
|
|
52
52
|
declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
53
53
|
|
|
54
|
+
declare function getReactVersion(at?: string, fallback?: string): string;
|
|
55
|
+
|
|
54
56
|
/**
|
|
55
57
|
* Schema with pipe type.
|
|
56
58
|
*/
|
|
@@ -2195,4 +2197,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
2195
2197
|
}
|
|
2196
2198
|
}
|
|
2197
2199
|
|
|
2198
|
-
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, normalizeSettings, unsafeReadSettings };
|
|
2200
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, getReactVersion, normalizeSettings, unsafeReadSettings };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@typescript-eslint/utils');
|
|
4
|
+
var module$1 = require('module');
|
|
4
5
|
var tools = require('@eslint-react/tools');
|
|
5
|
-
var localPkg = require('local-pkg');
|
|
6
6
|
var pm = require('picomatch');
|
|
7
7
|
var tsPattern = require('ts-pattern');
|
|
8
8
|
|
|
9
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
|
|
12
|
+
var module__default = /*#__PURE__*/_interopDefault(module$1);
|
|
11
13
|
var pm__default = /*#__PURE__*/_interopDefault(pm);
|
|
12
14
|
|
|
13
15
|
// src/constants.ts
|
|
@@ -217,6 +219,17 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
217
219
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
218
220
|
};
|
|
219
221
|
var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
222
|
+
function getReactVersion(at = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)), fallback = "19.0.0") {
|
|
223
|
+
const _require = module__default.default.createRequire(at);
|
|
224
|
+
try {
|
|
225
|
+
const version = _require("react")?.version;
|
|
226
|
+
if (typeof version !== "string") throw new Error("Failed to read version from 'react' package");
|
|
227
|
+
return version;
|
|
228
|
+
} catch {
|
|
229
|
+
console.warn(`Failed to detect React version from dependencies. Using fallback: ${fallback}`);
|
|
230
|
+
return fallback;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
220
233
|
|
|
221
234
|
// ../../node_modules/.pnpm/valibot@1.0.0-beta.9_typescript@5.7.2/node_modules/valibot/dist/index.js
|
|
222
235
|
var store;
|
|
@@ -1361,7 +1374,7 @@ var normalizeSettings = createMemoizedFunction((settings) => {
|
|
|
1361
1374
|
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
1362
1375
|
return acc.set(name, as);
|
|
1363
1376
|
}, /* @__PURE__ */ new Map()),
|
|
1364
|
-
version: tsPattern.match(settings.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () =>
|
|
1377
|
+
version: tsPattern.match(settings.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion()).otherwise(tools.F.identity)
|
|
1365
1378
|
};
|
|
1366
1379
|
}, { isEqual: shallowEqual });
|
|
1367
1380
|
var defineSettings = tools.F.identity;
|
|
@@ -1388,5 +1401,6 @@ exports.WEBSITE_URL = WEBSITE_URL;
|
|
|
1388
1401
|
exports.createRuleForPlugin = createRuleForPlugin;
|
|
1389
1402
|
exports.decodeSettings = decodeSettings;
|
|
1390
1403
|
exports.defineSettings = defineSettings;
|
|
1404
|
+
exports.getReactVersion = getReactVersion;
|
|
1391
1405
|
exports.normalizeSettings = normalizeSettings;
|
|
1392
1406
|
exports.unsafeReadSettings = unsafeReadSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
import module from 'node:module';
|
|
2
3
|
import { F } from '@eslint-react/tools';
|
|
3
|
-
import { getPackageInfoSync } from 'local-pkg';
|
|
4
4
|
import pm from 'picomatch';
|
|
5
5
|
import { match, P } from 'ts-pattern';
|
|
6
6
|
|
|
@@ -211,6 +211,17 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
211
211
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
212
212
|
};
|
|
213
213
|
var createRuleForPlugin = (pluginName) => ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
214
|
+
function getReactVersion(at = import.meta.url, fallback = "19.0.0") {
|
|
215
|
+
const _require = module.createRequire(at);
|
|
216
|
+
try {
|
|
217
|
+
const version = _require("react")?.version;
|
|
218
|
+
if (typeof version !== "string") throw new Error("Failed to read version from 'react' package");
|
|
219
|
+
return version;
|
|
220
|
+
} catch {
|
|
221
|
+
console.warn(`Failed to detect React version from dependencies. Using fallback: ${fallback}`);
|
|
222
|
+
return fallback;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
214
225
|
|
|
215
226
|
// ../../node_modules/.pnpm/valibot@1.0.0-beta.9_typescript@5.7.2/node_modules/valibot/dist/index.js
|
|
216
227
|
var store;
|
|
@@ -1355,9 +1366,9 @@ var normalizeSettings = createMemoizedFunction((settings) => {
|
|
|
1355
1366
|
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
1356
1367
|
return acc.set(name, as);
|
|
1357
1368
|
}, /* @__PURE__ */ new Map()),
|
|
1358
|
-
version: match(settings.version).with(P.union(P.nullish, "", "detect"), () =>
|
|
1369
|
+
version: match(settings.version).with(P.union(P.nullish, "", "detect"), () => getReactVersion()).otherwise(F.identity)
|
|
1359
1370
|
};
|
|
1360
1371
|
}, { isEqual: shallowEqual });
|
|
1361
1372
|
var defineSettings = F.identity;
|
|
1362
1373
|
|
|
1363
|
-
export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, normalizeSettings, unsafeReadSettings };
|
|
1374
|
+
export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, getReactVersion, normalizeSettings, unsafeReadSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1-next.1",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,18 +35,17 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/utils": "^8.18.
|
|
39
|
-
"local-pkg": "^0.5.1",
|
|
38
|
+
"@typescript-eslint/utils": "^8.18.1",
|
|
40
39
|
"picomatch": "^4.0.2",
|
|
41
40
|
"ts-pattern": "^5.6.0",
|
|
42
|
-
"@eslint-react/tools": "1.20.
|
|
41
|
+
"@eslint-react/tools": "1.20.1-next.1"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@types/picomatch": "^3.0.1",
|
|
46
45
|
"fast-equals": "^5.0.1",
|
|
47
46
|
"micro-memoize": "^4.1.2",
|
|
48
47
|
"tsup": "^8.3.5",
|
|
49
|
-
"type-fest": "^4.30.
|
|
48
|
+
"type-fest": "^4.30.2",
|
|
50
49
|
"valibot": "^1.0.0-beta.9",
|
|
51
50
|
"@workspace/configs": "0.0.0"
|
|
52
51
|
},
|