@eslint-react/kit 1.40.4 → 1.40.5-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.mts CHANGED
@@ -38,60 +38,35 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
38
38
  */
39
39
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
40
40
 
41
+ type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
41
42
  /**
42
- * Regular expression for matching a `@jsx` annotation comment.
43
- */
44
- declare const RE_JSX_RT_ANNOTATION_JSX: RegExp;
45
- /**
46
- * Regular expression for matching a `@jsxFrag` annotation comment.
47
- */
48
- declare const RE_JSX_RT_ANNOTATION_JSX_FRAG: RegExp;
49
- /**
50
- * Regular expression for matching a `@jsxRuntime` annotation comment.
51
- */
52
- declare const RE_JSX_RT_ANNOTATION_JSX_RUNTIME: RegExp;
53
- /**
54
- * Regular expression for matching a `@jsxImportSource` annotation comment.
55
- */
56
- declare const RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
57
- interface JsxRuntimeAnnotation {
58
- jsx: _ | string;
59
- jsxFrag: _ | string;
60
- jsxImportSource: _ | string;
61
- jsxRuntime: _ | string;
62
- }
63
- declare function make$1(): JsxRuntimeAnnotation;
64
- /**
65
- * Get the a JsxRuntimeAnnotation object representing the JSX annotations in the file.
66
- * @param context The RuleContext
67
- * @returns JsxRuntimeAnnotation
43
+ * Create a JsxRuntimeOptions object
44
+ * @returns JsxRuntimeOptions
68
45
  */
69
- declare function getJsxRuntimeAnnotation(context: RuleContext): JsxRuntimeAnnotation;
70
-
71
- type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
46
+ declare function make$1(): JsxRuntimeOptions;
72
47
  /**
73
48
  * Get JsxRuntimeOptions from RuleContext
74
49
  * @param context The RuleContext
75
50
  * @returns JsxRuntimeOptions
76
51
  */
