@eslint-react/shared 5.0.0-next.0 → 5.0.1-beta.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.ts CHANGED
@@ -2,37 +2,25 @@ import { z } from "zod/v4";
2
2
  import * as tseslint from "@typescript-eslint/utils/ts-eslint";
3
3
  import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener, RuleListener as RuleListener$1 } from "@typescript-eslint/utils/ts-eslint";
4
4
 
5
- //#region src/_id.d.ts
6
- /**
7
- * A generator for unique ids.
8
- */
9
- declare class IdGenerator {
10
- private n;
11
- private prefix;
12
- /**
13
- * @param prefix Optional. A prefix of generated ids.
14
- */
15
- constructor(prefix?: string);
16
- /**
17
- * Generates an id.
18
- * @returns A generated id.
19
- */
20
- next(): string;
21
- }
22
- //#endregion
23
- //#region src/constants.d.ts
24
- /**
25
- * The NPM scope for this project.
26
- */
27
- declare const NPM_SCOPE = "@eslint-react";
28
- /**
29
- * The GitHub repository for this project.
30
- */
31
- declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
5
+ //#region src/define-rule-listener.d.ts
32
6
  /**
33
- * The URL to the project's website.
7
+ * Defines a rule listener by merging multiple visitor objects
8
+ *
9
+ * @param base Base visitor object (target of merge)
10
+ * @param rest Additional visitor objects to merge (one or more)
11
+ * @returns Merged RuleListener object
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const listener1 = { Identifier: () => console.log(1) };
16
+ * const listener2 = { Identifier: () => console.log(2) };
17
+ * const merged = defineRuleListener(listener1, listener2);
18
+ * // When encountering Identifier nodes, outputs 1 then 2
19
+ * ```
34
20
  */
35
- declare const WEBSITE_URL = "https://eslint-react.xyz";
21
+ declare function defineRuleListener(base: RuleListener$1, ...rest: RuleListener$1[]): RuleListener$1;
22
+ //#endregion
23
+ //#region src/regexp.d.ts
36
24
  /**
37
25
  * Regular expressions for matching a HTML tag name
38
26
  */
@@ -102,50 +90,6 @@ declare const RE_COMPONENT_NAME_LOOSE: RegExp;
102
90
  * Regular expression for matching a React Hook name.
103
91
  */
104
92
  declare const RE_HOOK_NAME: RegExp;
105
- /**
106
- * Known impure functions
107
- */
108
- declare const IMPURE_FUNCS: ReadonlyMap<string, ReadonlySet<string>>;
109
- /**
110
- * Known impure global constructors used with `new`
111
- */
112
- declare const IMPURE_CTORS: ReadonlySet<string>;
113
- /**
114
- * Known pure functions
115
- */
116
- declare const PURE_FUNCS: ReadonlyMap<string, ReadonlySet<string>>;
117
- /**
118
- Known pure global constructors used with `new`
119
- */
120
- declare const PURE_CTORS: ReadonlySet<string>;
121
- //#endregion
122
- //#region src/define-rule-listener.d.ts
123
- /**
124
- * Defines a rule listener by merging multiple visitor objects
125
- *
126
- * @param base Base visitor object (target of merge)
127
- * @param rest Additional visitor objects to merge (one or more)
128
- * @returns Merged RuleListener object
129
- *
130
- * @example
131
- * ```typescript
132
- * const listener1 = { Identifier: () => console.log(1) };
133
- * const listener2 = { Identifier: () => console.log(2) };
134
- * const merged = defineRuleListener(listener1, listener2);
135
- * // When encountering Identifier nodes, outputs 1 then 2
136
- * ```
137
- */
138
- declare function defineRuleListener(base: RuleListener$1, ...rest: RuleListener$1[]): RuleListener$1;
139
- //#endregion
140
- //#region src/react-version.d.ts
141
- /**
142
- * Gets the React version from the project's dependencies.
143
- * @param fallback The fallback version to return if React is not found.
144
- * @returns The detected React version or the fallback version.
145
- */
146
- declare function getReactVersion(fallback: string): string;
147
- //#endregion
148
- //#region src/regexp.d.ts
149
93
  /**
150
94
  * A type represents RegExp-like object with `test` method.
151
95
  */
