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