@eslint-react/kit 2.0.0-next.177 → 2.0.0-next.179

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,10 @@
1
1
  import { unit } from "@eslint-react/eff";
2
- import { z } from "zod/v4";
3
2
  import { TSESTree } from "@typescript-eslint/types";
4
- import * as typescript0 from "typescript";
3
+ import { TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
5
4
  import * as tseslint from "@typescript-eslint/utils/ts-eslint";
6
5
  import { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint";
7
- import { TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
8
6
 
9
- //#region src/ContextDetection.d.ts
10
- declare namespace ContextDetection_d_exports {
11
- export { isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isViMock, isViMockCallback };
12
- }
7
+ //#region src/ast/env-checks.d.ts
13
8
  /**
14
9
  * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
15
10
  * @param node The AST node
@@ -17,7 +12,7 @@ declare namespace ContextDetection_d_exports {
17
12
  */
18
13
  declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
19
14
  /**
20
- * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
15
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
21
16
  * @param node The AST node
22
17
  * @param operator The operator used in the comparison
23
18
  * @param value The string literal value to compare against
@@ -39,7 +34,100 @@ declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.M
39
34
  */
40
35
  declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
41
36
  //#endregion
42
- //#region src/types.d.ts
37
+ //#region src/ast/selectors.d.ts
38
+ type ImplicitReturnArrowFunctionExpression = TSESTree$1.ArrowFunctionExpression & {
39
+ body: TSESTree$1.Expression;
40
+ };
41
+ type ObjectDestructuringVariableDeclarator = TSESTree$1.VariableDeclarator & {
42
+ id: TSESTree$1.ObjectPattern;
43
+ init: TSESTree$1.Identifier;
44
+ };
45
+ type DisplayNameAssignmentExpression = TSESTree$1.AssignmentExpression & {
46
+ type: "AssignmentExpression";
47
+ left: TSESTree$1.MemberExpression & {
48
+ property: TSESTree$1.Identifier & {
49
+ name: "displayName";
50
+ };
51
+ };
52
+ operator: "=";
53
+ right: TSESTree$1.Literal;
54
+ };
55
+ declare const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
56
+ declare const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
57
+ declare const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
58
+ //#endregion
59
+ //#region src/constants.d.ts
60
+ /**
61
+ * Regular expressions for matching a HTML tag name
62
+ */
63
+ declare const RE_HTML_TAG: RegExp;
64
+ /**
65
+ * Regular expression for matching a TypeScript file extension.
66
+ */
67
+ declare const RE_TS_EXT: RegExp;
68
+ /**
69
+ * Regular expression for matching a JavaScript file extension.
70
+ */
71
+ declare const RE_JS_EXT: RegExp;
72
+ /**
73
+ * Regular expression for matching a PascalCase string.
74
+ */
75
+ declare const RE_PASCAL_CASE: RegExp;
76
+ /**
77
+ * Regular expression for matching a camelCase string.
78
+ */
79
+ declare const RE_CAMEL_CASE: RegExp;
80
+ /**
81
+ * Regular expression for matching a kebab-case string.
82
+ */
83
+ declare const RE_KEBAB_CASE: RegExp;
84
+ /**
85
+ * Regular expression for matching a snake_case string.
86
+ */
87
+ declare const RE_SNAKE_CASE: RegExp;
88
+ /**
89
+ * Regular expression for matching a CONSTANT_CASE string.
90
+ */
91
+ declare const RE_CONSTANT_CASE: RegExp;
92
+ declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
93
+ /**
94
+ * Regular expression for matching a valid JavaScript identifier.
95
+ */
96
+ declare const RE_JS_IDENTIFIER: RegExp;
97
+ /**
98
+ * Regular expression for matching a RegExp string.
99
+ */
100
+ declare const RE_REGEXP_STR: RegExp;
101
+ /**
102
+ * Regular expression for matching a `@jsx` annotation comment.
103
+ */
104
+ declare const RE_ANNOTATION_JSX: RegExp;
105
+ /**
106
+ * Regular expression for matching a `@jsxFrag` annotation comment.
107
+ */
108
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
109
+ /**
110
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
111
+ */
112
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
113
+ /**
114
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
115
+ */
116
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
117
+ /**
118
+ * Regular expression for matching a React component name.
119
+ */
120
+ declare const RE_COMPONENT_NAME: RegExp;
121
+ /**
122
+ * Regular expression for matching a React component name (loose).
123
+ */
124
+ declare const RE_COMPONENT_NAME_LOOSE: RegExp;
125
+ /**
126
+ * Regular expression for matching a React Hook name.
127
+ */
128
+ declare const RE_HOOK_NAME: RegExp;
129
+ //#endregion
130
+ //#region src/types/index.d.ts
43
131
  /**
44
132
  * Rule severity.
45
133
  * @since 0.0.1
@@ -102,160 +190,7 @@ interface CompatibleConfig {
102
190
  settings?: SettingsConfig;
103
191
  }
104
192
  //#endregion
105
- //#region src/JsxConfig/JsxConfig.d.ts
106
- declare const JsxEmit: {
107
- readonly None: 0;
108
- readonly Preserve: 1;
109
- readonly React: 2;
110
- readonly ReactNative: 3;
111
- readonly ReactJSX: 4;
112
- readonly ReactJSXDev: 5;
113
- };
114
- interface JsxConfig {
115
- jsx?: number;
116
- jsxFactory?: string;
117
- jsxFragmentFactory?: string;
118
- jsxImportSource?: string;
119
- }
120
- /**
121
- * Create a JsxConfig object
122
- * @returns JsxConfig
123
- */
124
- declare function make$2(): JsxConfig;
125
- /**
126
- * Get JsxConfig from RuleContext
127
- * @param context The RuleContext
128
- * @returns JsxConfig
129
- */
130
- declare function getFromContext$1(context: RuleContext): {
131
- jsx: 4 | typescript0.JsxEmit;
132
- jsxFactory: string;
133
- jsxFragmentFactory: string;
134
- jsxImportSource: string;
135
- reactNamespace: string;
136
- };
137
- /**
138
- * Get JsxConfig from annotation
139
- * @param context The RuleContext
140
- * @returns JsxConfig
141
- */
142
- declare function getFromAnnotation(context: RuleContext): JsxConfig;
143
- declare namespace index_d_exports {
144
- export { JsxConfig, JsxEmit, getFromAnnotation, getFromContext$1 as getFromContext, make$2 as make };
145
- }
146
- //#endregion
147
- //#region src/LanguagePreference/LanguagePreferenceSchema.d.ts
148
- /**
149
- * @internal
150
- */
151
- declare const LanguagePreferenceSchema: z.ZodObject<{
152
- indentStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"tab">, z.ZodLiteral<"space">]>>;
153
- indentWidth: z.ZodOptional<z.ZodNumber>;
154
- quoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
155
- semicolons: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"asNeeded">]>>;
156
- trailingCommas: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodLiteral<"es5">, z.ZodLiteral<"none">]>>;
157
- jsxQuoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
158
- }, z.core.$strip>;
159
- //#endregion
160
- //#region src/LanguagePreference/LanguagePreference.d.ts
161
- /**
162
- * @internal
163
- */
164
- type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
165
- /**
166
- * Get a copy of the default LanguagePreference.
167
- */
168
- declare function make$1(): LanguagePreference;
169
- /**
170
- * A default LanguagePreference object.
171
- */
172
- declare const defaultLanguagePreference: {
173
- indentStyle?: "tab" | "space" | undefined;
174
- indentWidth?: number | undefined;
175
- quoteStyle?: "single" | "double" | undefined;
176
- semicolons?: "always" | "asNeeded" | undefined;
177
- trailingCommas?: "all" | "es5" | "none" | undefined;
178
- jsxQuoteStyle?: "single" | "double" | undefined;
179
- };
180
- declare function getFromContext(): void;
181
- declare module "@typescript-eslint/utils/ts-eslint" {
182
- interface SharedConfigurationSettings {}
183
- }
184
- declare namespace index_d_exports$1 {
185
- export { LanguagePreference, LanguagePreferenceSchema, defaultLanguagePreference, getFromContext, make$1 as make };
186
- }
187
- declare namespace RegExp_d_exports {
188
- export { ANNOTATION_JSX, ANNOTATION_JSX_FRAG, ANNOTATION_JSX_IMPORT_SOURCE, ANNOTATION_JSX_RUNTIME, CAMEL_CASE, COMPONENT_NAME, COMPONENT_NAME_LOOSE, CONSTANT_CASE, HOOK_NAME, HTML_TAG, JAVASCRIPT_PROTOCOL, JS_EXT, JS_IDENTIFIER, KEBAB_CASE, PASCAL_CASE, REGEXP_STR, SNAKE_CASE, TS_EXT, isRegExp, toRegExp };
189
- }
190
- /**
191
- * Regular expressions for matching a HTML tag name
192
- */
193
- declare const HTML_TAG: RegExp;
194
- /**
195
- * Regular expression for matching a TypeScript file extension.
196
- */
197
- declare const TS_EXT: RegExp;
198
- /**
199
- * Regular expression for matching a JavaScript file extension.
200
- */
201
- declare const JS_EXT: RegExp;
202
- /**
203
- * Regular expression for matching a PascalCase string.
204
- */
205
- declare const PASCAL_CASE: RegExp;
206
- /**
207
- * Regular expression for matching a camelCase string.
208
- */
209
- declare const CAMEL_CASE: RegExp;
210
- /**
211
- * Regular expression for matching a kebab-case string.
212
- */
213
- declare const KEBAB_CASE: RegExp;
214
- /**
215
- * Regular expression for matching a snake_case string.
216
- */
217
- declare const SNAKE_CASE: RegExp;
218
- /**
219
- * Regular expression for matching a CONSTANT_CASE string.
220
- */
221
- declare const CONSTANT_CASE: RegExp;
222
- declare const JAVASCRIPT_PROTOCOL: RegExp;
223
- /**
224
- * Regular expression for matching a valid JavaScript identifier.
225
- */
226
- declare const JS_IDENTIFIER: RegExp;
227
- /**
228
- * Regular expression for matching a RegExp string.
229
- */
230
- declare const REGEXP_STR: RegExp;
231
- /**
232
- * Regular expression for matching a `@jsx` annotation comment.
233
- */
234
- declare const ANNOTATION_JSX: RegExp;
235
- /**
236
- * Regular expression for matching a `@jsxFrag` annotation comment.
237
- */
238
- declare const ANNOTATION_JSX_FRAG: RegExp;
239
- /**
240
- * Regular expression for matching a `@jsxRuntime` annotation comment.
241
- */
242
- declare const ANNOTATION_JSX_RUNTIME: RegExp;
243
- /**
244
- * Regular expression for matching a `@jsxImportSource` annotation comment.
245
- */
246
- declare const ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
247
- /**
248
- * Regular expression for matching a React component name.
249
- */
250
- declare const COMPONENT_NAME: RegExp;
251
- /**
252
- * Regular expression for matching a React component name (loose).
253
- */
254
- declare const COMPONENT_NAME_LOOSE: RegExp;
255
- /**
256
- * Regular expression for matching a React Hook name.
257
- */
258
- declare const HOOK_NAME: RegExp;
193
+ //#region src/utils/regexp.d.ts
259
194
  /**
260
195
  * Convert a string to the `RegExp`.
261
196
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -273,44 +208,8 @@ declare function toRegExp(string: string): {
273
208
  * @returns boolean
274
209
  */
275
210
  declare function isRegExp(string: string): boolean;
276
- declare namespace Reporter_d_exports {
277
- export { Reporter, make, send, sendOrElse };
278
- }
279
- interface Reporter<TMessageID extends string> {
280
- send: (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
281
- sendOrElse: <TElse>(descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse) => unit | TElse;
282
- }
283
- declare const send: {
284
- <TMessageID extends string>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>): void;
285
- <TMessageID extends string>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
286
- };
287
- declare const sendOrElse: {
288
- <TMessageID extends string, TElse>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse): unit | TElse;
289
- <TMessageID extends string, TElse>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => (cb: () => TElse) => unit | TElse;
290
- };
291
- declare function make<TMessageID extends string>(context: RuleContext): Reporter<TMessageID>;
292
- declare namespace Selector_d_exports {
293
- export { DISPLAY_NAME_ASSIGNMENT_EXPRESSION, DisplayNameAssignmentExpression, IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, ImplicitReturnArrowFunctionExpression, OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, ObjectDestructuringVariableDeclarator };
294
- }
295
- type ImplicitReturnArrowFunctionExpression = TSESTree$1.ArrowFunctionExpression & {
296
- body: TSESTree$1.Expression;
297
- };
298
- type ObjectDestructuringVariableDeclarator = TSESTree$1.VariableDeclarator & {
299
- id: TSESTree$1.ObjectPattern;
300
- init: TSESTree$1.Identifier;
301
- };
302
- type DisplayNameAssignmentExpression = TSESTree$1.AssignmentExpression & {
303
- type: "AssignmentExpression";
304
- left: TSESTree$1.MemberExpression & {
305
- property: TSESTree$1.Identifier & {
306
- name: "displayName";
307
- };
308
- };
309
- operator: "=";
310
- right: TSESTree$1.Literal;
311
- };
312
- declare const IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
313
- declare const OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
314
- declare const DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
315
211
  //#endregion
316
- export { CompatibleConfig, CompatiblePlugin, CompatibleRule, ContextDetection_d_exports as ContextDetection, index_d_exports as JsxConfig, index_d_exports$1 as LanguagePreference, RegExp_d_exports as RegExp, Reporter_d_exports as Reporter, RuleConfig, RuleContext, RuleFeature, RulePolicy, RuleSuggest, Selector_d_exports as Selector, SettingsConfig, Severity, SeverityLevel, SeverityName };
212
+ //#region src/utils/reporting.d.ts
213
+ declare function report(context: RuleContext): (descriptor: unit | null | ReportDescriptor<string>) => void;
214
+ //#endregion
215
+ export { CompatibleConfig, CompatiblePlugin, CompatibleRule, DisplayNameAssignmentExpression, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, 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, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, SettingsConfig, Severity, SeverityLevel, SeverityName, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isRegExp, isViMock, isViMockCallback, report, toRegExp };
package/dist/index.js CHANGED
@@ -1,8 +1,32 @@
1
- import { __commonJS, __export, __toESM } from "./chunk-51aI8Tpl.js";
2
1
  import * as AST from "@eslint-react/ast";
3
- import { dual, getOrElseUpdate } from "@eslint-react/eff";
4
- import { z } from "zod/v4";
2
+ import "@eslint-react/eff";
5
3
 
4
+ //#region rolldown:runtime
5
+ var __create = Object.create;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __commonJS = (cb, mod) => function() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
+ key = keys[i];
17
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+
29
+ //#endregion
6
30
  //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js
7
31
  var require_ast_spec = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js": ((exports) => {
8
32
  /**********************************************
@@ -15,7 +39,6 @@ var require_ast_spec = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm
15
39
  * yarn build *
16
40
  **********************************************/
17
41
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.AST_TOKEN_TYPES = exports.AST_NODE_TYPES = void 0;
19
42
  var AST_NODE_TYPES;
20
43
  (function(AST_NODE_TYPES$1) {
21
44
  AST_NODE_TYPES$1["AccessorProperty"] = "AccessorProperty";
@@ -263,7 +286,6 @@ var require_ts_estree = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnp
263
286
  };
264
287
  })();
265
288
  Object.defineProperty(exports, "__esModule", { value: true });
266
- exports.TSESTree = void 0;
267
289
  exports.TSESTree = __importStar(require_ast_spec());
268
290
  }) });
269
291
 
@@ -308,14 +330,7 @@ var require_dist = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@ty
308
330
  }) });
309
331
 
310
332
  //#endregion
311
- //#region src/ContextDetection.ts
312
- var ContextDetection_exports = {};
313
- __export(ContextDetection_exports, {
314
- isProcessEnvNodeEnv: () => isProcessEnvNodeEnv,
315
- isProcessEnvNodeEnvCompare: () => isProcessEnvNodeEnvCompare,
316
- isViMock: () => isViMock,
317
- isViMockCallback: () => isViMockCallback
318
- });
333
+ //#region src/ast/env-checks.ts
319
334
  var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
320
335
  /**
321
336
  * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
@@ -326,7 +341,7 @@ function isProcessEnvNodeEnv(node) {
326
341
  return node != null && node.type === import_dist.AST_NODE_TYPES.MemberExpression && node.object.type === import_dist.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_dist.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_dist.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_dist.AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
327
342
  }
328
343
  /**
329
- * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
344
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
330
345
  * @param node The AST node
331
346
  * @param operator The operator used in the comparison
332
347
  * @param value The string literal value to compare against
@@ -360,99 +375,94 @@ function isViMockCallback(node) {
360
375
  }
361
376
 
362
377
  //#endregion
363
- //#region src/RegExp.ts
364
- var RegExp_exports = {};
365
- __export(RegExp_exports, {
366
- ANNOTATION_JSX: () => ANNOTATION_JSX,
367
- ANNOTATION_JSX_FRAG: () => ANNOTATION_JSX_FRAG,
368
- ANNOTATION_JSX_IMPORT_SOURCE: () => ANNOTATION_JSX_IMPORT_SOURCE,
369
- ANNOTATION_JSX_RUNTIME: () => ANNOTATION_JSX_RUNTIME,
370
- CAMEL_CASE: () => CAMEL_CASE,
371
- COMPONENT_NAME: () => COMPONENT_NAME,
372
- COMPONENT_NAME_LOOSE: () => COMPONENT_NAME_LOOSE,
373
- CONSTANT_CASE: () => CONSTANT_CASE,
374
- HOOK_NAME: () => HOOK_NAME,
375
- HTML_TAG: () => HTML_TAG,
376
- JAVASCRIPT_PROTOCOL: () => JAVASCRIPT_PROTOCOL,
377
- JS_EXT: () => JS_EXT,
378
- JS_IDENTIFIER: () => JS_IDENTIFIER,
379
- KEBAB_CASE: () => KEBAB_CASE,
380
- PASCAL_CASE: () => PASCAL_CASE,
381
- REGEXP_STR: () => REGEXP_STR,
382
- SNAKE_CASE: () => SNAKE_CASE,
383
- TS_EXT: () => TS_EXT,
384
- isRegExp: () => isRegExp,
385
- toRegExp: () => toRegExp
386
- });
378
+ //#region src/ast/selectors.ts
379
+ const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
380
+ const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
381
+ "VariableDeclarator",
382
+ "[id.type='ObjectPattern']",
383
+ "[init.type='Identifier']"
384
+ ].join("");
385
+ const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
386
+ "AssignmentExpression",
387
+ "[operator='=']",
388
+ "[left.type='MemberExpression']",
389
+ "[left.property.name='displayName']"
390
+ ].join("");
391
+
392
+ //#endregion
393
+ //#region src/constants.ts
387
394
  /**
388
395
  * Regular expressions for matching a HTML tag name
389
396
  */
390
- const HTML_TAG = /^[a-z][^-]*$/u;
397
+ const RE_HTML_TAG = /^[a-z][^-]*$/u;
391
398
  /**
392
399
  * Regular expression for matching a TypeScript file extension.
393
400
  */
394
- const TS_EXT = /^[cm]?tsx?$/u;
401
+ const RE_TS_EXT = /^[cm]?tsx?$/u;
395
402
  /**
396
403
  * Regular expression for matching a JavaScript file extension.
397
404
  */
398
- const JS_EXT = /^[cm]?jsx?$/u;
405
+ const RE_JS_EXT = /^[cm]?jsx?$/u;
399
406
  /**
400
407
  * Regular expression for matching a PascalCase string.
401
408
  */
402
- const PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
409
+ const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
403
410
  /**
404
411
  * Regular expression for matching a camelCase string.
405
412
  */
406
- const CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
413
+ const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
407
414
  /**
408
415
  * Regular expression for matching a kebab-case string.
409
416
  */
410
- const KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
417
+ const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
411
418
  /**
412
419
  * Regular expression for matching a snake_case string.
413
420
  */
414
- const SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
421
+ const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
415
422
  /**
416
423
  * Regular expression for matching a CONSTANT_CASE string.
417
424
  */
418
- const CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
419
- const 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;
425
+ const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
426
+ 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;
420
427
  /**
421
428
  * Regular expression for matching a valid JavaScript identifier.
422
429
  */
423
- const JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
430
+ const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
424
431
  /**
425
432
  * Regular expression for matching a RegExp string.
426
433
  */
427
- const REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
434
+ const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
428
435
  /**
429
436
  * Regular expression for matching a `@jsx` annotation comment.
430
437
  */
431
- const ANNOTATION_JSX = /@jsx\s+(\S+)/u;
438
+ const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
432
439
  /**
433
440
  * Regular expression for matching a `@jsxFrag` annotation comment.
434
441
  */
435
- const ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
442
+ const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
436
443
  /**
437
444
  * Regular expression for matching a `@jsxRuntime` annotation comment.
438
445
  */
439
- const ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
446
+ const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
440
447
  /**
441
448
  * Regular expression for matching a `@jsxImportSource` annotation comment.
442
449
  */
