@eslint-react/kit 2.0.0-next.18 → 2.0.0-next.181

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 +137 -200
  2. package/dist/index.js +482 -201
  3. package/package.json +9 -9
package/dist/index.d.ts CHANGED
@@ -1,185 +1,196 @@
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 * as z from '@zod/mini';
5
- import { _ } from '@eslint-react/eff';
6
- import { TSESTree } from '@typescript-eslint/utils';
1
+ import { unit } from "@eslint-react/eff";
2
+ import { TSESTree } from "@typescript-eslint/types";
3
+ import { TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
4
+ import * as tseslint from "@typescript-eslint/utils/ts-eslint";
5
+ import { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint";
7
6
 
7
+ //#region src/ast/env-checks.d.ts
8
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
9
+ * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
10
+ * @param node The AST node
11
+ * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
17
12
  */
18
- type RuleDeclaration = [RuleSeverity, Record<string, unknown>?] | RuleSeverity;
13
+ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
19
14
  /**
20
- * Rule config preset.
21
- * @since 0.0.1
15
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
16
+ * @param node The AST node
17
+ * @param operator The operator used in the comparison
18
+ * @param value The string literal value to compare against
19
+ * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
22
20
  */
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
-
36
- declare const JsxEmit: {
37
- readonly None: 0;
38
- readonly Preserve: 1;
39
- readonly React: 2;
40
- readonly ReactNative: 3;
41
- readonly ReactJSX: 4;
42
- readonly ReactJSXDev: 5;
43
- };
44
- interface JsxConfig {
45
- jsx?: number;
46
- jsxFactory?: string;
47
- jsxFragmentFactory?: string;
48
- jsxImportSource?: string;
49
- }
50
- /**
51
- * Create a JsxConfig object
52
- * @returns JsxConfig
53
- */
54
- declare function make$2(): JsxConfig;
55
- /**
56
- * Get JsxConfig from RuleContext
57
- * @param context The RuleContext
58
- * @returns JsxConfig
59
- */
60
- declare function getFromContext$1(context: RuleContext): {
61
- jsx: 4 | typescript.JsxEmit;
62
- jsxFactory: string;
63
- jsxFragmentFactory: string;
64
- jsxImportSource: string;
65
- reactNamespace: string;
66
- };
67
- /**
68
- * Get JsxConfig from annotation
69
- * @param context The RuleContext
70
- * @returns JsxConfig
71
- */
72
- declare function getFromAnnotation(context: RuleContext): JsxConfig;
73
-
74
- type index$1_JsxConfig = JsxConfig;
75
- declare const index$1_JsxEmit: typeof JsxEmit;
76
- declare const index$1_getFromAnnotation: typeof getFromAnnotation;
77
- declare namespace index$1 {
78
- 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 };
79
- }
80
-
21
+ declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
81
22
  /**
23
+ * Checks if the given node is a `vi.mock`.
24
+ * @param node The node to check
25
+ * @returns `true` if the node is a `vi.mock`, otherwise `false`.
82
26
  * @internal
83
27
  */
84
- declare const LanguagePreferenceSchema: z.ZodMiniObject<{
85
- indentStyle: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"tab">, z.ZodMiniLiteral<"space">]>>;
86
- indentWidth: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
87
- quoteStyle: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"single">, z.ZodMiniLiteral<"double">]>>;
88
- semicolons: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"always">, z.ZodMiniLiteral<"asNeeded">]>>;
89
- trailingCommas: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"all">, z.ZodMiniLiteral<"es5">, z.ZodMiniLiteral<"none">]>>;
90
- jsxQuoteStyle: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"single">, z.ZodMiniLiteral<"double">]>>;
91
- }, {}, {}>;
92
-
28
+ declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
93
29
  /**
30
+ * Checks if the given node is a `vi.mock` callback.
31
+ * @param node The node to check
32
+ * @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
94
33
  * @internal
95
34
  */
96
- type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
97
- /**
98
- * Get a copy of the default LanguagePreference.
99
- */
100
- declare function make$1(): LanguagePreference;
101
- declare function getFromContext(): void;
102
- declare module "@typescript-eslint/utils/ts-eslint" {
103
- interface SharedConfigurationSettings {
104
- }
105
- }
106
-
107
- type index_LanguagePreference = LanguagePreference;
108
- declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
109
- declare const index_getFromContext: typeof getFromContext;
110
- declare namespace index {
111
- export { type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_getFromContext as getFromContext, make$1 as make };
112
- }
113
-
35
+ declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
36
+ //#endregion
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
114
60
  /**
115
61
  * Regular expressions for matching a HTML tag name
116
62
  */
117
- declare const HTML_TAG: RegExp;
63
+ declare const RE_HTML_TAG: RegExp;
118
64
  /**
119
65
  * Regular expression for matching a TypeScript file extension.
120
66
  */
121
- declare const TS_EXT: RegExp;
67
+ declare const RE_TS_EXT: RegExp;
122
68
  /**
123
69
  * Regular expression for matching a JavaScript file extension.
124
70
  */
125
- declare const JS_EXT: RegExp;
71
+ declare const RE_JS_EXT: RegExp;
126
72
  /**
127
73
  * Regular expression for matching a PascalCase string.
128
74
  */
129
- declare const PASCAL_CASE: RegExp;
75
+ declare const RE_PASCAL_CASE: RegExp;
130
76
  /**
131
77
  * Regular expression for matching a camelCase string.
132
78
  */
133
- declare const CAMEL_CASE: RegExp;
79
+ declare const RE_CAMEL_CASE: RegExp;
134
80
  /**
135
81
  * Regular expression for matching a kebab-case string.
136
82
  */
137
- declare const KEBAB_CASE: RegExp;
83
+ declare const RE_KEBAB_CASE: RegExp;
138
84
  /**
139
85
  * Regular expression for matching a snake_case string.
140
86
  */
141
- declare const SNAKE_CASE: RegExp;
87
+ declare const RE_SNAKE_CASE: RegExp;
142
88
  /**
143
89
  * Regular expression for matching a CONSTANT_CASE string.
144
90
  */