@@ -290,6 +234,12 @@ declare const normalizeSettings: ({
290
234
  readonly additionalStateHooks: RegExpLike;
291
235
  readonly additionalEffectHooks: RegExpLike;
292
236
  };
237
+ /**
238
+ * Gets the React version from the project's dependencies.
239
+ * @param fallback The fallback version to return if React is not found.
240
+ * @returns The detected React version or the fallback version.
241
+ */
242
+ declare function getReactVersion(fallback: string): string;
293
243
  declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
294
244
  declare module "@typescript-eslint/utils/ts-eslint" {
295
245
  interface SharedConfigurationSettings {
@@ -297,4 +247,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
297
247
  }
298
248
  }
299
249
  //#endregion
300
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, IdGenerator, NPM_SCOPE, PURE_CTORS, PURE_FUNCS, 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, type ReportFixFunction, RuleConfig, RuleContext, RuleFeature, type RuleFix, type RuleFixer, type RuleListener, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
250
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, 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, type ReportFixFunction, RuleConfig, RuleContext, RuleFeature, type RuleFix, type RuleFixer, type RuleListener, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/dist/index.js CHANGED
@@ -3,558 +3,6 @@ import path from "node:path";
3
3
  import { P, match } from "ts-pattern";
4
4
  import { z } from "zod/v4";
5
5
 
6
- //#region src/_id.ts
7
- /**
8
- * A generator for unique ids.
9
- */
10
- var IdGenerator = class {
11
- n;
12
- prefix;
13
- /**
14
- * @param prefix Optional. A prefix of generated ids.
15
- */
16
- constructor(prefix = "id_") {
17
- this.prefix = prefix;
18
- this.n = 0n;
19
- }
20
- /**
21
- * Generates an id.
22
- * @returns A generated id.
23
- */
24
- next() {
25
- this.n = 1n + this.n;
26
- return this.prefix + this.n.toString(16);
27
- }
28
- };
29
-
30
- //#endregion
31
- //#region src/constants.ts
32
- /**
33
- * The NPM scope for this project.
34
- */
35
- const NPM_SCOPE = "@eslint-react";
36
- /**
37
- * The GitHub repository for this project.
38
- */
39
- const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
40
- /**
41
- * The URL to the project's website.
42
- */
43
- const WEBSITE_URL = "https://eslint-react.xyz";
44
- /**
45
- * Regular expressions for matching a HTML tag name
46
- */
47
- const RE_HTML_TAG = /^[a-z][^-]*$/u;
48
- /**
49
- * Regular expression for matching a TypeScript file extension.
50
- */
51
- const RE_TS_EXT = /^[cm]?tsx?$/u;
52
- /**
53
- * Regular expression for matching a JavaScript file extension.
54
- */
55
- const RE_JS_EXT = /^[cm]?jsx?$/u;
56
- /**
57
- * Regular expression for matching a PascalCase string.
58
- */
59
- const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
60
- /**
61
- * Regular expression for matching a camelCase string.
62
- */
63
- const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
64
- /**
65
- * Regular expression for matching a kebab-case string.
66
- */
67
- const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
68
- /**
69
- * Regular expression for matching a snake_case string.
70
- */
71
- const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
72
- /**
73
- * Regular expression for matching a CONSTANT_CASE string.
74
- */
75
- const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
76
- 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;
77
- /**
78
- * Regular expression for matching a valid JavaScript identifier.
79
- */
80
- const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
81
- /**
82
- * Regular expression for matching a RegExp string.
83
- */
84
- const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
85
- /**
86
- * Regular expression for matching a `@jsx` annotation comment.
87
- */
88
- const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
89
- /**
90
- * Regular expression for matching a `@jsxFrag` annotation comment.
91
- */
92
- const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
93
- /**
94
- * Regular expression for matching a `@jsxRuntime` annotation comment.
95
- */
96
- const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
97
- /**
98
- * Regular expression for matching a `@jsxImportSource` annotation comment.
99
- */
100
- const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
101
- /**
102
- * Regular expression for matching a React component name.
103
- */
104
- const RE_COMPONENT_NAME = /^[A-Z]/u;
105
- /**
106
- * Regular expression for matching a React component name (loose).
107
- */
108
- const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
109
- /**
110
- * Regular expression for matching a React Hook name.
111
- */
112
- const RE_HOOK_NAME = /^use/u;
113
- /**
114
- * Known impure functions
115
- */
116
- const IMPURE_FUNCS = new Map([
117
- ["Atomics", new Set([
118
- "add",
119
- "and",
120
- "compareExchange",
121
- "exchange",
122
- "load",
123
- "notify",
124
- "or",
125
- "store",
126
- "sub",
127
- "wait",
128
- "waitAsync",
129
- "xor"
130
- ])],
131
- ["caches", new Set([
132
- "delete",
133
- "has",
134
- "keys",
135
- "match",
136
- "open"
137
- ])],
138
- ["clipboard", new Set([
139
- "read",
140
- "readText",
141
- "write",
142
- "writeText"
143
- ])],
144
- ["cookieStore", new Set([
145
- "delete",
146
- "get",
147
- "getAll",
148
- "set"
149
- ])],
150
- ["crypto", new Set(["getRandomValues", "randomUUID"])],
151
- ["Date", new Set(["now"])],
152
- ["document", new Set([
153
- "adoptNode",
154
- "append",
155
- "close",
156
- "createAttribute",
157
- "createAttributeNS",
158
- "createCDATASection",
159
- "createComment",
160
- "createDocumentFragment",
161
- "createDocumentType",
162
- "createElement",
163
- "createElementNS",
164
- "createEvent",
165
- "createNodeIterator",
166
- "createProcessingInstruction",
167
- "createRange",
168
- "createTextNode",
169
- "createTreeWalker",
170
- "elementFromPoint",
171
- "elementsFromPoint",
172
- "execCommand",
173
- "exitFullscreen",
174
- "exitPictureInPicture",
175
- "exitPointerLock",
176
- "getAnimations",
177
- "getElementById",
178
- "getElementsByClassName",
179
- "getElementsByName",
180
- "getElementsByTagName",
181
- "getElementsByTagNameNS",
182
- "getSelection",
183
- "hasFocus",
184
- "importNode",
185
- "open",
186
- "prepend",
187
- "querySelector",
188
- "querySelectorAll",
189
- "replaceChildren",
190
- "requestStorageAccess",
191
- "startViewTransition",
192
- "write",
193
- "writeln"
194
- ])],
195
- ["globalThis", new Set([
196
- "addEventListener",
197
- "alert",
198
- "alert",
199
- "blur",
200
- "cancelAnimationFrame",
201
- "cancelIdleCallback",
202
- "clearInterval",
203
- "clearInterval",
204
- "clearTimeout",
205
- "clearTimeout",
206
- "close",
207
- "confirm",
208
- "confirm",
209
- "dispatchEvent",
210
- "fetch",
211
- "fetch",
212
- "focus",
213
- "getComputedStyle",
214
- "getSelection",
215
- "matchMedia",
216
- "moveBy",
217
- "moveTo",
218
- "open",
219
- "postMessage",
220
- "postMessage",
221
- "print",
222
- "prompt",
223
- "prompt",
224
- "queueMicrotask",
225
- "queueMicrotask",
226
- "removeEventListener",
227
- "reportError",
228
- "requestAnimationFrame",
229
- "requestIdleCallback",
230
- "resizeBy",
231
- "resizeTo",
232
- "scroll",
233
- "scrollBy",
234
- "scrollTo",
235
- "setInterval",
236
- "setInterval",
237
- "setTimeout",
238
- "setTimeout",
239
- "stop",
240
- "structuredClone"
241
- ])],
242
- ["history", new Set([
243
- "back",
244
- "forward",
245
- "go",
246
- "pushState",
247
- "replaceState"
248
- ])],
249
- ["indexedDB", new Set([
250
- "databases",
251
- "deleteDatabase",
252
- "open"
253
- ])],
254
- ["localStorage", new Set([
255
- "clear",
256
- "getItem",
257
- "key",
258
- "removeItem",
259
- "setItem"
260
- ])],
261
- ["location", new Set([
262
- "assign",
263
- "reload",
264
- "replace"
265
- ])],
266
- ["Math", new Set(["random"])],
267
- ["navigation", new Set([
268
- "back",
269
- "forward",
270
- "navigate",
271
- "reload",
272
- "traverseTo",
273
- "updateCurrentEntry"
274
- ])],
275
- ["navigator", new Set([
276
- "canShare",
277
- "getBattery",
278
- "getGamepads",
279
- "getUserMedia",
280
- "javaEnabled",
281
- "registerProtocolHandler",
282
- "requestMediaKeySystemAccess",
283
- "requestMIDIAccess",
284
- "sendBeacon",
285
- "share",
286
- "vibrate"
287
- ])],
288
- ["Notification", new Set(["requestPermission"])],
289
- ["Object", new Set([
290
- "assign",
291
- "defineProperties",
292
- "defineProperty",
293
- "freeze",
294
- "preventExtensions",
295
- "seal",
296
- "setPrototypeOf"
297
- ])],
298
- ["performance", new Set([
299
- "clearMarks",
300
- "clearMeasures",
301
- "getEntries",
302
- "getEntriesByName",
303
- "getEntriesByType",
304
- "mark",
305
- "measure",
306
- "now"
307
- ])],
308
- ["process", new Set([
309
- "abort",
310
- "chdir",
311
- "cpuUsage",
312
- "emitWarning",
313
- "exit",
314
- "hrtime",
315
- "kill",
316
- "memoryUsage",
317
- "nextTick",
318
- "send",
319
- "stderr",
320
- "stdout"
321
- ])],
322
- ["Reflect", new Set([
323
- "defineProperty",
324
- "deleteProperty",
325
- "preventExtensions",
326
- "set",
327
- "setPrototypeOf"
328
- ])],
329
- ["scheduler", new Set(["postTask", "yield"])],
330
- ["sessionStorage", new Set([
331
- "clear",
332
- "getItem",
333
- "key",
334
- "removeItem",
335
- "setItem"
336
- ])],
337
- ["URL", new Set(["createObjectURL", "revokeObjectURL"])],
338
- ["window", new Set([
339
- "addEventListener",
340
- "alert",
341
- "alert",
342
- "blur",
343
- "cancelAnimationFrame",
344
- "cancelIdleCallback",
345
- "clearInterval",
346
- "clearInterval",
347
- "clearTimeout",
348
- "clearTimeout",
349
- "close",
350
- "confirm",
351
- "confirm",
352
- "dispatchEvent",
353
- "fetch",
354
- "fetch",
355
- "focus",
356
- "getComputedStyle",
357
- "getSelection",
358
- "matchMedia",
359
- "moveBy",
360
- "moveTo",
361
- "open",
362
- "postMessage",
363
- "postMessage",
364
- "print",
365
- "prompt",
366
- "prompt",
367
- "queueMicrotask",
368
- "queueMicrotask",
369
- "removeEventListener",
370
- "reportError",
371
- "requestAnimationFrame",
372
- "requestIdleCallback",
373
- "resizeBy",
374
- "resizeTo",
375
- "scroll",
376
- "scrollBy",
377
- "scrollTo",
378
- "setInterval",
379
- "setInterval",
380
- "setTimeout",
381
- "setTimeout",
382
- "stop",
383
- "structuredClone"
384
- ])]
385
- ]);
386
- /**
387
- * Known impure global constructors used with `new`
388
- */
389
- const IMPURE_CTORS = new Set([
390
- "Audio",
391
- "AudioContext",
392
- "BroadcastChannel",
393
- "Date",
394
- "EventSource",
395
- "FileReader",
396
- "Image",
397
- "IntersectionObserver",
398
- "MediaRecorder",
399
- "MediaSource",
400
- "MediaStream",
401
- "MessageChannel",
402
- "MutationObserver",
403
- "Notification",
404
- "OfflineAudioContext",
405
- "PerformanceObserver",
406
- "ReportingObserver",
407
- "ResizeObserver",
408
- "RTCPeerConnection",
409
- "SharedWorker",
410
- "WebSocket",
411
- "Worker",
412
- "XMLHttpRequest"
413
- ]);
414
- /**
415
- * Known pure functions
416
- */
417
- const PURE_FUNCS = new Map([
418
- ["Array", new Set([
419
- "from",
420
- "isArray",
421
- "of"
422
- ])],
423
- ["Atomics", new Set(["isLockFree"])],
424
- ["BigInt", new Set(["asIntN", "asUintN"])],
425
- ["Date", new Set(["parse", "UTC"])],
426
- ["globalThis", new Set([
427
- "atob",
428
- "Boolean",
429
- "btoa",
430
- "decodeURI",
431
- "decodeURIComponent",
432
- "encodeURI",
433
- "encodeURIComponent",
434
- "escape",
435
- "isFinite",
436
- "isNaN",
437
- "Number",
438
- "parseFloat",
439
- "parseInt",
440
- "String",
441
- "unescape"
442
- ])],
443
- ["JSON", new Set(["parse", "stringify"])],
444
- ["Math", new Set([
445
- "abs",
446
- "acos",
447
- "acosh",
448
- "asin",
449
- "asinh",
450
- "atan",
451
- "atan2",
452
- "atanh",
453
- "cbrt",
454
- "ceil",
455
- "clz32",
456
- "cos",
457
- "cosh",
458
- "exp",
459
- "expm1",
460
- "floor",
461
- "fround",
462
- "hypot",
463
- "imul",
464
- "log",
465
- "log1p",
466
- "log2",
467
- "log10",
468
- "max",
469
- "min",
470
- "pow",
471
- "round",
472
- "sign",
473
- "sin",
474
- "sinh",
475
- "sqrt",
476
- "tan",
477
- "tanh",
478
- "trunc"
479
- ])],
480
- ["Number", new Set([
481
- "isFinite",
482
- "isInteger",
483
- "isNaN",
484
- "isSafeInteger",
485
- "parseFloat",
486
- "parseInt"
487
- ])],
488
- ["Object", new Set([
489
- "entries",
490
- "fromEntries",
491
- "getOwnPropertyDescriptor",
492
- "getOwnPropertyDescriptors",
493
- "getOwnPropertyNames",
494
- "getOwnPropertySymbols",
495
- "getPrototypeOf",
496
- "groupBy",
497
- "hasOwn",
498
- "is",
499
- "isExtensible",
500
- "isFrozen",
501
- "isSealed",
502
- "keys",
503
- "values"
504
- ])],
505
- ["Reflect", new Set([
506
- "apply",
507
- "construct",
508
- "get",
509
- "getOwnPropertyDescriptor",
510
- "getPrototypeOf",
511
- "has",
512
- "isExtensible",
513
- "ownKeys"
514
- ])],
515
- ["String", new Set([
516
- "fromCharCode",
517
- "fromCodePoint",
518
- "raw"
519
- ])]
520
- ]);
521
- /**
522
- Known pure global constructors used with `new`
523
- */
524
- const PURE_CTORS = new Set([
525
- "Array",
526
- "ArrayBuffer",
527
- "BigInt64Array",
528
- "BigUint64Array",
529
- "DataView",
530
- "Error",
531
- "EvalError",
532
- "FinalizationRegistry",
533
- "Float32Array",
534
- "Float64Array",
535
- "Int8Array",
536
- "Int16Array",
537
- "Int32Array",
538
- "Map",
539
- "RangeError",
540
- "ReferenceError",
541
- "RegExp",
542
- "Set",
543
- "SyntaxError",
544
- "TypeError",
545
- "Uint8Array",
546
- "Uint8ClampedArray",
547
- "Uint16Array",
548
- "Uint32Array",
549
- "URIError",
550
- "URL",
551
- "URLSearchParams",
552
- "WeakMap",
553
- "WeakRef",
554
- "WeakSet"
555
- ]);
556
-
557
- //#endregion
558
6
  //#region src/define-rule-listener.ts
559
7
  /**
560
8
  * Defines a rule listener by merging multiple visitor objects
@@ -724,23 +172,76 @@ function getOrInsertComputed(map, key, callback) {
724
172
  }
725
173
 
726
174
  //#endregion
727
- //#region src/react-version.ts
728
- const _require = module.createRequire(process.cwd() + path.sep);
175
+ //#region src/regexp.ts
729
176
  /**
730
- * Gets the React version from the project's dependencies.
731
- * @param fallback The fallback version to return if React is not found.
732
- * @returns The detected React version or the fallback version.
177
+ * Regular expressions for matching a HTML tag name
733
178
  */
734
- function getReactVersion(fallback) {
735
- try {
736
- return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
737
- } catch {
738
- return fallback;
739
- }
740
- }
741
-
742
- //#endregion
743
- //#region src/regexp.ts
179
+ const RE_HTML_TAG = /^[a-z][^-]*$/u;
180
+ /**
181
+ * Regular expression for matching a TypeScript file extension.
182
+ */
183
+ const RE_TS_EXT = /^[cm]?tsx?$/u;
184
+ /**
185
+ * Regular expression for matching a JavaScript file extension.
186
+ */
187
+ const RE_JS_EXT = /^[cm]?jsx?$/u;
188
+ /**
189
+ * Regular expression for matching a PascalCase string.
190
+ */
191
+ const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
192
+ /**
193
+ * Regular expression for matching a camelCase string.
194
+ */
195
+ const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
196
+ /**
197
+ * Regular expression for matching a kebab-case string.
198
+ */
199
+ const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
200
+ /**
201
+ * Regular expression for matching a snake_case string.
202
+ */
203
+ const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
204
+ /**
205
+ * Regular expression for matching a CONSTANT_CASE string.
206
+ */
207
+ const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
208
+ 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;
209
+ /**
210
+ * Regular expression for matching a valid JavaScript identifier.
211
+ */
212
+ const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
213
+ /**
214
+ * Regular expression for matching a RegExp string.
215
+ */
216
+ const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
217
+ /**
218
+ * Regular expression for matching a `@jsx` annotation comment.
219
+ */
220
+ const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
221
+ /**
222
+ * Regular expression for matching a `@jsxFrag` annotation comment.
223
+ */
224
+ const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
225
+ /**
226
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
227
+ */
228
+ const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
229
+ /**
230
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
231
+ */
232
+ const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
233
+ /**
234
+ * Regular expression for matching a React component name.
235
+ */
236
+ const RE_COMPONENT_NAME = /^[A-Z]/u;
237
+ /**
238
+ * Regular expression for matching a React component name (loose).
239
+ */
240
+ const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
241
+ /**
242
+ * Regular expression for matching a React Hook name.
243
+ */
244
+ const RE_HOOK_NAME = /^use/u;
744
245
  /**
745
246
  * Convert a string to the `RegExp`.
746
247
  * Normal strings (ex: `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -780,6 +281,7 @@ function report(context) {
780
281
 
781
282
  //#endregion
782
283
  //#region src/settings.ts
284
+ const _require = module.createRequire(process.cwd() + path.sep);
783
285
  /**
784
286
  * @internal
785
287
  */
@@ -832,10 +334,22 @@ const normalizeSettings = ({ importSource = "react", compilationMode, polymorphi
832
334
  };
833
335
  };
834
336
  const cache = /* @__PURE__ */ new Map();
337
+ /**
338
+ * Gets the React version from the project's dependencies.
339
+ * @param fallback The fallback version to return if React is not found.
340
+ * @returns The detected React version or the fallback version.
341
+ */
342
+ function getReactVersion(fallback) {
343
+ try {
344
+ return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
345
+ } catch {
346
+ return fallback;
347
+ }
348
+ }
835
349
  function getSettingsFromContext(context) {
836
- const settings = context.settings;
837
- return getOrInsertComputed(cache, settings["react-x"], () => normalizeSettings(decodeSettings(settings["react-x"])));
350
+ const settings = context.settings["react-x"];
351
+ return getOrInsertComputed(cache, settings, () => normalizeSettings(decodeSettings(settings)));
838
352
  }
839
353
 
840
354
  //#endregion
841
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, IMPURE_CTORS, IMPURE_FUNCS, IdGenerator, NPM_SCOPE, PURE_CTORS, PURE_FUNCS, 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, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
355
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, 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, decodeESLintSettings, decodeSettings, defineRuleListener, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "5.0.0-next.0",
3
+ "version": "5.0.1-beta.1",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {