@eslint-react/kit 2.0.0-beta.2 → 2.0.0-beta.200

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +93 -227
  2. package/dist/index.js +99 -210
  3. package/package.json +8 -9
package/dist/index.d.ts CHANGED
@@ -1,202 +1,142 @@
1
- import * as typescript from 'typescript';
2
- import * as tseslint from '@typescript-eslint/utils/ts-eslint';
3
- import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
4
- import { z } from 'zod/v4';
5
- import { unit } from '@eslint-react/eff';
6
- import { TSESTree } from '@typescript-eslint/utils';
7
-
8
- /**
9
- * Rule severity.
10
- * @since 0.0.1
11
- */
12
- type RuleSeverity = "error" | "off" | "warn";
13
- /**
14
- * Rule declaration.
15
- * @internal
16
- * @since 0.0.1
17
- */
18
- type RuleDeclaration = [RuleSeverity, Record<string, unknown>?] | RuleSeverity;
19
- /**
20
- * Rule config preset.
21
- * @since 0.0.1
22
- */
23
- type RulePreset = Record<string, RuleDeclaration>;
24
- /**
25
- * Rule context.
26
- * @since 0.0.1
27
- */
28
- type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
29
- /**
30
- * Rule feature.
31
- * @since 1.20.0
32
- */
33
- type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
34
- type RulePolicy = number;
35
- type RuleSuggest<MessageIds extends string = string> = {
36
- messageId: MessageIds;
37
- data?: Record<string, unknown>;
38
- fix: tseslint.ReportFixFunction;
39
- };
40
-
41
- declare const JsxEmit: {
42
- readonly None: 0;
43
- readonly Preserve: 1;
44
- readonly React: 2;
45
- readonly ReactNative: 3;
46
- readonly ReactJSX: 4;
47
- readonly ReactJSXDev: 5;
48
- };
49
- interface JsxConfig {
50
- jsx?: number;
51
- jsxFactory?: string;
52
- jsxFragmentFactory?: string;
53
- jsxImportSource?: string;
54
- }
55
- /**
56
- * Create a JsxConfig object
57
- * @returns JsxConfig
58
- */
59
- declare function make$2(): JsxConfig;
60
- /**
61
- * Get JsxConfig from RuleContext
62
- * @param context The RuleContext
63
- * @returns JsxConfig
64
- */
65
- declare function getFromContext$1(context: RuleContext): {
66
- jsx: 4 | typescript.JsxEmit;
67
- jsxFactory: string;
68
- jsxFragmentFactory: string;
69
- jsxImportSource: string;
70
- reactNamespace: string;
71
- };
72
- /**
73
- * Get JsxConfig from annotation
74
- * @param context The RuleContext
75
- * @returns JsxConfig
76
- */
77
- declare function getFromAnnotation(context: RuleContext): JsxConfig;
78
-
79
- type index$1_JsxConfig = JsxConfig;
80
- declare const index$1_JsxEmit: typeof JsxEmit;
81
- declare const index$1_getFromAnnotation: typeof getFromAnnotation;
82
- declare namespace index$1 {
83
- export { type index$1_JsxConfig as JsxConfig, index$1_JsxEmit as JsxEmit, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$2 as make };
84
- }
85
-
86
- /**
87
- * @internal
88
- */
89
- declare const LanguagePreferenceSchema: z.ZodObject<{
90
- indentStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"tab">, z.ZodLiteral<"space">]>>;
91
- indentWidth: z.ZodOptional<z.ZodNumber>;
92
- quoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
93
- semicolons: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"asNeeded">]>>;
94
- trailingCommas: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodLiteral<"es5">, z.ZodLiteral<"none">]>>;
95
- jsxQuoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
96
- }, z.core.$strip>;
97
-
98
- /**
99
- * @internal
100
- */
101
- type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
102
- /**
103
- * Get a copy of the default LanguagePreference.
104
- */
105
- declare function make$1(): LanguagePreference;
106
- /**
107
- * A default LanguagePreference object.
108
- */
109
- declare const defaultLanguagePreference: {
110
- indentStyle?: "tab" | "space" | undefined;
111
- indentWidth?: number | undefined;
112
- quoteStyle?: "single" | "double" | undefined;
113
- semicolons?: "always" | "asNeeded" | undefined;
114
- trailingCommas?: "all" | "es5" | "none" | undefined;
115
- jsxQuoteStyle?: "single" | "double" | undefined;
116
- };
117
- declare function getFromContext(): void;
118
- declare module "@typescript-eslint/utils/ts-eslint" {
119
- interface SharedConfigurationSettings {
120
- }
121
- }
122
-
123
- type index_LanguagePreference = LanguagePreference;
124
- declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
125
- declare const index_defaultLanguagePreference: typeof defaultLanguagePreference;
126
- declare const index_getFromContext: typeof getFromContext;
127
- declare namespace index {
128
- export { type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_defaultLanguagePreference as defaultLanguagePreference, index_getFromContext as getFromContext, make$1 as make };
129
- }
1
+ import { unit } from "@eslint-react/eff";
2
+ import * as tseslint from "@typescript-eslint/utils/ts-eslint";
3
+ import { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint";
130
4
 
5
+ //#region src/constants.d.ts
131
6
  /**
132
7
  * Regular expressions for matching a HTML tag name
133
8
  */
134
- declare const HTML_TAG: RegExp;
9
+ declare const RE_HTML_TAG: RegExp;
135
10
  /**
136
11
  * Regular expression for matching a TypeScript file extension.
137
12
  */
138
- declare const TS_EXT: RegExp;
13
+ declare const RE_TS_EXT: RegExp;
139
14
  /**
140
15
  * Regular expression for matching a JavaScript file extension.
141
16
  */
142
- declare const JS_EXT: RegExp;
17
+ declare const RE_JS_EXT: RegExp;
143
18
  /**
144
19
  * Regular expression for matching a PascalCase string.
145
20
  */
146
- declare const PASCAL_CASE: RegExp;
21
+ declare const RE_PASCAL_CASE: RegExp;
147
22
  /**
148
23
  * Regular expression for matching a camelCase string.
149
24
  */
150
- declare const CAMEL_CASE: RegExp;
25
+ declare const RE_CAMEL_CASE: RegExp;
151
26
  /**
152
27
  * Regular expression for matching a kebab-case string.
153
28
  */
154
- declare const KEBAB_CASE: RegExp;
29
+ declare const RE_KEBAB_CASE: RegExp;
155
30
  /**
156
31
  * Regular expression for matching a snake_case string.
157
32
  */
158
- declare const SNAKE_CASE: RegExp;
33
+ declare const RE_SNAKE_CASE: RegExp;
159
34
  /**
160
35
  * Regular expression for matching a CONSTANT_CASE string.
161
36
  */
162
- declare const CONSTANT_CASE: RegExp;
163
- declare const JAVASCRIPT_PROTOCOL: RegExp;
37
+ declare const RE_CONSTANT_CASE: RegExp;
38
+ declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
164
39
  /**
165
40
  * Regular expression for matching a valid JavaScript identifier.
166
41
  */
167
- declare const JS_IDENTIFIER: RegExp;
42
+ declare const RE_JS_IDENTIFIER: RegExp;
168
43
  /**
169
44
  * Regular expression for matching a RegExp string.
170
45
  */
171
- declare const REGEXP_STR: RegExp;
46
+ declare const RE_REGEXP_STR: RegExp;
172
47
  /**
173
48
  * Regular expression for matching a `@jsx` annotation comment.
174
49
  */
175
- declare const ANNOTATION_JSX: RegExp;
50
+ declare const RE_ANNOTATION_JSX: RegExp;
176
51
  /**
177
52
  * Regular expression for matching a `@jsxFrag` annotation comment.
178
53
  */
179
- declare const ANNOTATION_JSX_FRAG: RegExp;
54
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
180
55
  /**
181
56
  * Regular expression for matching a `@jsxRuntime` annotation comment.
182
57
  */
183
- declare const ANNOTATION_JSX_RUNTIME: RegExp;
58
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
184
59
  /**
185
60
  * Regular expression for matching a `@jsxImportSource` annotation comment.
186
61
  */
187
- declare const ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
62
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
188
63
  /**
189
64
  * Regular expression for matching a React component name.
190
65
  */
191
- declare const COMPONENT_NAME: RegExp;
66
+ declare const RE_COMPONENT_NAME: RegExp;
192
67
  /**
193
68
  * Regular expression for matching a React component name (loose).
194
69
  */
195
- declare const COMPONENT_NAME_LOOSE: RegExp;
70
+ declare const RE_COMPONENT_NAME_LOOSE: RegExp;
196
71
  /**
197
72
  * Regular expression for matching a React Hook name.
198
73
  */
199
- declare const HOOK_NAME: RegExp;
74
+ declare const RE_HOOK_NAME: RegExp;
75
+ //#endregion
76
+ //#region src/types/index.d.ts
77
+ /**
78
+ * Rule severity.
79
+ * @since 0.0.1
80
+ */
81
+ type SeverityName = "off" | "warn" | "error";
82
+ /**
83
+ * The numeric severity level for a rule.
84
+ *
85
+ * - `0` means off.
86
+ * - `1` means warn.
87
+ * - `2` means error.
88
+ */
89
+ type SeverityLevel = 0 | 1 | 2;
90
+ /**
91
+ * The severity of a rule in a configuration.
92
+ */
93
+ type Severity = SeverityName | SeverityLevel;
94
+ /**
95
+ * Rule declaration.
96
+ * @internal
97
+ * @since 0.0.1
98
+ */
99
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
100
+ /**
101
+ * Rule context.
102
+ * @since 0.0.1
103
+ */
104
+ type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
105
+ /**
106
+ * Rule feature.
107
+ * @since 1.20.0
108
+ */
109
+ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
110
+ type RulePolicy = number;
111
+ type RuleSuggest<MessageIds extends string = string> = {
112
+ messageId: MessageIds;
113
+ data?: Record<string, unknown>;
114
+ fix: tseslint.ReportFixFunction;
115
+ };
116
+ /**
117
+ * A collection of settings.
118
+ */
119
+ interface SettingsConfig {
120
+ [key: string]: unknown;
121
+ }
122
+ interface CompatibleRule {
123
+ meta: Record<string, any>;
124
+ create: (...args: any[]) => any;
125
+ }
126
+ interface CompatiblePlugin {
127
+ meta: {
128
+ name: string;
129
+ version: string;
130
+ };
131
+ rules: Record<string, CompatibleRule>;
132
+ }
133
+ interface CompatibleConfig {
134
+ name?: string;
135
+ rules?: Record<string, RuleConfig>;
136
+ settings?: SettingsConfig;
137
+ }
138
+ //#endregion
139
+ //#region src/utils/regexp.d.ts
200
140
  /**
201
141
  * Convert a string to the `RegExp`.
202
142
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -206,7 +146,7 @@ declare const HOOK_NAME: RegExp;
206
146
  * @returns Returns the `RegExp`.
207
147
  */
208
148
  declare function toRegExp(string: string): {
209
- test(s: string): boolean;
149
+ test(s: string): boolean;
210
150
  };
211
151
  /**
212
152
  * Checks whether given string is regexp string
@@ -214,82 +154,8 @@ declare function toRegExp(string: string): {
214
154
  * @returns boolean
215
155
  */
216
156
  declare function isRegExp(string: string): boolean;
217
-
218
- declare const RegExp$1_ANNOTATION_JSX: typeof ANNOTATION_JSX;
219
- declare const RegExp$1_ANNOTATION_JSX_FRAG: typeof ANNOTATION_JSX_FRAG;
220
- declare const RegExp$1_ANNOTATION_JSX_IMPORT_SOURCE: typeof ANNOTATION_JSX_IMPORT_SOURCE;
221
- declare const RegExp$1_ANNOTATION_JSX_RUNTIME: typeof ANNOTATION_JSX_RUNTIME;
222
- declare const RegExp$1_CAMEL_CASE: typeof CAMEL_CASE;
223
- declare const RegExp$1_COMPONENT_NAME: typeof COMPONENT_NAME;
224
- declare const RegExp$1_COMPONENT_NAME_LOOSE: typeof COMPONENT_NAME_LOOSE;
225
- declare const RegExp$1_CONSTANT_CASE: typeof CONSTANT_CASE;
226
- declare const RegExp$1_HOOK_NAME: typeof HOOK_NAME;
227
- declare const RegExp$1_HTML_TAG: typeof HTML_TAG;
228
- declare const RegExp$1_JAVASCRIPT_PROTOCOL: typeof JAVASCRIPT_PROTOCOL;
229
- declare const RegExp$1_JS_EXT: typeof JS_EXT;
230
- declare const RegExp$1_JS_IDENTIFIER: typeof JS_IDENTIFIER;
231
- declare const RegExp$1_KEBAB_CASE: typeof KEBAB_CASE;
232
- declare const RegExp$1_PASCAL_CASE: typeof PASCAL_CASE;
233
- declare const RegExp$1_REGEXP_STR: typeof REGEXP_STR;
234
- declare const RegExp$1_SNAKE_CASE: typeof SNAKE_CASE;
235
- declare const RegExp$1_TS_EXT: typeof TS_EXT;
236
- declare const RegExp$1_isRegExp: typeof isRegExp;
237
- declare const RegExp$1_toRegExp: typeof toRegExp;
238
- declare namespace RegExp$1 {
239
- export { RegExp$1_ANNOTATION_JSX as ANNOTATION_JSX, RegExp$1_ANNOTATION_JSX_FRAG as ANNOTATION_JSX_FRAG, RegExp$1_ANNOTATION_JSX_IMPORT_SOURCE as ANNOTATION_JSX_IMPORT_SOURCE, RegExp$1_ANNOTATION_JSX_RUNTIME as ANNOTATION_JSX_RUNTIME, RegExp$1_CAMEL_CASE as CAMEL_CASE, RegExp$1_COMPONENT_NAME as COMPONENT_NAME, RegExp$1_COMPONENT_NAME_LOOSE as COMPONENT_NAME_LOOSE, RegExp$1_CONSTANT_CASE as CONSTANT_CASE, RegExp$1_HOOK_NAME as HOOK_NAME, RegExp$1_HTML_TAG as HTML_TAG, RegExp$1_JAVASCRIPT_PROTOCOL as JAVASCRIPT_PROTOCOL, RegExp$1_JS_EXT as JS_EXT, RegExp$1_JS_IDENTIFIER as JS_IDENTIFIER, RegExp$1_KEBAB_CASE as KEBAB_CASE, RegExp$1_PASCAL_CASE as PASCAL_CASE, RegExp$1_REGEXP_STR as REGEXP_STR, RegExp$1_SNAKE_CASE as SNAKE_CASE, RegExp$1_TS_EXT as TS_EXT, RegExp$1_isRegExp as isRegExp, RegExp$1_toRegExp as toRegExp };
240
- }
241
-
242
- interface Reporter<TMessageID extends string> {
243
- send: (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
244
- sendOrElse: <TElse>(descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse) => unit | TElse;
245
- }
246
- declare const send: {
247
- <TMessageID extends string>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>): void;
248
- <TMessageID extends string>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
249
- };
250
- declare const sendOrElse: {
251
- <TMessageID extends string, TElse>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse): unit | TElse;
252
- <TMessageID extends string, TElse>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => (cb: () => TElse) => unit | TElse;
253
- };
254
- declare function make<TMessageID extends string>(context: RuleContext): Reporter<TMessageID>;
255
-
256
- type Reporter$1_Reporter<TMessageID extends string> = Reporter<TMessageID>;
257
- declare const Reporter$1_make: typeof make;
258
- declare const Reporter$1_send: typeof send;
259
- declare const Reporter$1_sendOrElse: typeof sendOrElse;
260
- declare namespace Reporter$1 {
261
- export { type Reporter$1_Reporter as Reporter, Reporter$1_make as make, Reporter$1_send as send, Reporter$1_sendOrElse as sendOrElse };
262
- }
263
-
264
- type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
265
- body: TSESTree.Expression;
266
- };
267
- type ObjectDestructuringVariableDeclarator = TSESTree.VariableDeclarator & {
268
- id: TSESTree.ObjectPattern;
269
- init: TSESTree.Identifier;
270
- };
271
- type DisplayNameAssignmentExpression = TSESTree.AssignmentExpression & {
272
- type: "AssignmentExpression";
273
- left: TSESTree.MemberExpression & {
274
- property: TSESTree.Identifier & {
275
- name: "displayName";
276
- };
277
- };
278
- operator: "=";
279
- right: TSESTree.Literal;
280
- };
281
- declare const IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
282
- declare const OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
283
- declare const DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
284
-
285
- declare const Selector_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: typeof DISPLAY_NAME_ASSIGNMENT_EXPRESSION;
286
- type Selector_DisplayNameAssignmentExpression = DisplayNameAssignmentExpression;
287
- declare const Selector_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: typeof IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION;
288
- type Selector_ImplicitReturnArrowFunctionExpression = ImplicitReturnArrowFunctionExpression;
289
- declare const Selector_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: typeof OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR;
290
- type Selector_ObjectDestructuringVariableDeclarator = ObjectDestructuringVariableDeclarator;
291
- declare namespace Selector {
292
- export { Selector_DISPLAY_NAME_ASSIGNMENT_EXPRESSION as DISPLAY_NAME_ASSIGNMENT_EXPRESSION, type Selector_DisplayNameAssignmentExpression as DisplayNameAssignmentExpression, Selector_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION as IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, type Selector_ImplicitReturnArrowFunctionExpression as ImplicitReturnArrowFunctionExpression, Selector_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR as OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, type Selector_ObjectDestructuringVariableDeclarator as ObjectDestructuringVariableDeclarator };
293
- }
294
-
295
- export { index$1 as JsxConfig, index as LanguagePreference, RegExp$1 as RegExp, Reporter$1 as Reporter, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePolicy, type RulePreset, type RuleSeverity, type RuleSuggest, Selector };
157
+ //#endregion
158
+ //#region src/utils/reporting.d.ts
159
+ declare function report(context: RuleContext): (descriptor: unit | null | ReportDescriptor<string>) => void;
160
+ //#endregion
161
+ export { CompatibleConfig, CompatiblePlugin, CompatibleRule, 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, RuleConfig, RuleContext, RuleFeature, RulePolicy, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, isRegExp, report, toRegExp };
package/dist/index.js CHANGED
@@ -1,219 +1,108 @@
1
- import { dual, getOrElseUpdate } from '@eslint-react/eff';
2
- import { z } from 'zod/v4';
1
+ import "@eslint-react/eff";
3
2
 