145
- declare const CONSTANT_CASE: RegExp;
146
- declare const JAVASCRIPT_PROTOCOL: RegExp;
91
+ declare const RE_CONSTANT_CASE: RegExp;
92
+ declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
147
93
  /**
148
94
  * Regular expression for matching a valid JavaScript identifier.
149
95
  */
150
- declare const JS_IDENTIFIER: RegExp;
96
+ declare const RE_JS_IDENTIFIER: RegExp;
151
97
  /**
152
98
  * Regular expression for matching a RegExp string.
153
99
  */
154
- declare const REGEXP_STR: RegExp;
100
+ declare const RE_REGEXP_STR: RegExp;
155
101
  /**
156
102
  * Regular expression for matching a `@jsx` annotation comment.
157
103
  */
158
- declare const ANNOTATION_JSX: RegExp;
104
+ declare const RE_ANNOTATION_JSX: RegExp;
159
105
  /**
160
106
  * Regular expression for matching a `@jsxFrag` annotation comment.
161
107
  */
162
- declare const ANNOTATION_JSX_FRAG: RegExp;
108
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
163
109
  /**
164
110
  * Regular expression for matching a `@jsxRuntime` annotation comment.
165
111
  */
166
- declare const ANNOTATION_JSX_RUNTIME: RegExp;
112
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
167
113
  /**
168
114
  * Regular expression for matching a `@jsxImportSource` annotation comment.
169
115
  */
170
- declare const ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
116
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
171
117
  /**
172
118
  * Regular expression for matching a React component name.
173
119
  */
174
- declare const COMPONENT_NAME: RegExp;
120
+ declare const RE_COMPONENT_NAME: RegExp;
175
121
  /**
176
122
  * Regular expression for matching a React component name (loose).
177
123
  */
178
- declare const COMPONENT_NAME_LOOSE: RegExp;
124
+ declare const RE_COMPONENT_NAME_LOOSE: RegExp;
179
125
  /**
180
126
  * Regular expression for matching a React Hook name.
181
127
  */
182
- declare const HOOK_NAME: RegExp;
128
+ declare const RE_HOOK_NAME: RegExp;
129
+ //#endregion
130
+ //#region src/types/index.d.ts
131
+ /**
132
+ * Rule severity.
133
+ * @since 0.0.1
134
+ */
135
+ type SeverityName = "off" | "warn" | "error";
136
+ /**
137
+ * The numeric severity level for a rule.
138
+ *
139
+ * - `0` means off.
140
+ * - `1` means warn.
141
+ * - `2` means error.
142
+ */
143
+ type SeverityLevel = 0 | 1 | 2;
144
+ /**
145
+ * The severity of a rule in a configuration.
146
+ */
147
+ type Severity = SeverityName | SeverityLevel;
148
+ /**
149
+ * Rule declaration.
150
+ * @internal
151
+ * @since 0.0.1
152
+ */
153
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
154
+ /**
155
+ * Rule context.
156
+ * @since 0.0.1
157
+ */
158
+ type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
159
+ /**
160
+ * Rule feature.
161
+ * @since 1.20.0
162
+ */
163
+ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
164
+ type RulePolicy = number;
165
+ type RuleSuggest<MessageIds extends string = string> = {
166
+ messageId: MessageIds;
167
+ data?: Record<string, unknown>;
168
+ fix: tseslint.ReportFixFunction;
169
+ };
170
+ /**
171
+ * A collection of settings.
172
+ */
173
+ interface SettingsConfig {
174
+ [key: string]: unknown;
175
+ }
176
+ interface CompatibleRule {
177
+ meta: Record<string, any>;
178
+ create: (...args: any[]) => any;
179
+ }
180
+ interface CompatiblePlugin {
181
+ meta: {
182
+ name: string;
183
+ version: string;
184
+ };
185
+ rules: Record<string, CompatibleRule>;
186
+ }
187
+ interface CompatibleConfig {
188
+ name?: string;
189
+ rules?: Record<string, RuleConfig>;
190
+ settings?: SettingsConfig;
191
+ }
192
+ //#endregion
193
+ //#region src/utils/regexp.d.ts
183
194
  /**
184
195
  * Convert a string to the `RegExp`.
185
196
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
@@ -189,7 +200,7 @@ declare const HOOK_NAME: RegExp;
189
200
  * @returns Returns the `RegExp`.
190
201
  */
191
202
  declare function toRegExp(string: string): {
192
- test(s: string): boolean;
203
+ test(s: string): boolean;
193
204
  };
194
205
  /**
195
206
  * Checks whether given string is regexp string
@@ -197,82 +208,8 @@ declare function toRegExp(string: string): {
197
208
  * @returns boolean
198
209
  */
199
210
  declare function isRegExp(string: string): boolean;
200
-
201
- declare const RegExp$1_ANNOTATION_JSX: typeof ANNOTATION_JSX;
202
- declare const RegExp$1_ANNOTATION_JSX_FRAG: typeof ANNOTATION_JSX_FRAG;
203
- declare const RegExp$1_ANNOTATION_JSX_IMPORT_SOURCE: typeof ANNOTATION_JSX_IMPORT_SOURCE;
204
- declare const RegExp$1_ANNOTATION_JSX_RUNTIME: typeof ANNOTATION_JSX_RUNTIME;
205
- declare const RegExp$1_CAMEL_CASE: typeof CAMEL_CASE;
206
- declare const RegExp$1_COMPONENT_NAME: typeof COMPONENT_NAME;
207
- declare const RegExp$1_COMPONENT_NAME_LOOSE: typeof COMPONENT_NAME_LOOSE;
208
- declare const RegExp$1_CONSTANT_CASE: typeof CONSTANT_CASE;
209
- declare const RegExp$1_HOOK_NAME: typeof HOOK_NAME;
210
- declare const RegExp$1_HTML_TAG: typeof HTML_TAG;
211
- declare const RegExp$1_JAVASCRIPT_PROTOCOL: typeof JAVASCRIPT_PROTOCOL;
212
- declare const RegExp$1_JS_EXT: typeof JS_EXT;
213
- declare const RegExp$1_JS_IDENTIFIER: typeof JS_IDENTIFIER;
214
- declare const RegExp$1_KEBAB_CASE: typeof KEBAB_CASE;
215
- declare const RegExp$1_PASCAL_CASE: typeof PASCAL_CASE;
216
- declare const RegExp$1_REGEXP_STR: typeof REGEXP_STR;
217
- declare const RegExp$1_SNAKE_CASE: typeof SNAKE_CASE;
218
- declare const RegExp$1_TS_EXT: typeof TS_EXT;
219
- declare const RegExp$1_isRegExp: typeof isRegExp;
220
- declare const RegExp$1_toRegExp: typeof toRegExp;
221
- declare namespace RegExp$1 {
222
- 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 };
223
- }
224
-
225
- interface Reporter<TMessageID extends string> {
226
- send: (descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
227
- sendOrElse: <TElse>(descriptor: _ | null | ReportDescriptor<TMessageID>, cb: () => TElse) => _ | TElse;
228
- }
229
- declare const send: {
230
- <TMessageID extends string>(context: RuleContext, descriptor: _ | null | ReportDescriptor<TMessageID>): void;
231
- <TMessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
232
- };
233
- declare const sendOrElse: {
234
- <TMessageID extends string, TElse>(context: RuleContext, descriptor: _ | null | ReportDescriptor<TMessageID>, cb: () => TElse): _ | TElse;
235
- <TMessageID extends string, TElse>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<TMessageID>) => (cb: () => TElse) => _ | TElse;
236
- };
237
- declare function make<TMessageID extends string>(context: RuleContext): Reporter<TMessageID>;
238
-
239
- type Reporter$1_Reporter<TMessageID extends string> = Reporter<TMessageID>;
240
- declare const Reporter$1_make: typeof make;
241
- declare const Reporter$1_send: typeof send;
242
- declare const Reporter$1_sendOrElse: typeof sendOrElse;
243
- declare namespace Reporter$1 {
244
- export { type Reporter$1_Reporter as Reporter, Reporter$1_make as make, Reporter$1_send as send, Reporter$1_sendOrElse as sendOrElse };
245
- }
246
-
247
- type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
248
- body: TSESTree.Expression;
249
- };
250
- type ObjectDestructuringVariableDeclarator = TSESTree.VariableDeclarator & {
251
- id: TSESTree.ObjectPattern;
252
- init: TSESTree.Identifier;
253
- };
254
- type DisplayNameAssignmentExpression = TSESTree.AssignmentExpression & {
255
- type: "AssignmentExpression";
256
- left: TSESTree.MemberExpression & {
257
- property: TSESTree.Identifier & {
258
- name: "displayName";
259
- };
260
- };
261
- operator: "=";
262
- right: TSESTree.Literal;
263
- };
264
- declare const IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
265
- declare const OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
266
- declare const DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
267
-
268
- declare const Selector_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: typeof DISPLAY_NAME_ASSIGNMENT_EXPRESSION;
269
- type Selector_DisplayNameAssignmentExpression = DisplayNameAssignmentExpression;
270
- declare const Selector_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: typeof IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION;
271
- type Selector_ImplicitReturnArrowFunctionExpression = ImplicitReturnArrowFunctionExpression;
272
- declare const Selector_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: typeof OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR;
273
- type Selector_ObjectDestructuringVariableDeclarator = ObjectDestructuringVariableDeclarator;
274
- declare namespace Selector {
275
- 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 };
276
- }
277
-
278
- 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, Selector };
211
+ //#endregion
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,217 +1,498 @@
1
- import { dual, getOrElseUpdate } from '@eslint-react/eff';
2
- import * as z from '@zod/mini';
1
+ import * as AST from "@eslint-react/ast";
2
+ import "@eslint-react/eff";
3
3
 
4
+ //#region rolldown:runtime
5
+ var __create = Object.create;
4
6
  var __defProp = Object.defineProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
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;
8
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));
9
28
 
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
- });
29
+ //#endregion
30
+ //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js
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) => {
32
+ /**********************************************
33
+ * DO NOT MODIFY THIS FILE MANUALLY *
34
+ * *
35
+ * THIS FILE HAS BEEN COPIED FROM ast-spec. *
36
+ * ANY CHANGES WILL BE LOST ON THE NEXT BUILD *
37
+ * *
38
+ * MAKE CHANGES TO ast-spec AND THEN RUN *
39
+ * yarn build *
40
+ **********************************************/
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var AST_NODE_TYPES;
43
+ (function(AST_NODE_TYPES$1) {
44
+ AST_NODE_TYPES$1["AccessorProperty"] = "AccessorProperty";
45
+ AST_NODE_TYPES$1["ArrayExpression"] = "ArrayExpression";
46
+ AST_NODE_TYPES$1["ArrayPattern"] = "ArrayPattern";
47
+ AST_NODE_TYPES$1["ArrowFunctionExpression"] = "ArrowFunctionExpression";
48
+ AST_NODE_TYPES$1["AssignmentExpression"] = "AssignmentExpression";
49
+ AST_NODE_TYPES$1["AssignmentPattern"] = "AssignmentPattern";
50
+ AST_NODE_TYPES$1["AwaitExpression"] = "AwaitExpression";
51
+ AST_NODE_TYPES$1["BinaryExpression"] = "BinaryExpression";
52
+ AST_NODE_TYPES$1["BlockStatement"] = "BlockStatement";
53
+ AST_NODE_TYPES$1["BreakStatement"] = "BreakStatement";
54
+ AST_NODE_TYPES$1["CallExpression"] = "CallExpression";
55
+ AST_NODE_TYPES$1["CatchClause"] = "CatchClause";
56
+ AST_NODE_TYPES$1["ChainExpression"] = "ChainExpression";
57
+ AST_NODE_TYPES$1["ClassBody"] = "ClassBody";
58
+ AST_NODE_TYPES$1["ClassDeclaration"] = "ClassDeclaration";
59
+ AST_NODE_TYPES$1["ClassExpression"] = "ClassExpression";
60
+ AST_NODE_TYPES$1["ConditionalExpression"] = "ConditionalExpression";
61
+ AST_NODE_TYPES$1["ContinueStatement"] = "ContinueStatement";
62
+ AST_NODE_TYPES$1["DebuggerStatement"] = "DebuggerStatement";
63
+ AST_NODE_TYPES$1["Decorator"] = "Decorator";
64
+ AST_NODE_TYPES$1["DoWhileStatement"] = "DoWhileStatement";
65
+ AST_NODE_TYPES$1["EmptyStatement"] = "EmptyStatement";
66
+ AST_NODE_TYPES$1["ExportAllDeclaration"] = "ExportAllDeclaration";
67
+ AST_NODE_TYPES$1["ExportDefaultDeclaration"] = "ExportDefaultDeclaration";
68
+ AST_NODE_TYPES$1["ExportNamedDeclaration"] = "ExportNamedDeclaration";
69
+ AST_NODE_TYPES$1["ExportSpecifier"] = "ExportSpecifier";
70
+ AST_NODE_TYPES$1["ExpressionStatement"] = "ExpressionStatement";
71
+ AST_NODE_TYPES$1["ForInStatement"] = "ForInStatement";
72
+ AST_NODE_TYPES$1["ForOfStatement"] = "ForOfStatement";
73
+ AST_NODE_TYPES$1["ForStatement"] = "ForStatement";
74
+ AST_NODE_TYPES$1["FunctionDeclaration"] = "FunctionDeclaration";
75
+ AST_NODE_TYPES$1["FunctionExpression"] = "FunctionExpression";
76
+ AST_NODE_TYPES$1["Identifier"] = "Identifier";
77
+ AST_NODE_TYPES$1["IfStatement"] = "IfStatement";
78
+ AST_NODE_TYPES$1["ImportAttribute"] = "ImportAttribute";
79
+ AST_NODE_TYPES$1["ImportDeclaration"] = "ImportDeclaration";
80
+ AST_NODE_TYPES$1["ImportDefaultSpecifier"] = "ImportDefaultSpecifier";
81
+ AST_NODE_TYPES$1["ImportExpression"] = "ImportExpression";
82
+ AST_NODE_TYPES$1["ImportNamespaceSpecifier"] = "ImportNamespaceSpecifier";
83
+ AST_NODE_TYPES$1["ImportSpecifier"] = "ImportSpecifier";
84
+ AST_NODE_TYPES$1["JSXAttribute"] = "JSXAttribute";
85
+ AST_NODE_TYPES$1["JSXClosingElement"] = "JSXClosingElement";
86
+ AST_NODE_TYPES$1["JSXClosingFragment"] = "JSXClosingFragment";
87
+ AST_NODE_TYPES$1["JSXElement"] = "JSXElement";
88
+ AST_NODE_TYPES$1["JSXEmptyExpression"] = "JSXEmptyExpression";
89
+ AST_NODE_TYPES$1["JSXExpressionContainer"] = "JSXExpressionContainer";
90
+ AST_NODE_TYPES$1["JSXFragment"] = "JSXFragment";
91
+ AST_NODE_TYPES$1["JSXIdentifier"] = "JSXIdentifier";
92
+ AST_NODE_TYPES$1["JSXMemberExpression"] = "JSXMemberExpression";
93
+ AST_NODE_TYPES$1["JSXNamespacedName"] = "JSXNamespacedName";
94
+ AST_NODE_TYPES$1["JSXOpeningElement"] = "JSXOpeningElement";
95
+ AST_NODE_TYPES$1["JSXOpeningFragment"] = "JSXOpeningFragment";
96
+ AST_NODE_TYPES$1["JSXSpreadAttribute"] = "JSXSpreadAttribute";
97
+ AST_NODE_TYPES$1["JSXSpreadChild"] = "JSXSpreadChild";
98
+ AST_NODE_TYPES$1["JSXText"] = "JSXText";
99
+ AST_NODE_TYPES$1["LabeledStatement"] = "LabeledStatement";
100
+ AST_NODE_TYPES$1["Literal"] = "Literal";
101
+ AST_NODE_TYPES$1["LogicalExpression"] = "LogicalExpression";
102
+ AST_NODE_TYPES$1["MemberExpression"] = "MemberExpression";
103
+ AST_NODE_TYPES$1["MetaProperty"] = "MetaProperty";
104
+ AST_NODE_TYPES$1["MethodDefinition"] = "MethodDefinition";
105
+ AST_NODE_TYPES$1["NewExpression"] = "NewExpression";
106
+ AST_NODE_TYPES$1["ObjectExpression"] = "ObjectExpression";
107
+ AST_NODE_TYPES$1["ObjectPattern"] = "ObjectPattern";
108
+ AST_NODE_TYPES$1["PrivateIdentifier"] = "PrivateIdentifier";
109
+ AST_NODE_TYPES$1["Program"] = "Program";
110
+ AST_NODE_TYPES$1["Property"] = "Property";
111
+ AST_NODE_TYPES$1["PropertyDefinition"] = "PropertyDefinition";
112
+ AST_NODE_TYPES$1["RestElement"] = "RestElement";
113
+ AST_NODE_TYPES$1["ReturnStatement"] = "ReturnStatement";
114
+ AST_NODE_TYPES$1["SequenceExpression"] = "SequenceExpression";
115
+ AST_NODE_TYPES$1["SpreadElement"] = "SpreadElement";
116
+ AST_NODE_TYPES$1["StaticBlock"] = "StaticBlock";
117
+ AST_NODE_TYPES$1["Super"] = "Super";
118
+ AST_NODE_TYPES$1["SwitchCase"] = "SwitchCase";
119
+ AST_NODE_TYPES$1["SwitchStatement"] = "SwitchStatement";
120
+ AST_NODE_TYPES$1["TaggedTemplateExpression"] = "TaggedTemplateExpression";
121
+ AST_NODE_TYPES$1["TemplateElement"] = "TemplateElement";
122
+ AST_NODE_TYPES$1["TemplateLiteral"] = "TemplateLiteral";
123
+ AST_NODE_TYPES$1["ThisExpression"] = "ThisExpression";
124
+ AST_NODE_TYPES$1["ThrowStatement"] = "ThrowStatement";
125
+ AST_NODE_TYPES$1["TryStatement"] = "TryStatement";
126
+ AST_NODE_TYPES$1["UnaryExpression"] = "UnaryExpression";
127
+ AST_NODE_TYPES$1["UpdateExpression"] = "UpdateExpression";
128
+ AST_NODE_TYPES$1["VariableDeclaration"] = "VariableDeclaration";
129
+ AST_NODE_TYPES$1["VariableDeclarator"] = "VariableDeclarator";
130
+ AST_NODE_TYPES$1["WhileStatement"] = "WhileStatement";
131
+ AST_NODE_TYPES$1["WithStatement"] = "WithStatement";
132
+ AST_NODE_TYPES$1["YieldExpression"] = "YieldExpression";
133
+ AST_NODE_TYPES$1["TSAbstractAccessorProperty"] = "TSAbstractAccessorProperty";
134
+ AST_NODE_TYPES$1["TSAbstractKeyword"] = "TSAbstractKeyword";
135
+ AST_NODE_TYPES$1["TSAbstractMethodDefinition"] = "TSAbstractMethodDefinition";
136
+ AST_NODE_TYPES$1["TSAbstractPropertyDefinition"] = "TSAbstractPropertyDefinition";
137
+ AST_NODE_TYPES$1["TSAnyKeyword"] = "TSAnyKeyword";
138
+ AST_NODE_TYPES$1["TSArrayType"] = "TSArrayType";
139
+ AST_NODE_TYPES$1["TSAsExpression"] = "TSAsExpression";
140
+ AST_NODE_TYPES$1["TSAsyncKeyword"] = "TSAsyncKeyword";
141
+ AST_NODE_TYPES$1["TSBigIntKeyword"] = "TSBigIntKeyword";
142
+ AST_NODE_TYPES$1["TSBooleanKeyword"] = "TSBooleanKeyword";
143
+ AST_NODE_TYPES$1["TSCallSignatureDeclaration"] = "TSCallSignatureDeclaration";
144
+ AST_NODE_TYPES$1["TSClassImplements"] = "TSClassImplements";
145
+ AST_NODE_TYPES$1["TSConditionalType"] = "TSConditionalType";
146
+ AST_NODE_TYPES$1["TSConstructorType"] = "TSConstructorType";
147
+ AST_NODE_TYPES$1["TSConstructSignatureDeclaration"] = "TSConstructSignatureDeclaration";
148
+ AST_NODE_TYPES$1["TSDeclareFunction"] = "TSDeclareFunction";
149
+ AST_NODE_TYPES$1["TSDeclareKeyword"] = "TSDeclareKeyword";
150
+ AST_NODE_TYPES$1["TSEmptyBodyFunctionExpression"] = "TSEmptyBodyFunctionExpression";
151
+ AST_NODE_TYPES$1["TSEnumBody"] = "TSEnumBody";
152
+ AST_NODE_TYPES$1["TSEnumDeclaration"] = "TSEnumDeclaration";
153
+ AST_NODE_TYPES$1["TSEnumMember"] = "TSEnumMember";
154
+ AST_NODE_TYPES$1["TSExportAssignment"] = "TSExportAssignment";
155
+ AST_NODE_TYPES$1["TSExportKeyword"] = "TSExportKeyword";
156
+ AST_NODE_TYPES$1["TSExternalModuleReference"] = "TSExternalModuleReference";
157
+ AST_NODE_TYPES$1["TSFunctionType"] = "TSFunctionType";
158
+ AST_NODE_TYPES$1["TSImportEqualsDeclaration"] = "TSImportEqualsDeclaration";
159
+ AST_NODE_TYPES$1["TSImportType"] = "TSImportType";
160
+ AST_NODE_TYPES$1["TSIndexedAccessType"] = "TSIndexedAccessType";
161
+ AST_NODE_TYPES$1["TSIndexSignature"] = "TSIndexSignature";
162
+ AST_NODE_TYPES$1["TSInferType"] = "TSInferType";
163
+ AST_NODE_TYPES$1["TSInstantiationExpression"] = "TSInstantiationExpression";
164
+ AST_NODE_TYPES$1["TSInterfaceBody"] = "TSInterfaceBody";
165
+ AST_NODE_TYPES$1["TSInterfaceDeclaration"] = "TSInterfaceDeclaration";
166
+ AST_NODE_TYPES$1["TSInterfaceHeritage"] = "TSInterfaceHeritage";
167
+ AST_NODE_TYPES$1["TSIntersectionType"] = "TSIntersectionType";
168
+ AST_NODE_TYPES$1["TSIntrinsicKeyword"] = "TSIntrinsicKeyword";
169
+ AST_NODE_TYPES$1["TSLiteralType"] = "TSLiteralType";
170
+ AST_NODE_TYPES$1["TSMappedType"] = "TSMappedType";
171
+ AST_NODE_TYPES$1["TSMethodSignature"] = "TSMethodSignature";
172
+ AST_NODE_TYPES$1["TSModuleBlock"] = "TSModuleBlock";
173
+ AST_NODE_TYPES$1["TSModuleDeclaration"] = "TSModuleDeclaration";
174
+ AST_NODE_TYPES$1["TSNamedTupleMember"] = "TSNamedTupleMember";
175
+ AST_NODE_TYPES$1["TSNamespaceExportDeclaration"] = "TSNamespaceExportDeclaration";
176
+ AST_NODE_TYPES$1["TSNeverKeyword"] = "TSNeverKeyword";
177
+ AST_NODE_TYPES$1["TSNonNullExpression"] = "TSNonNullExpression";
178
+ AST_NODE_TYPES$1["TSNullKeyword"] = "TSNullKeyword";
179
+ AST_NODE_TYPES$1["TSNumberKeyword"] = "TSNumberKeyword";
180
+ AST_NODE_TYPES$1["TSObjectKeyword"] = "TSObjectKeyword";
181
+ AST_NODE_TYPES$1["TSOptionalType"] = "TSOptionalType";
182
+ AST_NODE_TYPES$1["TSParameterProperty"] = "TSParameterProperty";
183
+ AST_NODE_TYPES$1["TSPrivateKeyword"] = "TSPrivateKeyword";
184
+ AST_NODE_TYPES$1["TSPropertySignature"] = "TSPropertySignature";
185
+ AST_NODE_TYPES$1["TSProtectedKeyword"] = "TSProtectedKeyword";
186
+ AST_NODE_TYPES$1["TSPublicKeyword"] = "TSPublicKeyword";
187
+ AST_NODE_TYPES$1["TSQualifiedName"] = "TSQualifiedName";
188
+ AST_NODE_TYPES$1["TSReadonlyKeyword"] = "TSReadonlyKeyword";
189
+ AST_NODE_TYPES$1["TSRestType"] = "TSRestType";
190
+ AST_NODE_TYPES$1["TSSatisfiesExpression"] = "TSSatisfiesExpression";
191
+ AST_NODE_TYPES$1["TSStaticKeyword"] = "TSStaticKeyword";
192
+ AST_NODE_TYPES$1["TSStringKeyword"] = "TSStringKeyword";
193
+ AST_NODE_TYPES$1["TSSymbolKeyword"] = "TSSymbolKeyword";
194
+ AST_NODE_TYPES$1["TSTemplateLiteralType"] = "TSTemplateLiteralType";
195
+ AST_NODE_TYPES$1["TSThisType"] = "TSThisType";
196
+ AST_NODE_TYPES$1["TSTupleType"] = "TSTupleType";
197
+ AST_NODE_TYPES$1["TSTypeAliasDeclaration"] = "TSTypeAliasDeclaration";
198
+ AST_NODE_TYPES$1["TSTypeAnnotation"] = "TSTypeAnnotation";
199
+ AST_NODE_TYPES$1["TSTypeAssertion"] = "TSTypeAssertion";
200
+ AST_NODE_TYPES$1["TSTypeLiteral"] = "TSTypeLiteral";
201
+ AST_NODE_TYPES$1["TSTypeOperator"] = "TSTypeOperator";
202
+ AST_NODE_TYPES$1["TSTypeParameter"] = "TSTypeParameter";
203
+ AST_NODE_TYPES$1["TSTypeParameterDeclaration"] = "TSTypeParameterDeclaration";
204
+ AST_NODE_TYPES$1["TSTypeParameterInstantiation"] = "TSTypeParameterInstantiation";
205
+ AST_NODE_TYPES$1["TSTypePredicate"] = "TSTypePredicate";
206
+ AST_NODE_TYPES$1["TSTypeQuery"] = "TSTypeQuery";
207
+ AST_NODE_TYPES$1["TSTypeReference"] = "TSTypeReference";
208
+ AST_NODE_TYPES$1["TSUndefinedKeyword"] = "TSUndefinedKeyword";
209
+ AST_NODE_TYPES$1["TSUnionType"] = "TSUnionType";
210
+ AST_NODE_TYPES$1["TSUnknownKeyword"] = "TSUnknownKeyword";
211
+ AST_NODE_TYPES$1["TSVoidKeyword"] = "TSVoidKeyword";
212
+ })(AST_NODE_TYPES || (exports.AST_NODE_TYPES = AST_NODE_TYPES = {}));
213
+ var AST_TOKEN_TYPES;
214
+ (function(AST_TOKEN_TYPES$1) {
215
+ AST_TOKEN_TYPES$1["Boolean"] = "Boolean";
216
+ AST_TOKEN_TYPES$1["Identifier"] = "Identifier";
217
+ AST_TOKEN_TYPES$1["JSXIdentifier"] = "JSXIdentifier";
218
+ AST_TOKEN_TYPES$1["PrivateIdentifier"] = "PrivateIdentifier";
219
+ AST_TOKEN_TYPES$1["JSXText"] = "JSXText";
220
+ AST_TOKEN_TYPES$1["Keyword"] = "Keyword";
221
+ AST_TOKEN_TYPES$1["Null"] = "Null";
222
+ AST_TOKEN_TYPES$1["Numeric"] = "Numeric";
223
+ AST_TOKEN_TYPES$1["Punctuator"] = "Punctuator";
224
+ AST_TOKEN_TYPES$1["RegularExpression"] = "RegularExpression";
225
+ AST_TOKEN_TYPES$1["String"] = "String";
226
+ AST_TOKEN_TYPES$1["Template"] = "Template";
227
+ AST_TOKEN_TYPES$1["Block"] = "Block";
228
+ AST_TOKEN_TYPES$1["Line"] = "Line";
229
+ })(AST_TOKEN_TYPES || (exports.AST_TOKEN_TYPES = AST_TOKEN_TYPES = {}));
230
+ }) });
18
231
 
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;
61
- 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 };
65
- }
66
- function isRegExp(string) {
67
- return Boolean(REGEXP_STR.test(string));
68
- }
232
+ //#endregion
233
+ //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/lib.js
234
+ var require_lib = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/lib.js": ((exports) => {
235
+ Object.defineProperty(exports, "__esModule", { value: true });
236
+ }) });
69
237
 
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 {};
238
+ //#endregion
239
+ //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/parser-options.js
240
+ var require_parser_options = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/parser-options.js": ((exports) => {
241
+ Object.defineProperty(exports, "__esModule", { value: true });
242
+ }) });
243
+
244
+ //#endregion
245
+ //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/ts-estree.js
246
+ var require_ts_estree = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/ts-estree.js": ((exports) => {
247
+ var __createBinding$1 = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
248
+ if (k2 === void 0) k2 = k;
249
+ var desc = Object.getOwnPropertyDescriptor(m, k);
250
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
251
+ enumerable: true,
252
+ get: function() {
253
+ return m[k];
254
+ }
255
+ };
256
+ Object.defineProperty(o, k2, desc);
257
+ }) : (function(o, m, k, k2) {
258
+ if (k2 === void 0) k2 = k;
259
+ o[k2] = m[k];
260
+ }));
261
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
262
+ Object.defineProperty(o, "default", {
263
+ enumerable: true,
264
+ value: v
265
+ });
266
+ }) : function(o, v) {
267
+ o["default"] = v;
268
+ });
269
+ var __importStar = exports && exports.__importStar || (function() {
270
+ var ownKeys = function(o) {
271
+ ownKeys = Object.getOwnPropertyNames || function(o$1) {
272
+ var ar = [];
273
+ for (var k in o$1) if (Object.prototype.hasOwnProperty.call(o$1, k)) ar[ar.length] = k;
274
+ return ar;
275
+ };
276
+ return ownKeys(o);
277
+ };
278
+ return function(mod) {
279
+ if (mod && mod.__esModule) return mod;
280
+ var result = {};
281
+ if (mod != null) {
282
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding$1(result, mod, k[i]);
283
+ }
284
+ __setModuleDefault(result, mod);
285
+ return result;
286
+ };
287
+ })();
288
+ Object.defineProperty(exports, "__esModule", { value: true });
289
+ exports.TSESTree = __importStar(require_ast_spec());
290
+ }) });
291
+
292
+ //#endregion
293
+ //#region ../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/index.js
294
+ var require_dist = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@typescript-eslint+types@8.43.0/node_modules/@typescript-eslint/types/dist/index.js": ((exports) => {
295
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
296
+ if (k2 === void 0) k2 = k;
297
+ var desc = Object.getOwnPropertyDescriptor(m, k);
298
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
299
+ enumerable: true,
300
+ get: function() {
301
+ return m[k];
302
+ }
303
+ };
304
+ Object.defineProperty(o, k2, desc);
305
+ }) : (function(o, m, k, k2) {
306
+ if (k2 === void 0) k2 = k;
307
+ o[k2] = m[k];
308
+ }));
309
+ var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
310
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
311
+ };
312
+ Object.defineProperty(exports, "__esModule", { value: true });
313
+ exports.AST_TOKEN_TYPES = exports.AST_NODE_TYPES = void 0;
314
+ var ast_spec_1 = require_ast_spec();
315
+ Object.defineProperty(exports, "AST_NODE_TYPES", {
316
+ enumerable: true,
317
+ get: function() {
318
+ return ast_spec_1.AST_NODE_TYPES;
319
+ }
320
+ });
321
+ Object.defineProperty(exports, "AST_TOKEN_TYPES", {
322
+ enumerable: true,
323
+ get: function() {
324
+ return ast_spec_1.AST_TOKEN_TYPES;
325
+ }
326
+ });
327
+ __exportStar(require_lib(), exports);
328
+ __exportStar(require_parser_options(), exports);
329
+ __exportStar(require_ts_estree(), exports);
330
+ }) });
331
+
332
+ //#endregion
333
+ //#region src/ast/env-checks.ts
334
+ var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
335
+ /**
336
+ * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
337
+ * @param node The AST node
338
+ * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
339
+ */
340
+ function isProcessEnvNodeEnv(node) {
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";
81
342
  }
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
- };
343
+ /**
344
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
345
+ * @param node The AST node
346
+ * @param operator The operator used in the comparison
347
+ * @param value The string literal value to compare against
348
+ * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
349
+ */
350
+ function isProcessEnvNodeEnvCompare(node, operator, value) {
351
+ if (node == null) return false;
352
+ if (node.type !== import_dist.AST_NODE_TYPES.BinaryExpression) return false;
353
+ if (node.operator !== operator) return false;
354
+ if (isProcessEnvNodeEnv(node.left) && AST.isLiteral(node.right, "string")) return node.right.value === value;
355
+ if (AST.isLiteral(node.left, "string") && isProcessEnvNodeEnv(node.right)) return node.left.value === value;
356
+ return false;
91
357
  }
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
- );
358
+ /**
359
+ * Checks if the given node is a `vi.mock`.
360
+ * @param node The node to check
361
+ * @returns `true` if the node is a `vi.mock`, otherwise `false`.
362
+ * @internal
363
+ */
364
+ function isViMock(node) {
365
+ return node != null && node.type === import_dist.AST_NODE_TYPES.MemberExpression && node.object.type === import_dist.AST_NODE_TYPES.Identifier && node.object.name === "vi" && node.property.type === import_dist.AST_NODE_TYPES.Identifier && node.property.name === "mock";
366
+ }
367
+ /**
368
+ * Checks if the given node is a `vi.mock` callback.
369
+ * @param node The node to check
370
+ * @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
371
+ * @internal
372
+ */
373
+ function isViMockCallback(node) {
374
+ return node != null && AST.isFunction(node) && node.parent.type === import_dist.AST_NODE_TYPES.CallExpression && isViMock(node.parent.callee) && node.parent.arguments[1] === node;
115
375
  }
116
376
 
117
- // src/LanguagePreference/index.ts
118
- var LanguagePreference_exports = {};
119
- __export(LanguagePreference_exports, {
120
- LanguagePreferenceSchema: () => LanguagePreferenceSchema,
121
- getFromContext: () => getFromContext2,
122
- make: () => make2
123
- });
377
+ //#endregion
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("");
124
391
 
125
- // src/LanguagePreference/LanguagePreference.ts
126
- function make2() {
127
- return {
128
- indentStyle: "space",
129
- indentWidth: 2,
130
- jsxQuoteStyle: "double",
131
- quoteStyle: "single",
132
- semicolons: "always",
133
- trailingCommas: "all"
134
- };
392
+ //#endregion
393
+ //#region src/constants.ts
394
+ /**
395
+ * Regular expressions for matching a HTML tag name
396
+ */
397
+ const RE_HTML_TAG = /^[a-z][^-]*$/u;
398
+ /**
399
+ * Regular expression for matching a TypeScript file extension.
400
+ */
401
+ const RE_TS_EXT = /^[cm]?tsx?$/u;
402
+ /**
403
+ * Regular expression for matching a JavaScript file extension.
404
+ */
405
+ const RE_JS_EXT = /^[cm]?jsx?$/u;
406
+ /**
407
+ * Regular expression for matching a PascalCase string.
408
+ */
409
+ const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
410
+ /**
411
+ * Regular expression for matching a camelCase string.
412
+ */
413
+ const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
414
+ /**
415
+ * Regular expression for matching a kebab-case string.
416
+ */
417
+ const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
418
+ /**
419
+ * Regular expression for matching a snake_case string.
420
+ */
421
+ const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
422
+ /**
423
+ * Regular expression for matching a CONSTANT_CASE string.
424
+ */
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;
427
+ /**
428
+ * Regular expression for matching a valid JavaScript identifier.
429
+ */
430
+ const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
431
+ /**
432
+ * Regular expression for matching a RegExp string.
433
+ */
434
+ const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
435
+ /**
436
+ * Regular expression for matching a `@jsx` annotation comment.
437
+ */
438
+ const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
439
+ /**
440
+ * Regular expression for matching a `@jsxFrag` annotation comment.
441
+ */
442
+ const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
443
+ /**
444
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
445
+ */
446
+ const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
447
+ /**
448
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
449
+ */
450
+ const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
451
+ /**
452
+ * Regular expression for matching a React component name.
453
+ */
454
+ const RE_COMPONENT_NAME = /^[A-Z]/u;
455
+ /**
456
+ * Regular expression for matching a React component name (loose).
457
+ */
458
+ const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
459
+ /**
460
+ * Regular expression for matching a React Hook name.
461
+ */
462
+ const RE_HOOK_NAME = /^use/u;
463
+
464
+ //#endregion
465
+ //#region src/utils/regexp.ts
466
+ /**
467
+ * Convert a string to the `RegExp`.
468
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
469
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
470
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
471
+ * @param string The string to convert.
472
+ * @returns Returns the `RegExp`.
473
+ */
474
+ function toRegExp(string) {
475
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
476
+ if (pattern != null) return new RegExp(pattern, flags);
477
+ return { test: (s) => s === string };
135
478
  }
136
- function getFromContext2() {
137
- throw new Error("getFromContext is not implemented");
479
+ /**
480
+ * Checks whether given string is regexp string
481
+ * @param string The string to check
482
+ * @returns boolean
483
+ */
484
+ function isRegExp(string) {
485
+ return RE_REGEXP_STR.test(string);
138
486
  }
139
- var LanguagePreferenceSchema = z.object({
140
- indentStyle: z.optional(
141
- z.union([
142
- z.literal("tab"),
143
- z.literal("space")
144
- ])
145
- ),
146
- indentWidth: z.optional(z.number()),
147
- quoteStyle: z.optional(
148
- z.union([
149
- z.literal("single"),
150
- z.literal("double")
151
- ])
152
- ),
153
- semicolons: z.optional(
154
- z.union([
155
- z.literal("always"),
156
- z.literal("asNeeded")
157
- ])
158
- ),
159
- trailingCommas: z.optional(
160
- z.union([
161
- z.literal("all"),
162
- z.literal("es5"),
163
- z.literal("none")
164
- ])
165
- ),
166
- // JSX specific options
167
- jsxQuoteStyle: z.optional(
168
- z.union([
169
- z.literal("single"),
170
- z.literal("double")
171
- ])
172
- )
173
- }, {});
174
487
 
175
- // src/Reporter.ts
176
- var Reporter_exports = {};
177
- __export(Reporter_exports, {
178
- make: () => make3,
179
- send: () => send,
180
- sendOrElse: () => sendOrElse
181
- });
182
- var send = dual(2, (context, descriptor) => {
183
- if (descriptor == null) return;
184
- return context.report(descriptor);
185
- });
186
- var sendOrElse = dual(3, (context, descriptor, cb) => {
187
- if (descriptor == null) return cb();
188
- return context.report(descriptor);
189
- });
190
- function make3(context) {
191
- return {
192
- send: (...args) => send(context, ...args),
193
- sendOrElse: (...args) => sendOrElse(context, ...args)
194
- };
488
+ //#endregion
489
+ //#region src/utils/reporting.ts
490
+ function report(context) {
491
+ return (descriptor) => {
492
+ if (descriptor == null) return;
493
+ return context.report(descriptor);
494
+ };
195
495
  }
196
496
 
197
- // src/Selector.ts
198
- var Selector_exports = {};
199
- __export(Selector_exports, {
200
- DISPLAY_NAME_ASSIGNMENT_EXPRESSION: () => DISPLAY_NAME_ASSIGNMENT_EXPRESSION,
201
- IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: () => IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION,
202
- OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: () => OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR
203
- });
204
- var IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
205
- var OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
206
- "VariableDeclarator",
207
- "[id.type='ObjectPattern']",
208
- "[init.type='Identifier']"
209
- ].join("");
210
- var DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
211
- "AssignmentExpression",
212
- "[operator='=']",
213
- "[left.type='MemberExpression']",
214
- "[left.property.name='displayName']"
215
- ].join("");
216
-
217
- export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RegExp_exports as RegExp, Reporter_exports as Reporter, Selector_exports as Selector };
497
+ //#endregion
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.18",
3
+ "version": "2.0.0-next.181",
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,23 @@
27
27
  "./package.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@typescript-eslint/utils": "^8.32.0",
31
- "@zod/mini": "^4.0.0-beta.20250505T195954",
32
- "ts-pattern": "^5.7.0",
33
- "@eslint-react/eff": "2.0.0-next.18"
30
+ "@typescript-eslint/utils": "^8.43.0",
31
+ "ts-pattern": "^5.8.0",
32
+ "zod": "^4.1.8",
33
+ "@eslint-react/ast": "2.0.0-next.181",
34
+ "@eslint-react/eff": "2.0.0-next.181"
34
35
  },
35
36
  "devDependencies": {
36
- "@tsconfig/node22": "^22.0.1",
37
- "tsup": "^8.4.0",
37
+ "@tsconfig/node22": "^22.0.2",
38
+ "tsdown": "^0.15.1",
38
39
  "type-fest": "^4.41.0",
39
40
  "@local/configs": "0.0.0"
40
41
  },
41
42
  "engines": {
42
- "bun": ">=1.0.15",
43
43
  "node": ">=20.19.0"
44
44
  },
45
45
  "scripts": {
46
- "build": "tsup",
46
+ "build": "tsdown --dts-resolve",
47
47
  "build:docs": "typedoc",
48
48
  "lint:publish": "publint",
49
49
  "lint:ts": "tsc --noEmit"