@eslint-react/kit 1.40.5-beta.0 → 1.40.5-beta.2
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 +36 -43
- package/dist/index.d.ts +36 -43
- package/dist/index.js +57 -52
- package/dist/index.mjs +53 -52
- package/package.json +2 -2
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 JsxRuntimeConfig = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
declare const RE_JSX_RT_ANNOTATION_JSX: RegExp;
|
|
45
|
-
/**
|
|
46
|
-
* Regular expression for matching a `@jsxFrag` annotation comment.
|
|
43
|
+
* Create a JsxRuntimeConfig object
|
|
44
|
+
* @returns JsxRuntimeConfig
|
|
47
45
|
*/
|
|
48
|
-
declare
|
|
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
|
|
68
|
-
*/
|
|
69
|
-
declare function getJsxRuntimeAnnotation(context: RuleContext): JsxRuntimeAnnotation;
|
|
70
|
-
|
|
71
|
-
type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
46
|
+
declare function make$1(): JsxRuntimeConfig;
|
|
72
47
|
/**
|
|
73
|
-
* Get
|
|
48
|
+
* Get JsxRuntimeConfig from RuleContext
|
|
74
49
|
* @param context The RuleContext
|
|
75
|
-
* @returns
|
|
50
|
+
* @returns JsxRuntimeConfig
|
|
76
51
|
*/
|
|
77
|
-
declare function
|
|
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 JsxRuntimeConfig from annotation
|
|
61
|
+
* @param context The RuleContext
|
|
62
|
+
* @returns JsxRuntimeConfig
|
|
63
|
+
*/
|
|
64
|
+
declare function getFromAnnotation(context: RuleContext): JsxRuntimeConfig;
|
|
84
65
|
|
|
85
|
-
type index$
|
|
86
|
-
|
|
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;
|
|
66
|
+
type index$1_JsxRuntimeConfig = JsxRuntimeConfig;
|
|
67
|
+
declare const index$1_getFromAnnotation: typeof getFromAnnotation;
|
|
93
68
|
declare namespace index$1 {
|
|
94
|
-
export { type index$
|
|
69
|
+
export { type index$1_JsxRuntimeConfig as JsxRuntimeConfig, 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
|
|
189
|
+
export { index$1 as JsxRuntimeConfig, 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 JsxRuntimeConfig = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
declare const RE_JSX_RT_ANNOTATION_JSX: RegExp;
|
|
45
|
-
/**
|
|
46
|
-
* Regular expression for matching a `@jsxFrag` annotation comment.
|
|
43
|
+
* Create a JsxRuntimeConfig object
|
|
44
|
+
* @returns JsxRuntimeConfig
|
|
47
45
|
*/
|
|
48
|
-
declare
|
|
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
|
|
68
|
-
*/
|
|
69
|
-
declare function getJsxRuntimeAnnotation(context: RuleContext): JsxRuntimeAnnotation;
|
|
70
|
-
|
|
71
|
-
type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
46
|
+
declare function make$1(): JsxRuntimeConfig;
|
|
72
47
|
/**
|
|
73
|
-
* Get
|
|
48
|
+
* Get JsxRuntimeConfig from RuleContext
|
|
74
49
|
* @param context The RuleContext
|
|
75
|
-
* @returns
|
|
50
|
+
* @returns JsxRuntimeConfig
|
|
76
51
|
*/
|
|
77
|
-
declare function
|
|
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 JsxRuntimeConfig from annotation
|
|
61
|
+
* @param context The RuleContext
|
|
62
|
+
* @returns JsxRuntimeConfig
|
|
63
|
+
*/
|
|
64
|
+
declare function getFromAnnotation(context: RuleContext): JsxRuntimeConfig;
|
|
84
65
|
|
|
85
|
-
type index$
|
|
86
|
-
|
|
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;
|
|
66
|
+
type index$1_JsxRuntimeConfig = JsxRuntimeConfig;
|
|
67
|
+
declare const index$1_getFromAnnotation: typeof getFromAnnotation;
|
|
93
68
|
declare namespace index$1 {
|
|
94
|
-
export { type index$
|
|
69
|
+
export { type index$1_JsxRuntimeConfig as JsxRuntimeConfig, 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
|
|
189
|
+
export { index$1 as JsxRuntimeConfig, 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
|
@@ -9,43 +9,43 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// src/
|
|
13
|
-
var
|
|
14
|
-
__export(
|
|
15
|
-
|
|
16
|
-
|
|
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,
|
|
12
|
+
// src/JsxRuntimeConfig/index.ts
|
|
13
|
+
var JsxRuntimeConfig_exports = {};
|
|
14
|
+
__export(JsxRuntimeConfig_exports, {
|
|
15
|
+
getFromAnnotation: () => getFromAnnotation,
|
|
16
|
+
getFromContext: () => getFromContext,
|
|
21
17
|
make: () => make
|
|
22
18
|
});
|
|
23
19
|
|
|
24
|
-
// src/
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
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/JsxRuntimeConfig/JsxRuntimeConfig.ts
|
|
29
45
|
function make() {
|
|
30
46
|
return {};
|
|
31
47
|
}
|
|
32
|
-
function
|
|
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) {
|
|
48
|
+
function getFromContext(context) {
|
|
49
49
|
const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
|
|
50
50
|
return {
|
|
51
51
|
jsx: options.jsx ?? typescript.JsxEmit.ReactJSX,
|
|
@@ -55,12 +55,30 @@ function getJsxRuntimeOptions(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
|
+
}
|
|
58
75
|
|
|
59
76
|
// src/LanguagePreference/index.ts
|
|
60
77
|
var LanguagePreference_exports = {};
|
|
61
78
|
__export(LanguagePreference_exports, {
|
|
62
79
|
DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
|
|
63
80
|
LanguagePreferenceSchema: () => LanguagePreferenceSchema,
|
|
81
|
+
getFromContext: () => getFromContext2,
|
|
64
82
|
make: () => make2
|
|
65
83
|
});
|
|
66
84
|
var DEFAULT_LANGUAGE_PREFERENCE = {
|
|
@@ -76,6 +94,9 @@ function make2() {
|
|
|
76
94
|
...DEFAULT_LANGUAGE_PREFERENCE
|
|
77
95
|
};
|
|
78
96
|
}
|
|
97
|
+
function getFromContext2() {
|
|
98
|
+
throw new Error("getFromContext is not implemented");
|
|
99
|
+
}
|
|
79
100
|
var LanguagePreferenceSchema = valibot.object({
|
|
80
101
|
indentStyle: valibot.optional(
|
|
81
102
|
valibot.union([
|
|
@@ -117,26 +138,6 @@ var LanguagePreferenceSchema = valibot.object({
|
|
|
117
138
|
)
|
|
118
139
|
});
|
|
119
140
|
|
|
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
|
-
|
|
140
141
|
// src/Rule.ts
|
|
141
142
|
function createReport(context) {
|
|
142
143
|
return (descriptor) => {
|
|
@@ -144,8 +145,12 @@ function createReport(context) {
|
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
exports.
|
|
148
|
+
exports.JsxRuntimeConfig = JsxRuntimeConfig_exports;
|
|
148
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;
|
|
149
154
|
exports.RE_CAMEL_CASE = RE_CAMEL_CASE;
|
|
150
155
|
exports.RE_CONSTANT_CASE = RE_CONSTANT_CASE;
|
|
151
156
|
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/
|
|
11
|
-
var
|
|
12
|
-
__export(
|
|
13
|
-
|
|
14
|
-
|
|
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,
|
|
10
|
+
// src/JsxRuntimeConfig/index.ts
|
|
11
|
+
var JsxRuntimeConfig_exports = {};
|
|
12
|
+
__export(JsxRuntimeConfig_exports, {
|
|
13
|
+
getFromAnnotation: () => getFromAnnotation,
|
|
14
|
+
getFromContext: () => getFromContext,
|
|
19
15
|
make: () => make
|
|
20
16
|
});
|
|
21
17
|
|
|
22
|
-
// src/
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
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/JsxRuntimeConfig/JsxRuntimeConfig.ts
|
|
27
43
|
function make() {
|
|
28
44
|
return {};
|
|
29
45
|
}
|
|
30
|
-
function
|
|
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) {
|
|
46
|
+
function getFromContext(context) {
|
|
47
47
|
const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
|
|
48
48
|
return {
|
|
49
49
|
jsx: options.jsx ?? JsxEmit.ReactJSX,
|
|
@@ -53,12 +53,30 @@ function getJsxRuntimeOptions(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
|
+
}
|
|
56
73
|
|
|
57
74
|
// src/LanguagePreference/index.ts
|
|
58
75
|
var LanguagePreference_exports = {};
|
|
59
76
|
__export(LanguagePreference_exports, {
|
|
60
77
|
DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
|
|
61
78
|
LanguagePreferenceSchema: () => LanguagePreferenceSchema,
|
|
79
|
+
getFromContext: () => getFromContext2,
|
|
62
80
|
make: () => make2
|
|
63
81
|
});
|
|
64
82
|
var DEFAULT_LANGUAGE_PREFERENCE = {
|
|
@@ -74,6 +92,9 @@ function make2() {
|
|
|
74
92
|
...DEFAULT_LANGUAGE_PREFERENCE
|
|
75
93
|
};
|
|
76
94
|
}
|
|
95
|
+
function getFromContext2() {
|
|
96
|
+
throw new Error("getFromContext is not implemented");
|
|
97
|
+
}
|
|
77
98
|
var LanguagePreferenceSchema = object({
|
|
78
99
|
indentStyle: optional(
|
|
79
100
|
union([
|
|
@@ -115,26 +136,6 @@ var LanguagePreferenceSchema = object({
|
|
|
115
136
|
)
|
|
116
137
|
});
|
|
117
138
|
|
|
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
|
-
|
|
138
139
|
// src/Rule.ts
|
|
139
140
|
function createReport(context) {
|
|
140
141
|
return (descriptor) => {
|
|
@@ -142,4 +143,4 @@ function createReport(context) {
|
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
export {
|
|
146
|
+
export { JsxRuntimeConfig_exports as JsxRuntimeConfig, 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.5-beta.
|
|
3
|
+
"version": "1.40.5-beta.2",
|
|
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.
|
|
41
|
+
"@eslint-react/eff": "1.40.5-beta.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@tsconfig/node22": "^22.0.1",
|