4
- var __defProp = Object.defineProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
3
+ //#region src/constants.ts
4
+ /**
5
+ * Regular expressions for matching a HTML tag name
6
+ */
7
+ const RE_HTML_TAG = /^[a-z][^-]*$/u;
8
+ /**
9
+ * Regular expression for matching a TypeScript file extension.
10
+ */
11
+ const RE_TS_EXT = /^[cm]?tsx?$/u;
12
+ /**
13
+ * Regular expression for matching a JavaScript file extension.
14
+ */
15
+ const RE_JS_EXT = /^[cm]?jsx?$/u;
16
+ /**
17
+ * Regular expression for matching a PascalCase string.
18
+ */
19
+ const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
20
+ /**
21
+ * Regular expression for matching a camelCase string.
22
+ */
23
+ const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
24
+ /**
25
+ * Regular expression for matching a kebab-case string.
26
+ */
27
+ const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
28
+ /**
29
+ * Regular expression for matching a snake_case string.
30
+ */
31
+ const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
32
+ /**
33
+ * Regular expression for matching a CONSTANT_CASE string.
34
+ */
35
+ const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
36
+ 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;
37
+ /**
38
+ * Regular expression for matching a valid JavaScript identifier.
39
+ */
40
+ const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
41
+ /**
42
+ * Regular expression for matching a RegExp string.
43
+ */
44
+ const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
45
+ /**
46
+ * Regular expression for matching a `@jsx` annotation comment.
47
+ */
48
+ const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
49
+ /**
50
+ * Regular expression for matching a `@jsxFrag` annotation comment.
51
+ */
52
+ const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
53
+ /**
54
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
55
+ */
56
+ const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
57
+ /**
58
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
59
+ */
60
+ const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
61
+ /**
62
+ * Regular expression for matching a React component name.
63
+ */
64
+ const RE_COMPONENT_NAME = /^[A-Z]/u;
65
+ /**
66
+ * Regular expression for matching a React component name (loose).
67
+ */
68
+ const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
69
+ /**
70
+ * Regular expression for matching a React Hook name.
71
+ */
72
+ const RE_HOOK_NAME = /^use/u;
9
73
 
10
- // src/JsxConfig/index.ts
11
- var JsxConfig_exports = {};
12
- __export(JsxConfig_exports, {
13
- JsxEmit: () => JsxEmit,
14
- getFromAnnotation: () => getFromAnnotation,
15
- getFromContext: () => getFromContext,
16
- make: () => make
17
- });
18
-
19
- // src/RegExp.ts
20
- var RegExp_exports = {};
21
- __export(RegExp_exports, {
22
- ANNOTATION_JSX: () => ANNOTATION_JSX,
23
- ANNOTATION_JSX_FRAG: () => ANNOTATION_JSX_FRAG,
24
- ANNOTATION_JSX_IMPORT_SOURCE: () => ANNOTATION_JSX_IMPORT_SOURCE,
25
- ANNOTATION_JSX_RUNTIME: () => ANNOTATION_JSX_RUNTIME,
26
- CAMEL_CASE: () => CAMEL_CASE,
27
- COMPONENT_NAME: () => COMPONENT_NAME,
28
- COMPONENT_NAME_LOOSE: () => COMPONENT_NAME_LOOSE,
29
- CONSTANT_CASE: () => CONSTANT_CASE,
30
- HOOK_NAME: () => HOOK_NAME,
31
- HTML_TAG: () => HTML_TAG,
32
- JAVASCRIPT_PROTOCOL: () => JAVASCRIPT_PROTOCOL,
33
- JS_EXT: () => JS_EXT,
34
- JS_IDENTIFIER: () => JS_IDENTIFIER,
35
- KEBAB_CASE: () => KEBAB_CASE,
36
- PASCAL_CASE: () => PASCAL_CASE,
37
- REGEXP_STR: () => REGEXP_STR,
38
- SNAKE_CASE: () => SNAKE_CASE,
39
- TS_EXT: () => TS_EXT,
40
- isRegExp: () => isRegExp,
41
- toRegExp: () => toRegExp
42
- });
43
- var HTML_TAG = /^[a-z][^-]*$/u;
44
- var TS_EXT = /^[cm]?tsx?$/u;
45
- var JS_EXT = /^[cm]?jsx?$/u;
46
- var PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
47
- var CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
48
- var KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
49
- var SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
50
- var CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
51
- var 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;
52
- var JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
53
- var REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
54
- var ANNOTATION_JSX = /@jsx\s+(\S+)/u;
55
- var ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
56
- var ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
57
- var ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
58
- var COMPONENT_NAME = /^[A-Z]/u;
59
- var COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
60
- var HOOK_NAME = /^use/u;
74
+ //#endregion
75
+ //#region src/utils/regexp.ts
76
+ /**
77
+ * Convert a string to the `RegExp`.
78
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
79
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
80
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
81
+ * @param string The string to convert.
82
+ * @returns Returns the `RegExp`.
83
+ */
61
84
  function toRegExp(string) {
62
- const [, pattern, flags = "u"] = REGEXP_STR.exec(string) ?? [];
63
- if (pattern != null) return new RegExp(pattern, flags);
64
- return { test: (s) => s === string };
85
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
86
+ if (pattern != null) return new RegExp(pattern, flags);
87
+ return { test: (s) => s === string };
65
88
  }
89
+ /**
90
+ * Checks whether given string is regexp string
91
+ * @param string The string to check
92
+ * @returns boolean
93
+ */
66
94
  function isRegExp(string) {
67
- return Boolean(REGEXP_STR.test(string));
68
- }
69
-
70
- // src/JsxConfig/JsxConfig.ts
71
- var JsxEmit = {
72
- None: 0,
73
- Preserve: 1,
74
- React: 2,
75
- ReactNative: 3,
76
- ReactJSX: 4,
77
- ReactJSXDev: 5
78
- };
79
- function make() {
80
- return {};
81
- }
82
- function getFromContext(context) {
83
- const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
84
- return {
85
- jsx: options.jsx ?? JsxEmit.ReactJSX,
86
- jsxFactory: options.jsxFactory ?? "React.createElement",
87
- jsxFragmentFactory: options.jsxFragmentFactory ?? "React.Fragment",
88
- jsxImportSource: options.jsxImportSource ?? "react",
89
- reactNamespace: options.reactNamespace ?? "React"
90
- };
91
- }
92
- var cache = /* @__PURE__ */ new WeakMap();
93
- function getFromAnnotation(context) {
94
- return getOrElseUpdate(
95
- cache,
96
- context.sourceCode,
97
- () => {
98
- const options = make();
99
- if (!context.sourceCode.text.includes("@jsx")) return options;
100
- let jsx, jsxFrag, jsxRuntime, jsxImportSource;
101
- for (const comment of context.sourceCode.getAllComments().reverse()) {
102
- const value = comment.value;
103
- jsx ??= value.match(ANNOTATION_JSX)?.[1];
104
- jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
105
- jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
106
- jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
107
- }
108
- if (jsx != null) options.jsxFactory = jsx;
109
- if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
110
- if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.React : JsxEmit.ReactJSX;
111
- if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
112
- return options;
113
- }
114
- );
95
+ return RE_REGEXP_STR.test(string);
115
96
  }
116
97
 
117
- // src/LanguagePreference/index.ts
118
- var LanguagePreference_exports = {};
119
- __export(LanguagePreference_exports, {
120
- LanguagePreferenceSchema: () => LanguagePreferenceSchema,
121
- defaultLanguagePreference: () => defaultLanguagePreference,
122
- getFromContext: () => getFromContext2,
123
- make: () => make2
124
- });
125
-
126
- // src/LanguagePreference/LanguagePreference.ts
127
- function make2() {
128
- return {
129
- indentStyle: "space",
130
- indentWidth: 2,
131
- jsxQuoteStyle: "double",
132
- quoteStyle: "single",
133
- semicolons: "always",
134
- trailingCommas: "all"
135
- };
136
- }
137
- var defaultLanguagePreference = make2();
138
- function getFromContext2() {
139
- throw new Error("getFromContext is not implemented");
98
+ //#endregion
99
+ //#region src/utils/reporting.ts
100
+ function report(context) {
101
+ return (descriptor) => {
102
+ if (descriptor == null) return;
103
+ return context.report(descriptor);
104
+ };
140
105
  }
141
- var LanguagePreferenceSchema = z.object({
142
- indentStyle: z.optional(
143
- z.union([
144
- z.literal("tab"),
145
- z.literal("space")
146
- ])
147
- ),
148
- indentWidth: z.optional(z.number()),
149
- quoteStyle: z.optional(
150
- z.union([
151
- z.literal("single"),
152
- z.literal("double")
153
- ])
154
- ),
155
- semicolons: z.optional(
156
- z.union([
157
- z.literal("always"),
158
- z.literal("asNeeded")
159
- ])
160
- ),
161
- trailingCommas: z.optional(
162
- z.union([
163
- z.literal("all"),
164
- z.literal("es5"),
165
- z.literal("none")
166
- ])
167
- ),
168
- // JSX specific options
169
- jsxQuoteStyle: z.optional(
170
- z.union([
171
- z.literal("single"),
172
- z.literal("double")
173
- ])
174
- )
175
- }, {});
176
-
177
- // src/Reporter.ts
178
- var Reporter_exports = {};
179
- __export(Reporter_exports, {
180
- make: () => make3,
181
- send: () => send,
182
- sendOrElse: () => sendOrElse
183
- });
184
- var send = dual(2, (context, descriptor) => {
185
- if (descriptor == null) return;
186
- return context.report(descriptor);
187
- });
188
- var sendOrElse = dual(3, (context, descriptor, cb) => {
189
- if (descriptor == null) return cb();
190
- return context.report(descriptor);
191
- });
192
- function make3(context) {
193
- return {
194
- send: (...args) => send(context, ...args),
195
- sendOrElse: (...args) => sendOrElse(context, ...args)
196
- };
197
- }
198
-
199
- // src/Selector.ts
200
- var Selector_exports = {};
201
- __export(Selector_exports, {
202
- DISPLAY_NAME_ASSIGNMENT_EXPRESSION: () => DISPLAY_NAME_ASSIGNMENT_EXPRESSION,
203
- IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: () => IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION,
204
- OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: () => OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR
205
- });
206
- var IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
207
- var OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
208
- "VariableDeclarator",
209
- "[id.type='ObjectPattern']",
210
- "[init.type='Identifier']"
211
- ].join("");
212
- var DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
213
- "AssignmentExpression",
214
- "[operator='=']",
215
- "[left.type='MemberExpression']",
216
- "[left.property.name='displayName']"
217
- ].join("");
218
106
 
219
- export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RegExp_exports as RegExp, Reporter_exports as Reporter, Selector_exports as Selector };
107
+ //#endregion
108
+ export { 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, isRegExp, report, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.200",
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": {
@@ -27,23 +27,22 @@
27
27
  "./package.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@typescript-eslint/utils": "^8.35.0",
31
- "ts-pattern": "^5.7.1",
32
- "zod": "^3.25.67",
33
- "@eslint-react/eff": "2.0.0-beta.2"
30
+ "@typescript-eslint/utils": "^8.44.1",
31
+ "ts-pattern": "^5.8.0",
32
+ "zod": "^4.1.11",
33
+ "@eslint-react/eff": "2.0.0-beta.200"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@tsconfig/node22": "^22.0.2",
37
- "tsup": "^8.5.0",
38
- "type-fest": "^4.41.0",
37
+ "tsdown": "^0.15.4",
38
+ "type-fest": "^5.0.1",
39
39
  "@local/configs": "0.0.0"
40
40
  },
41
41
  "engines": {
42
- "bun": ">=1.0.15",
43
42
  "node": ">=20.19.0"
44
43
  },
45
44
  "scripts": {
46
- "build": "tsup",
45
+ "build": "tsdown --dts-resolve",
47
46
  "build:docs": "typedoc",
48
47
  "lint:publish": "publint",
49
48
  "lint:ts": "tsc --noEmit"