@react-analyzer/shared 0.0.3-next.7 → 0.0.4-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.ts +98 -1
- package/dist/index.js +102 -2
- package/package.json +7 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { unit } from "@react-analyzer/eff";
|
|
2
|
+
import { ReportDescriptor } from "tsl";
|
|
3
|
+
|
|
1
4
|
//#region src/_id.d.ts
|
|
2
5
|
/**
|
|
3
6
|
* @internal
|
|
@@ -23,6 +26,75 @@ declare const GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
|
|
|
23
26
|
* The URL to the project's website.
|
|
24
27
|
*/
|
|
25
28
|
declare const WEBSITE_URL = "https://react-analyzer.xyz";
|
|
29
|
+
/**
|
|
30
|
+
* Regular expressions for matching a HTML tag name
|
|
31
|
+
*/
|
|
32
|
+
declare const RE_HTML_TAG: RegExp;
|
|
33
|
+
/**
|
|
34
|
+
* Regular expression for matching a TypeScript file extension.
|
|
35
|
+
*/
|
|
36
|
+
declare const RE_TS_EXT: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* Regular expression for matching a JavaScript file extension.
|
|
39
|
+
*/
|
|
40
|
+
declare const RE_JS_EXT: RegExp;
|
|
41
|
+
/**
|
|
42
|
+
* Regular expression for matching a PascalCase string.
|
|
43
|
+
*/
|
|
44
|
+
declare const RE_PASCAL_CASE: RegExp;
|
|
45
|
+
/**
|
|
46
|
+
* Regular expression for matching a camelCase string.
|
|
47
|
+
*/
|
|
48
|
+
declare const RE_CAMEL_CASE: RegExp;
|
|
49
|
+
/**
|
|
50
|
+
* Regular expression for matching a kebab-case string.
|
|
51
|
+
*/
|
|
52
|
+
declare const RE_KEBAB_CASE: RegExp;
|
|
53
|
+
/**
|
|
54
|
+
* Regular expression for matching a snake_case string.
|
|
55
|
+
*/
|
|
56
|
+
declare const RE_SNAKE_CASE: RegExp;
|
|
57
|
+
/**
|
|
58
|
+
* Regular expression for matching a CONSTANT_CASE string.
|
|
59
|
+
*/
|
|
60
|
+
declare const RE_CONSTANT_CASE: RegExp;
|
|
61
|
+
declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* Regular expression for matching a valid JavaScript identifier.
|
|
64
|
+
*/
|
|
65
|
+
declare const RE_JS_IDENTIFIER: RegExp;
|
|
66
|
+
/**
|
|
67
|
+
* Regular expression for matching a RegExp string.
|
|
68
|
+
*/
|
|
69
|
+
declare const RE_REGEXP_STR: RegExp;
|
|
70
|
+
/**
|
|
71
|
+
* Regular expression for matching a `@jsx` annotation comment.
|
|
72
|
+
*/
|
|
73
|
+
declare const RE_ANNOTATION_JSX: RegExp;
|
|
74
|
+
/**
|
|
75
|
+
* Regular expression for matching a `@jsxFrag` annotation comment.
|
|
76
|
+
*/
|
|
77
|
+
declare const RE_ANNOTATION_JSX_FRAG: RegExp;
|
|
78
|
+
/**
|
|
79
|
+
* Regular expression for matching a `@jsxRuntime` annotation comment.
|
|
80
|
+
*/
|
|
81
|
+
declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
|
|
82
|
+
/**
|
|
83
|
+
* Regular expression for matching a `@jsxImportSource` annotation comment.
|
|
84
|
+
*/
|
|
85
|
+
declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* Regular expression for matching a React component name.
|
|
88
|
+
*/
|
|
89
|
+
declare const RE_COMPONENT_NAME: RegExp;
|
|
90
|
+
/**
|
|
91
|
+
* Regular expression for matching a React component name (loose).
|
|
92
|
+
*/
|
|
93
|
+
declare const RE_COMPONENT_NAME_LOOSE: RegExp;
|
|
94
|
+
/**
|
|
95
|
+
* Regular expression for matching a React Hook name.
|
|
96
|
+
*/
|
|
97
|
+
declare const RE_HOOK_NAME: RegExp;
|
|
26
98
|
//#endregion
|
|
27
99
|
//#region src/get-analyzer-options.d.ts
|
|
28
100
|
interface AnalyzerOptions {
|
|
@@ -41,4 +113,29 @@ declare function getCommandLineOptions(): {
|
|
|
41
113
|
//#region src/get-react-version.d.ts
|
|
42
114
|
declare function getReactVersion(fallback: string): string;
|
|
43
115
|
//#endregion
|
|
44
|
-
|
|
116
|
+
//#region src/regexp.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* Convert a string to the `RegExp`.
|
|
119
|
+
* Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
|
|
120
|
+
* Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
|
|
121
|
+
* @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
|
|
122
|
+
* @param string The string to convert.
|
|
123
|
+
* @returns Returns the `RegExp`.
|
|
124
|
+
*/
|
|
125
|
+
declare function toRegExp(string: string): {
|
|
126
|
+
test(s: string): boolean;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Checks whether given string is regexp string
|
|
130
|
+
* @param string The string to check
|
|
131
|
+
* @returns boolean
|
|
132
|
+
*/
|
|
133
|
+
declare function isRegExp(string: string): boolean;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/report.d.ts
|
|
136
|
+
interface Context {
|
|
137
|
+
report(descriptor: ReportDescriptor): void;
|
|
138
|
+
}
|
|
139
|
+
declare function report(ctx: Context, descriptor: unit | null | ReportDescriptor): void;
|
|
140
|
+
//#endregion
|
|
141
|
+
export { AnalyzerOptions, DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, 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, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion, isRegExp, 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 { identity } from "@react-analyzer/eff";
|
|
3
|
+
import { identity, unit } from "@react-analyzer/eff";
|
|
4
4
|
import { getTsconfig } from "get-tsconfig";
|
|
5
5
|
import { P, match } from "ts-pattern";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
@@ -33,6 +33,75 @@ const GITHUB_URL = "https://github.com/react-analyzer/react-analyzer";
|
|
|
33
33
|
* The URL to the project's website.
|
|
34
34
|
*/
|
|
35
35
|
const WEBSITE_URL = "https://react-analyzer.xyz";
|
|
36
|
+
/**
|
|
37
|
+
* Regular expressions for matching a HTML tag name
|
|
38
|
+
*/
|
|
39
|
+
const RE_HTML_TAG = /^[a-z][^-]*$/u;
|
|
40
|
+
/**
|
|
41
|
+
* Regular expression for matching a TypeScript file extension.
|
|
42
|
+
*/
|
|
43
|
+
const RE_TS_EXT = /^[cm]?tsx?$/u;
|
|
44
|
+
/**
|
|
45
|
+
* Regular expression for matching a JavaScript file extension.
|
|
46
|
+
*/
|
|
47
|
+
const RE_JS_EXT = /^[cm]?jsx?$/u;
|
|
48
|
+
/**
|
|
49
|
+
* Regular expression for matching a PascalCase string.
|
|
50
|
+
*/
|
|
51
|
+
const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
|
|
52
|
+
/**
|
|
53
|
+
* Regular expression for matching a camelCase string.
|
|
54
|
+
*/
|
|
55
|
+
const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
|
|
56
|
+
/**
|
|
57
|
+
* Regular expression for matching a kebab-case string.
|
|
58
|
+
*/
|
|
59
|
+
const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
|
|
60
|
+
/**
|
|
61
|
+
* Regular expression for matching a snake_case string.
|
|
62
|
+
*/
|
|
63
|
+
const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
|
|
64
|
+
/**
|
|
65
|
+
* Regular expression for matching a CONSTANT_CASE string.
|
|
66
|
+
*/
|
|
67
|
+
const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
|
|
68
|
+
const RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
|
|
69
|
+
/**
|
|
70
|
+
* Regular expression for matching a valid JavaScript identifier.
|
|
71
|
+
*/
|
|
72
|
+
const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
|
|
73
|
+
/**
|
|
74
|
+
* Regular expression for matching a RegExp string.
|
|
75
|
+
*/
|
|
76
|
+
const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
|
|
77
|
+
/**
|
|
78
|
+
* Regular expression for matching a `@jsx` annotation comment.
|
|
79
|
+
*/
|
|
80
|
+
const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
|
|
81
|
+
/**
|
|
82
|
+
* Regular expression for matching a `@jsxFrag` annotation comment.
|
|
83
|
+
*/
|
|
84
|
+
const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
|
|
85
|
+
/**
|
|
86
|
+
* Regular expression for matching a `@jsxRuntime` annotation comment.
|
|
87
|
+
*/
|
|
88
|
+
const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
|
|
89
|
+
/**
|
|
90
|
+
* Regular expression for matching a `@jsxImportSource` annotation comment.
|
|
91
|
+
*/
|
|
92
|
+
const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
|
|
93
|
+
/**
|
|
94
|
+
* Regular expression for matching a React component name.
|
|
95
|
+
*/
|
|
96
|
+
const RE_COMPONENT_NAME = /^[A-Z]/u;
|
|
97
|
+
/**
|
|
98
|
+
* Regular expression for matching a React component name (loose).
|
|
99
|
+
*/
|
|
100
|
+
const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
|
|
101
|
+
/**
|
|
102
|
+
* Regular expression for matching a React Hook name.
|
|
103
|
+
*/
|
|
104
|
+
const RE_HOOK_NAME = /^use/u;
|
|
36
105
|
|
|
37
106
|
//#endregion
|
|
38
107
|
//#region src/get-command-line-options.ts
|
|
@@ -67,4 +136,35 @@ function getReactVersion(fallback) {
|
|
|
67
136
|
}
|
|
68
137
|
|
|
69
138
|
//#endregion
|
|
70
|
-
|
|
139
|
+
//#region src/regexp.ts
|
|
140
|
+
/**
|
|
141
|
+
* Convert a string to the `RegExp`.
|
|
142
|
+
* Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
|
|
143
|
+
* Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
|
|
144
|
+
* @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
|
|
145
|
+
* @param string The string to convert.
|
|
146
|
+
* @returns Returns the `RegExp`.
|
|
147
|
+
*/
|
|
148
|
+
function toRegExp(string) {
|
|
149
|
+
const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
|
|
150
|
+
if (pattern != null) return new RegExp(pattern, flags);
|
|
151
|
+
return { test: (s) => s === string };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Checks whether given string is regexp string
|
|
155
|
+
* @param string The string to check
|
|
156
|
+
* @returns boolean
|
|
157
|
+
*/
|
|
158
|
+
function isRegExp(string) {
|
|
159
|
+
return RE_REGEXP_STR.test(string);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/report.ts
|
|
164
|
+
function report(ctx, descriptor) {
|
|
165
|
+
if (descriptor == null) return;
|
|
166
|
+
return ctx.report(descriptor);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
export { DEFAULT_ANALYZER_OPTIONS, GITHUB_URL, 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, WEBSITE_URL, _require, getAnalyzerOptions, getCommandLineOptions, getId, getReactVersion, isRegExp, report, toRegExp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-analyzer/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-next.0",
|
|
4
4
|
"description": "React Analyzer Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/react-analyzer",
|
|
6
6
|
"bugs": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/shared"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"author": "Rel1cx<
|
|
15
|
+
"author": "Rel1cx<rel1cx@proton.me>",
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
@@ -27,16 +27,15 @@
|
|
|
27
27
|
"./package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"get-tsconfig": "^4.
|
|
30
|
+
"get-tsconfig": "^4.12.0",
|
|
31
31
|
"ts-pattern": "^5.8.0",
|
|
32
|
-
"@react-analyzer/eff": "0.0.
|
|
33
|
-
"@react-analyzer/kit": "0.0.3-next.7"
|
|
32
|
+
"@react-analyzer/eff": "0.0.4-next.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@tsconfig/node24": "^24.0.1",
|
|
37
|
-
"@types/node": "^24.
|
|
38
|
-
"tsdown": "^0.
|
|
39
|
-
"type-fest": "^
|
|
36
|
+
"@types/node": "^24.7.2",
|
|
37
|
+
"tsdown": "^0.15.6",
|
|
38
|
+
"type-fest": "^5.1.0",
|
|
40
39
|
"@local/configs": "0.0.0"
|
|
41
40
|
},
|
|
42
41
|
"engines": {
|