77
- declare function getJsxRuntimeOptions(context: RuleContext): {
52
+ declare function getFromContext$1(context: RuleContext): {
78
53
  jsx: JsxEmit;
79
54
  jsxFactory: string;
80
55
  jsxFragmentFactory: string;
81
56
  jsxImportSource: string;
82
57
  reactNamespace: string;
83
58
  };
59
+ /**
60
+ * Get JsxRuntimeOptions from annotation
61
+ * @param context The RuleContext
62
+ * @returns JsxRuntimeOptions
63
+ */
64
+ declare function getFromAnnotation(context: RuleContext): JsxRuntimeOptions;
84
65
 
85
- type index$1_JsxRuntimeAnnotation = JsxRuntimeAnnotation;
86
66
  type index$1_JsxRuntimeOptions = JsxRuntimeOptions;
87
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX: typeof RE_JSX_RT_ANNOTATION_JSX;
88
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_FRAG: typeof RE_JSX_RT_ANNOTATION_JSX_FRAG;
89
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: typeof RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE;
90
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_RUNTIME: typeof RE_JSX_RT_ANNOTATION_JSX_RUNTIME;
91
- declare const index$1_getJsxRuntimeAnnotation: typeof getJsxRuntimeAnnotation;
92
- declare const index$1_getJsxRuntimeOptions: typeof getJsxRuntimeOptions;
67
+ declare const index$1_getFromAnnotation: typeof getFromAnnotation;
93
68
  declare namespace index$1 {
94
- export { type index$1_JsxRuntimeAnnotation as JsxRuntimeAnnotation, type index$1_JsxRuntimeOptions as JsxRuntimeOptions, index$1_RE_JSX_RT_ANNOTATION_JSX as RE_JSX_RT_ANNOTATION_JSX, index$1_RE_JSX_RT_ANNOTATION_JSX_FRAG as RE_JSX_RT_ANNOTATION_JSX_FRAG, index$1_RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE as RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE, index$1_RE_JSX_RT_ANNOTATION_JSX_RUNTIME as RE_JSX_RT_ANNOTATION_JSX_RUNTIME, index$1_getJsxRuntimeAnnotation as getJsxRuntimeAnnotation, index$1_getJsxRuntimeOptions as getJsxRuntimeOptions, make$1 as make };
69
+ export { type index$1_JsxRuntimeOptions as JsxRuntimeOptions, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$1 as make };
95
70
  }
96
71
 
97
72
  /**
@@ -125,6 +100,7 @@ declare const DEFAULT_LANGUAGE_PREFERENCE: {
125
100
  * Get a copy of the default LanguagePreference.
126
101
  */
127
102
  declare function make(): LanguagePreference;
103
+ declare function getFromContext(): void;
128
104
  declare module "@typescript-eslint/utils/ts-eslint" {
129
105
  interface SharedConfigurationSettings {
130
106
  }
@@ -133,9 +109,10 @@ declare module "@typescript-eslint/utils/ts-eslint" {
133
109
  declare const index_DEFAULT_LANGUAGE_PREFERENCE: typeof DEFAULT_LANGUAGE_PREFERENCE;
134
110
  type index_LanguagePreference = LanguagePreference;
135
111
  declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
112
+ declare const index_getFromContext: typeof getFromContext;
136
113
  declare const index_make: typeof make;
137
114
  declare namespace index {
138
- export { index_DEFAULT_LANGUAGE_PREFERENCE as DEFAULT_LANGUAGE_PREFERENCE, type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_make as make };
115
+ export { index_DEFAULT_LANGUAGE_PREFERENCE as DEFAULT_LANGUAGE_PREFERENCE, type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_getFromContext as getFromContext, index_make as make };
139
116
  }
140
117
 
141
118
  /**
@@ -175,6 +152,22 @@ declare const RE_JS_IDENTIFIER: RegExp;
175
152
  * Regular expression for matching a RegExp string.
176
153
  */
177
154
  declare const RE_REGEXP_STR: RegExp;
155
+ /**
156
+ * Regular expression for matching a `@jsx` annotation comment.
157
+ */
158
+ declare const RE_ANNOTATION_JSX: RegExp;
159
+ /**
160
+ * Regular expression for matching a `@jsxFrag` annotation comment.
161
+ */
162
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
163
+ /**
164
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
165
+ */
166
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
167
+ /**
168
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
169
+ */
170
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
178
171
  /**
179
172
  * Convert a string to the `RegExp`.
180
173
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -193,4 +186,4 @@ declare function toRegExp(string: string): {
193
186
  */
194
187
  declare function isRegExp(string: string): boolean;
195
188
 
196
- export { index$1 as JsxRuntime, index as LanguagePreference, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
189
+ export { index$1 as JsxRuntimeOptions, index as LanguagePreference, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.d.ts CHANGED
@@ -38,60 +38,35 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
38
38
  */
39
39
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
40
40
 
41
+ type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
41
42
  /**
42
- * Regular expression for matching a `@jsx` annotation comment.
43
- */
44
- declare const RE_JSX_RT_ANNOTATION_JSX: RegExp;
45
- /**
46
- * Regular expression for matching a `@jsxFrag` annotation comment.
47
- */
48
- declare const RE_JSX_RT_ANNOTATION_JSX_FRAG: RegExp;
49
- /**
50
- * Regular expression for matching a `@jsxRuntime` annotation comment.
51
- */
52
- declare const RE_JSX_RT_ANNOTATION_JSX_RUNTIME: RegExp;
53
- /**
54
- * Regular expression for matching a `@jsxImportSource` annotation comment.
55
- */
56
- declare const RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
57
- interface JsxRuntimeAnnotation {
58
- jsx: _ | string;
59
- jsxFrag: _ | string;
60
- jsxImportSource: _ | string;
61
- jsxRuntime: _ | string;
62
- }
63
- declare function make$1(): JsxRuntimeAnnotation;
64
- /**
65
- * Get the a JsxRuntimeAnnotation object representing the JSX annotations in the file.
66
- * @param context The RuleContext
67
- * @returns JsxRuntimeAnnotation
43
+ * Create a JsxRuntimeOptions object
44
+ * @returns JsxRuntimeOptions
68
45
  */
69
- declare function getJsxRuntimeAnnotation(context: RuleContext): JsxRuntimeAnnotation;
70
-
71
- type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
46
+ declare function make$1(): JsxRuntimeOptions;
72
47
  /**
73
48
  * Get JsxRuntimeOptions from RuleContext
74
49
  * @param context The RuleContext
75
50
  * @returns JsxRuntimeOptions
76
51
  */
77
- declare function getJsxRuntimeOptions(context: RuleContext): {
52
+ declare function getFromContext$1(context: RuleContext): {
78
53
  jsx: JsxEmit;
79
54
  jsxFactory: string;
80
55
  jsxFragmentFactory: string;
81
56
  jsxImportSource: string;
82
57
  reactNamespace: string;
83
58
  };
59
+ /**
60
+ * Get JsxRuntimeOptions from annotation
61
+ * @param context The RuleContext
62
+ * @returns JsxRuntimeOptions
63
+ */
64
+ declare function getFromAnnotation(context: RuleContext): JsxRuntimeOptions;
84
65
 
85
- type index$1_JsxRuntimeAnnotation = JsxRuntimeAnnotation;
86
66
  type index$1_JsxRuntimeOptions = JsxRuntimeOptions;
87
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX: typeof RE_JSX_RT_ANNOTATION_JSX;
88
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_FRAG: typeof RE_JSX_RT_ANNOTATION_JSX_FRAG;
89
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: typeof RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE;
90
- declare const index$1_RE_JSX_RT_ANNOTATION_JSX_RUNTIME: typeof RE_JSX_RT_ANNOTATION_JSX_RUNTIME;
91
- declare const index$1_getJsxRuntimeAnnotation: typeof getJsxRuntimeAnnotation;
92
- declare const index$1_getJsxRuntimeOptions: typeof getJsxRuntimeOptions;
67
+ declare const index$1_getFromAnnotation: typeof getFromAnnotation;
93
68
  declare namespace index$1 {
94
- export { type index$1_JsxRuntimeAnnotation as JsxRuntimeAnnotation, type index$1_JsxRuntimeOptions as JsxRuntimeOptions, index$1_RE_JSX_RT_ANNOTATION_JSX as RE_JSX_RT_ANNOTATION_JSX, index$1_RE_JSX_RT_ANNOTATION_JSX_FRAG as RE_JSX_RT_ANNOTATION_JSX_FRAG, index$1_RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE as RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE, index$1_RE_JSX_RT_ANNOTATION_JSX_RUNTIME as RE_JSX_RT_ANNOTATION_JSX_RUNTIME, index$1_getJsxRuntimeAnnotation as getJsxRuntimeAnnotation, index$1_getJsxRuntimeOptions as getJsxRuntimeOptions, make$1 as make };
69
+ export { type index$1_JsxRuntimeOptions as JsxRuntimeOptions, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$1 as make };
95
70
  }
96
71
 
97
72
  /**
@@ -125,6 +100,7 @@ declare const DEFAULT_LANGUAGE_PREFERENCE: {
125
100
  * Get a copy of the default LanguagePreference.
126
101
  */
127
102
  declare function make(): LanguagePreference;
103
+ declare function getFromContext(): void;
128
104
  declare module "@typescript-eslint/utils/ts-eslint" {
129
105
  interface SharedConfigurationSettings {
130
106
  }
@@ -133,9 +109,10 @@ declare module "@typescript-eslint/utils/ts-eslint" {
133
109
  declare const index_DEFAULT_LANGUAGE_PREFERENCE: typeof DEFAULT_LANGUAGE_PREFERENCE;
134
110
  type index_LanguagePreference = LanguagePreference;
135
111
  declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
112
+ declare const index_getFromContext: typeof getFromContext;
136
113
  declare const index_make: typeof make;
137
114
  declare namespace index {
138
- export { index_DEFAULT_LANGUAGE_PREFERENCE as DEFAULT_LANGUAGE_PREFERENCE, type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_make as make };
115
+ export { index_DEFAULT_LANGUAGE_PREFERENCE as DEFAULT_LANGUAGE_PREFERENCE, type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_getFromContext as getFromContext, index_make as make };
139
116
  }
140
117
 
141
118
  /**
@@ -175,6 +152,22 @@ declare const RE_JS_IDENTIFIER: RegExp;
175
152
  * Regular expression for matching a RegExp string.
176
153
  */
177
154
  declare const RE_REGEXP_STR: RegExp;
155
+ /**
156
+ * Regular expression for matching a `@jsx` annotation comment.
157
+ */
158
+ declare const RE_ANNOTATION_JSX: RegExp;
159
+ /**
160
+ * Regular expression for matching a `@jsxFrag` annotation comment.
161
+ */
162
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
163
+ /**
164
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
165
+ */
166
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
167
+ /**
168
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
169
+ */
170
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
178
171
  /**
179
172
  * Convert a string to the `RegExp`.
180
173
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -193,4 +186,4 @@ declare function toRegExp(string: string): {
193
186
  */
194
187
  declare function isRegExp(string: string): boolean;
195
188
 
196
- export { index$1 as JsxRuntime, index as LanguagePreference, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
189
+ export { index$1 as JsxRuntimeOptions, index as LanguagePreference, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var eff = require('@eslint-react/eff');
4
3
  var typescript = require('typescript');
5
4
  var valibot = require('valibot');
6
5
 
@@ -10,46 +9,43 @@ var __export = (target, all) => {
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
12
11
 
13
- // src/JsxRuntime/index.ts
14
- var JsxRuntime_exports = {};
15
- __export(JsxRuntime_exports, {
16
- RE_JSX_RT_ANNOTATION_JSX: () => RE_JSX_RT_ANNOTATION_JSX,
17
- RE_JSX_RT_ANNOTATION_JSX_FRAG: () => RE_JSX_RT_ANNOTATION_JSX_FRAG,
18
- RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: () => RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE,
19
- RE_JSX_RT_ANNOTATION_JSX_RUNTIME: () => RE_JSX_RT_ANNOTATION_JSX_RUNTIME,
20
- getJsxRuntimeAnnotation: () => getJsxRuntimeAnnotation,
21
- getJsxRuntimeOptions: () => getJsxRuntimeOptions,
12
+ // src/JsxRuntimeOptions/index.ts
13
+ var JsxRuntimeOptions_exports = {};
14
+ __export(JsxRuntimeOptions_exports, {
15
+ getFromAnnotation: () => getFromAnnotation,
16
+ getFromContext: () => getFromContext,
22
17
  make: () => make
23
18
  });
24
- var RE_JSX_RT_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
25
- var RE_JSX_RT_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
26
- var RE_JSX_RT_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
27
- var RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
28
- function make() {
29
- return {
30
- jsx: eff._,
31
- jsxFrag: eff._,
32
- jsxImportSource: eff._,
33
- jsxRuntime: eff._
34
- };
19
+
20
+ // src/RegExp.ts
21
+ var RE_TS_EXT = /^[cm]?tsx?$/;
22
+ var RE_JS_EXT = /^[cm]?jsx?$/;
23
+ var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
24
+ var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
25
+ var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
26
+ var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
27
+ var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
28
+ var 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;
29
+ var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
30
+ var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
31
+ var RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
32
+ var RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
33
+ var RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
34
+ var RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
35
+ function toRegExp(string) {
36
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
37
+ if (pattern != null) return new RegExp(pattern, flags);
38
+ return { test: (s) => s === string };
35
39
  }
36
- function getJsxRuntimeAnnotation(context) {
37
- const JsxRuntimeAnnotation = make();
38
- if (!context.sourceCode.text.includes("@jsx")) return JsxRuntimeAnnotation;
39
- const allComments = context.sourceCode.getAllComments();
40
- for (const comment of allComments) {
41
- const jsx = comment.value.match(RE_JSX_RT_ANNOTATION_JSX);
42
- const jsxFrag = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_FRAG);
43
- const jsxRuntime = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_RUNTIME);
44
- const jsxImportSource = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE);
45
- JsxRuntimeAnnotation.jsx = jsx?.[1];
46
- JsxRuntimeAnnotation.jsxFrag = jsxFrag?.[1];
47
- JsxRuntimeAnnotation.jsxRuntime = jsxRuntime?.[1];
48
- JsxRuntimeAnnotation.jsxImportSource = jsxImportSource?.[1];
49
- }
50
- return JsxRuntimeAnnotation;
40
+ function isRegExp(string) {
41
+ return Boolean(RE_REGEXP_STR.test(string));
42
+ }
43
+
44
+ // src/JsxRuntimeOptions/JsxRuntimeOptions.ts
45
+ function make() {
46
+ return {};
51
47
  }
52
- function getJsxRuntimeOptions(context) {
48
+ function getFromContext(context) {
53
49
  const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
54
50
  return {
55
51
  jsx: options.jsx ?? typescript.JsxEmit.ReactJSX,
@@ -59,12 +55,30 @@ function getJsxRuntimeOptions(context) {
59
55
  reactNamespace: options.reactNamespace ?? "React"
60
56
  };
61
57
  }
58
+ function getFromAnnotation(context) {
59
+ if (!context.sourceCode.text.includes("@jsx")) return {};
60
+ let jsx, jsxFrag, jsxRuntime, jsxImportSource;
61
+ for (const comment of context.sourceCode.getAllComments()) {
62
+ const value = comment.value;
63
+ jsx = value.match(RE_ANNOTATION_JSX)?.[1];
64
+ jsxFrag = value.match(RE_ANNOTATION_JSX_FRAG)?.[1];
65
+ jsxRuntime = value.match(RE_ANNOTATION_JSX_RUNTIME)?.[1];
66
+ jsxImportSource = value.match(RE_ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
67
+ }
68
+ const options = make();
69
+ if (jsx != null) options.jsxFactory = jsx;
70
+ if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
71
+ if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? typescript.JsxEmit.ReactJSX : typescript.JsxEmit.ReactJSXDev;
72
+ if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
73
+ return options;
74
+ }
62
75
 
63
76
  // src/LanguagePreference/index.ts
64
77
  var LanguagePreference_exports = {};
65
78
  __export(LanguagePreference_exports, {
66
79
  DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
67
80
  LanguagePreferenceSchema: () => LanguagePreferenceSchema,
81
+ getFromContext: () => getFromContext2,
68
82
  make: () => make2
69
83
  });
70
84
  var DEFAULT_LANGUAGE_PREFERENCE = {
@@ -80,6 +94,9 @@ function make2() {
80
94
  ...DEFAULT_LANGUAGE_PREFERENCE
81
95
  };
82
96
  }
97
+ function getFromContext2() {
98
+ throw new Error("getFromContext is not implemented");
99
+ }
83
100
  var LanguagePreferenceSchema = valibot.object({
84
101
  indentStyle: valibot.optional(
85
102
  valibot.union([
@@ -121,26 +138,6 @@ var LanguagePreferenceSchema = valibot.object({
121
138
  )
122
139
  });
123
140
 
124
- // src/RegExp.ts
125
- var RE_TS_EXT = /^[cm]?tsx?$/;
126
- var RE_JS_EXT = /^[cm]?jsx?$/;
127
- var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
128
- var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
129
- var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
130
- var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
131
- var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
132
- var 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;
133
- var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
134
- var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
135
- function toRegExp(string) {
136
- const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
137
- if (pattern != null) return new RegExp(pattern, flags);
138
- return { test: (s) => s === string };
139
- }
140
- function isRegExp(string) {
141
- return Boolean(RE_REGEXP_STR.test(string));
142
- }
143
-
144
141
  // src/Rule.ts
145
142
  function createReport(context) {
146
143
  return (descriptor) => {
@@ -148,8 +145,12 @@ function createReport(context) {
148
145
  };
149
146
  }
150
147
 
151
- exports.JsxRuntime = JsxRuntime_exports;
148
+ exports.JsxRuntimeOptions = JsxRuntimeOptions_exports;
152
149
  exports.LanguagePreference = LanguagePreference_exports;
150
+ exports.RE_ANNOTATION_JSX = RE_ANNOTATION_JSX;
151
+ exports.RE_ANNOTATION_JSX_FRAG = RE_ANNOTATION_JSX_FRAG;
152
+ exports.RE_ANNOTATION_JSX_IMPORT_SOURCE = RE_ANNOTATION_JSX_IMPORT_SOURCE;
153
+ exports.RE_ANNOTATION_JSX_RUNTIME = RE_ANNOTATION_JSX_RUNTIME;
153
154
  exports.RE_CAMEL_CASE = RE_CAMEL_CASE;
154
155
  exports.RE_CONSTANT_CASE = RE_CONSTANT_CASE;
155
156
  exports.RE_JAVASCRIPT_PROTOCOL = RE_JAVASCRIPT_PROTOCOL;
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { _ } from '@eslint-react/eff';
2
1
  import { JsxEmit } from 'typescript';
3
2
  import { object, optional, union, literal, number } from 'valibot';
4
3
 
@@ -8,46 +7,43 @@ var __export = (target, all) => {
8
7
  __defProp(target, name, { get: all[name], enumerable: true });
9
8
  };
10
9
 
11
- // src/JsxRuntime/index.ts
12
- var JsxRuntime_exports = {};
13
- __export(JsxRuntime_exports, {
14
- RE_JSX_RT_ANNOTATION_JSX: () => RE_JSX_RT_ANNOTATION_JSX,
15
- RE_JSX_RT_ANNOTATION_JSX_FRAG: () => RE_JSX_RT_ANNOTATION_JSX_FRAG,
16
- RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE: () => RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE,
17
- RE_JSX_RT_ANNOTATION_JSX_RUNTIME: () => RE_JSX_RT_ANNOTATION_JSX_RUNTIME,
18
- getJsxRuntimeAnnotation: () => getJsxRuntimeAnnotation,
19
- getJsxRuntimeOptions: () => getJsxRuntimeOptions,
10
+ // src/JsxRuntimeOptions/index.ts
11
+ var JsxRuntimeOptions_exports = {};
12
+ __export(JsxRuntimeOptions_exports, {
13
+ getFromAnnotation: () => getFromAnnotation,
14
+ getFromContext: () => getFromContext,
20
15
  make: () => make
21
16
  });
22
- var RE_JSX_RT_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
23
- var RE_JSX_RT_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
24
- var RE_JSX_RT_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
25
- var RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
26
- function make() {
27
- return {
28
- jsx: _,
29
- jsxFrag: _,
30
- jsxImportSource: _,
31
- jsxRuntime: _
32
- };
17
+
18
+ // src/RegExp.ts
19
+ var RE_TS_EXT = /^[cm]?tsx?$/;
20
+ var RE_JS_EXT = /^[cm]?jsx?$/;
21
+ var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
22
+ var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
23
+ var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
24
+ var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
25
+ var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
26
+ var 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;
27
+ var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
28
+ var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
29
+ var RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
30
+ var RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
31
+ var RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
32
+ var RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
33
+ function toRegExp(string) {
34
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
35
+ if (pattern != null) return new RegExp(pattern, flags);
36
+ return { test: (s) => s === string };
33
37
  }
34
- function getJsxRuntimeAnnotation(context) {
35
- const JsxRuntimeAnnotation = make();
36
- if (!context.sourceCode.text.includes("@jsx")) return JsxRuntimeAnnotation;
37
- const allComments = context.sourceCode.getAllComments();
38
- for (const comment of allComments) {
39
- const jsx = comment.value.match(RE_JSX_RT_ANNOTATION_JSX);
40
- const jsxFrag = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_FRAG);
41
- const jsxRuntime = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_RUNTIME);
42
- const jsxImportSource = comment.value.match(RE_JSX_RT_ANNOTATION_JSX_IMPORT_SOURCE);
43
- JsxRuntimeAnnotation.jsx = jsx?.[1];
44
- JsxRuntimeAnnotation.jsxFrag = jsxFrag?.[1];
45
- JsxRuntimeAnnotation.jsxRuntime = jsxRuntime?.[1];
46
- JsxRuntimeAnnotation.jsxImportSource = jsxImportSource?.[1];
47
- }
48
- return JsxRuntimeAnnotation;
38
+ function isRegExp(string) {
39
+ return Boolean(RE_REGEXP_STR.test(string));
40
+ }
41
+
42
+ // src/JsxRuntimeOptions/JsxRuntimeOptions.ts
43
+ function make() {
44
+ return {};
49
45
  }
50
- function getJsxRuntimeOptions(context) {
46
+ function getFromContext(context) {
51
47
  const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
52
48
  return {
53
49
  jsx: options.jsx ?? JsxEmit.ReactJSX,
@@ -57,12 +53,30 @@ function getJsxRuntimeOptions(context) {
57
53
  reactNamespace: options.reactNamespace ?? "React"
58
54
  };
59
55
  }
56
+ function getFromAnnotation(context) {
57
+ if (!context.sourceCode.text.includes("@jsx")) return {};
58
+ let jsx, jsxFrag, jsxRuntime, jsxImportSource;
59
+ for (const comment of context.sourceCode.getAllComments()) {
60
+ const value = comment.value;
61
+ jsx = value.match(RE_ANNOTATION_JSX)?.[1];
62
+ jsxFrag = value.match(RE_ANNOTATION_JSX_FRAG)?.[1];
63
+ jsxRuntime = value.match(RE_ANNOTATION_JSX_RUNTIME)?.[1];
64
+ jsxImportSource = value.match(RE_ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
65
+ }
66
+ const options = make();
67
+ if (jsx != null) options.jsxFactory = jsx;
68
+ if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
69
+ if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.ReactJSX : JsxEmit.ReactJSXDev;
70
+ if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
71
+ return options;
72
+ }
60
73
 
61
74
  // src/LanguagePreference/index.ts
62
75
  var LanguagePreference_exports = {};
63
76
  __export(LanguagePreference_exports, {
64
77
  DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
65
78
  LanguagePreferenceSchema: () => LanguagePreferenceSchema,
79
+ getFromContext: () => getFromContext2,
66
80
  make: () => make2
67
81
  });
68
82
  var DEFAULT_LANGUAGE_PREFERENCE = {
@@ -78,6 +92,9 @@ function make2() {
78
92
  ...DEFAULT_LANGUAGE_PREFERENCE
79
93
  };
80
94
  }
95
+ function getFromContext2() {
96
+ throw new Error("getFromContext is not implemented");
97
+ }
81
98
  var LanguagePreferenceSchema = object({
82
99
  indentStyle: optional(
83
100
  union([
@@ -119,26 +136,6 @@ var LanguagePreferenceSchema = object({
119
136
  )
120
137
  });
121
138
 
122
- // src/RegExp.ts
123
- var RE_TS_EXT = /^[cm]?tsx?$/;
124
- var RE_JS_EXT = /^[cm]?jsx?$/;
125
- var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
126
- var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
127
- var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
128
- var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
129
- var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
130
- var 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;
131
- var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
132
- var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
133
- function toRegExp(string) {
134
- const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
135
- if (pattern != null) return new RegExp(pattern, flags);
136
- return { test: (s) => s === string };
137
- }
138
- function isRegExp(string) {
139
- return Boolean(RE_REGEXP_STR.test(string));
140
- }
141
-
142
139
  // src/Rule.ts
143
140
  function createReport(context) {
144
141
  return (descriptor) => {
@@ -146,4 +143,4 @@ function createReport(context) {
146
143
  };
147
144
  }
148
145
 
149
- export { JsxRuntime_exports as JsxRuntime, LanguagePreference_exports as LanguagePreference, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, createReport, isRegExp, toRegExp };
146
+ export { JsxRuntimeOptions_exports as JsxRuntimeOptions, LanguagePreference_exports as LanguagePreference, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, createReport, isRegExp, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "1.40.4",
3
+ "version": "1.40.5-beta.1",
4
4
  "description": "ESLint React's plugin kit for building plugins and rules.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -38,7 +38,7 @@
38
38
  "@typescript-eslint/utils": "^8.29.0",
39
39
  "ts-pattern": "^5.7.0",
40
40
  "valibot": "^1.0.0",
41
- "@eslint-react/eff": "1.40.4"
41
+ "@eslint-react/eff": "1.40.5-beta.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tsconfig/node22": "^22.0.1",