443
- const ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
450
+ const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
444
451
  /**
445
452
  * Regular expression for matching a React component name.
446
453
  */
447
- const COMPONENT_NAME = /^[A-Z]/u;
454
+ const RE_COMPONENT_NAME = /^[A-Z]/u;
448
455
  /**
449
456
  * Regular expression for matching a React component name (loose).
450
457
  */
451
- const COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
458
+ const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
452
459
  /**
453
460
  * Regular expression for matching a React Hook name.
454
461
  */
455
- const HOOK_NAME = /^use/u;
462
+ const RE_HOOK_NAME = /^use/u;
463
+
464
+ //#endregion
465
+ //#region src/utils/regexp.ts
456
466
  /**
457
467
  * Convert a string to the `RegExp`.
458
468
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -462,7 +472,7 @@ const HOOK_NAME = /^use/u;
462
472
  * @returns Returns the `RegExp`.
463
473
  */
464
474
  function toRegExp(string) {
465
- const [, pattern, flags = "u"] = REGEXP_STR.exec(string) ?? [];
475
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
466
476
  if (pattern != null) return new RegExp(pattern, flags);
467
477
  return { test: (s) => s === string };
468
478
  }
@@ -472,171 +482,17 @@ function toRegExp(string) {
472
482
  * @returns boolean
473
483
  */
474
484
  function isRegExp(string) {
475
- return REGEXP_STR.test(string);
485
+ return RE_REGEXP_STR.test(string);
476
486
  }
477
487
 
478
488
  //#endregion
479
- //#region src/JsxConfig/JsxConfig.ts
480
- const JsxEmit = {
481
- None: 0,
482
- Preserve: 1,
483
- React: 2,
484
- ReactNative: 3,
485
- ReactJSX: 4,
486
- ReactJSXDev: 5
487
- };
488
- /**
489
- * Create a JsxConfig object
490
- * @returns JsxConfig
491
- */
492
- function make$2() {
493
- return {};
494
- }
495
- /**
496
- * Get JsxConfig from RuleContext
497
- * @param context The RuleContext
498
- * @returns JsxConfig
499
- */
500
- function getFromContext$1(context) {
501
- const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
502
- return {
503
- jsx: options.jsx ?? JsxEmit.ReactJSX,
504
- jsxFactory: options.jsxFactory ?? "React.createElement",
505
- jsxFragmentFactory: options.jsxFragmentFactory ?? "React.Fragment",
506
- jsxImportSource: options.jsxImportSource ?? "react",
507
- reactNamespace: options.reactNamespace ?? "React"
489
+ //#region src/utils/reporting.ts
490
+ function report(context) {
491
+ return (descriptor) => {
492
+ if (descriptor == null) return;
493
+ return context.report(descriptor);
508
494
  };
509
495
  }
510
- const cache = /* @__PURE__ */ new WeakMap();
511
- /**
512
- * Get JsxConfig from annotation
513
- * @param context The RuleContext
514
- * @returns JsxConfig
515
- */
516
- function getFromAnnotation(context) {
517
- return getOrElseUpdate(cache, context.sourceCode, () => {
518
- const options = make$2();
519
- if (!context.sourceCode.text.includes("@jsx")) return options;
520
- let jsx, jsxFrag, jsxRuntime, jsxImportSource;
521
- for (const comment of context.sourceCode.getAllComments().reverse()) {
522
- const value = comment.value;
523
- jsx ??= value.match(ANNOTATION_JSX)?.[1];
524
- jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
525
- jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
526
- jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
527
- }
528
- if (jsx != null) options.jsxFactory = jsx;
529
- if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
530
- if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.React : JsxEmit.ReactJSX;
531
- if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
532
- return options;
533
- });
534
- }
535
-
536
- //#endregion
537
- //#region src/JsxConfig/index.ts
538
- var JsxConfig_exports = {};
539
- __export(JsxConfig_exports, {
540
- JsxEmit: () => JsxEmit,
541
- getFromAnnotation: () => getFromAnnotation,
542
- getFromContext: () => getFromContext$1,
543
- make: () => make$2
544
- });
545
-
546
- //#endregion
547
- //#region src/LanguagePreference/LanguagePreference.ts
548
- /**
549
- * Get a copy of the default LanguagePreference.
550
- */
551
- function make$1() {
552
- return {
553
- indentStyle: "space",
554
- indentWidth: 2,
555
- jsxQuoteStyle: "double",
556
- quoteStyle: "single",
557
- semicolons: "always",
558
- trailingCommas: "all"
559
- };
560
- }
561
- /**
562
- * A default LanguagePreference object.
563
- */
564
- const defaultLanguagePreference = make$1();
565
- function getFromContext() {
566
- throw new Error("getFromContext is not implemented");
567
- }
568
-
569
- //#endregion
570
- //#region src/LanguagePreference/LanguagePreferenceSchema.ts
571
- /**
572
- * @internal
573
- */
574
- const LanguagePreferenceSchema = z.object({
575
- indentStyle: z.optional(z.union([z.literal("tab"), z.literal("space")])),
576
- indentWidth: z.optional(z.number()),
577
- quoteStyle: z.optional(z.union([z.literal("single"), z.literal("double")])),
578
- semicolons: z.optional(z.union([z.literal("always"), z.literal("asNeeded")])),
579
- trailingCommas: z.optional(z.union([
580
- z.literal("all"),
581
- z.literal("es5"),
582
- z.literal("none")
583
- ])),
584
- jsxQuoteStyle: z.optional(z.union([z.literal("single"), z.literal("double")]))
585
- }, {});
586
-
587
- //#endregion
588
- //#region src/LanguagePreference/index.ts
589
- var LanguagePreference_exports = {};
590
- __export(LanguagePreference_exports, {
591
- LanguagePreferenceSchema: () => LanguagePreferenceSchema,
592
- defaultLanguagePreference: () => defaultLanguagePreference,
593
- getFromContext: () => getFromContext,
594
- make: () => make$1
595
- });
596
-
597
- //#endregion
598
- //#region src/Reporter.ts
599
- var Reporter_exports = {};
600
- __export(Reporter_exports, {
601
- make: () => make,
602
- send: () => send,
603
- sendOrElse: () => sendOrElse
604
- });
605
- const send = dual(2, (context, descriptor) => {
606
- if (descriptor == null) return;
607
- return context.report(descriptor);
608
- });
609
- const sendOrElse = dual(3, (context, descriptor, cb) => {
610
- if (descriptor == null) return cb();
611
- return context.report(descriptor);
612
- });
613
- function make(context) {
614
- return {
615
- send: (...args) => send(context, ...args),
616
- sendOrElse: (...args) => sendOrElse(context, ...args)
617
- };
618
- }
619
-
620
- //#endregion
621
- //#region src/Selector.ts
622
- var Selector_exports = {};
623
- __export(Selector_exports, {
624
- DISPLAY_NAME_ASSIGNMENT_EXPRESSION: () => DISPLAY_NAME_ASSIGNMENT_EXPRESSION,
625
- IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: () => IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION,
626
- OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: () => OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR
627
- });
628
- const IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
629
- const OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
630
- "VariableDeclarator",
631
- "[id.type='ObjectPattern']",
632
- "[init.type='Identifier']"
633
- ].join("");
634
- const DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
635
- "AssignmentExpression",
636
- "[operator='=']",
637
- "[left.type='MemberExpression']",
638
- "[left.property.name='displayName']"
639
- ].join("");
640
496
 
641
497
  //#endregion
642
- export { ContextDetection_exports as ContextDetection, JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RegExp_exports as RegExp, Reporter_exports as Reporter, Selector_exports as Selector };
498
+ 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, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isRegExp, isViMock, isViMockCallback, report, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "2.0.0-next.177",
3
+ "version": "2.0.0-next.179",
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": {
@@ -29,9 +29,9 @@
29
29
  "dependencies": {
30
30
  "@typescript-eslint/utils": "^8.43.0",
31
31
  "ts-pattern": "^5.8.0",
32
- "zod": "^4.1.5",
33
- "@eslint-react/eff": "2.0.0-next.177",
34
- "@eslint-react/ast": "2.0.0-next.177"
32
+ "zod": "^4.1.7",
33
+ "@eslint-react/ast": "2.0.0-next.179",
34
+ "@eslint-react/eff": "2.0.0-next.179"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsconfig/node22": "^22.0.2",
@@ -1,33 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
- key = keys[i];
20
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: ((k) => from[k]).bind(null, key),
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
24
- }
25
- return to;
26
- };
27
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
30
- }) : target, mod));
31
-
32
- //#endregion
33
- export { __commonJS, __export, __toESM };