@eslint-react/kit 1.52.3-next.8 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -31,6 +31,12 @@ type RuleContext<MessageIds extends string = string, Options extends readonly un
31
31
  * @since 1.20.0
32
32
  */
33
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
+ };
34
40
 
35
41
  declare const JsxEmit: {
36
42
  readonly None: 0;
@@ -286,4 +292,4 @@ declare namespace Selector {
286
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 };
287
293
  }
288
294
 
289
- export { index$1 as JsxConfig, index as LanguagePreference, RegExp$1 as RegExp, Reporter$1 as Reporter, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, Selector };
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 };
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- var eff = require('@eslint-react/eff');
4
- var v4 = require('zod/v4');
1
+ import { dual, getOrElseUpdate } from '@eslint-react/eff';
2
+ import { z } from 'zod/v4';
5
3
 
6
4
  var __defProp = Object.defineProperty;
7
5
  var __export = (target, all) => {
@@ -93,7 +91,7 @@ function getFromContext(context) {
93
91
  }
94
92
  var cache = /* @__PURE__ */ new WeakMap();
95
93
  function getFromAnnotation(context) {
96
- return eff.getOrElseUpdate(
94
+ return getOrElseUpdate(
97
95
  cache,
98
96
  context.sourceCode,
99
97
  () => {
@@ -140,38 +138,38 @@ var defaultLanguagePreference = make2();
140
138
  function getFromContext2() {
141
139
  throw new Error("getFromContext is not implemented");
142
140
  }
143
- var LanguagePreferenceSchema = v4.z.object({
144
- indentStyle: v4.z.optional(
145
- v4.z.union([
146
- v4.z.literal("tab"),
147
- v4.z.literal("space")
141
+ var LanguagePreferenceSchema = z.object({
142
+ indentStyle: z.optional(
143
+ z.union([
144
+ z.literal("tab"),
145
+ z.literal("space")
148
146
  ])
149
147
  ),
150
- indentWidth: v4.z.optional(v4.z.number()),
151
- quoteStyle: v4.z.optional(
152
- v4.z.union([
153
- v4.z.literal("single"),
154
- v4.z.literal("double")
148
+ indentWidth: z.optional(z.number()),
149
+ quoteStyle: z.optional(
150
+ z.union([
151
+ z.literal("single"),
152
+ z.literal("double")
155
153
  ])
156
154
  ),
157
- semicolons: v4.z.optional(
158
- v4.z.union([
159
- v4.z.literal("always"),
160
- v4.z.literal("asNeeded")
155
+ semicolons: z.optional(
156
+ z.union([
157
+ z.literal("always"),
158
+ z.literal("asNeeded")
161
159
  ])
162
160
  ),
163
- trailingCommas: v4.z.optional(
164
- v4.z.union([
165
- v4.z.literal("all"),
166
- v4.z.literal("es5"),
167
- v4.z.literal("none")
161
+ trailingCommas: z.optional(
162
+ z.union([
163
+ z.literal("all"),
164
+ z.literal("es5"),
165
+ z.literal("none")
168
166
  ])
169
167
  ),
170
168
  // JSX specific options
171
- jsxQuoteStyle: v4.z.optional(
172
- v4.z.union([
173
- v4.z.literal("single"),
174
- v4.z.literal("double")
169
+ jsxQuoteStyle: z.optional(
170
+ z.union([
171
+ z.literal("single"),
172
+ z.literal("double")
175
173
  ])
176
174
  )
177
175
  }, {});
@@ -183,11 +181,11 @@ __export(Reporter_exports, {
183
181
  send: () => send,
184
182
  sendOrElse: () => sendOrElse
185
183
  });
186
- var send = eff.dual(2, (context, descriptor) => {
184
+ var send = dual(2, (context, descriptor) => {
187
185
  if (descriptor == null) return;
188
186
  return context.report(descriptor);
189
187
  });
190
- var sendOrElse = eff.dual(3, (context, descriptor, cb) => {
188
+ var sendOrElse = dual(3, (context, descriptor, cb) => {
191
189
  if (descriptor == null) return cb();
192
190
  return context.report(descriptor);
193
191
  });
@@ -218,8 +216,4 @@ var DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
218
216
  "[left.property.name='displayName']"
219
217
  ].join("");
220
218
 
221
- exports.JsxConfig = JsxConfig_exports;
222
- exports.LanguagePreference = LanguagePreference_exports;
223
- exports.RegExp = RegExp_exports;
224
- exports.Reporter = Reporter_exports;
225
- exports.Selector = Selector_exports;
219
+ export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RegExp_exports as RegExp, Reporter_exports as Reporter, Selector_exports as Selector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "1.52.3-next.8",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "ESLint React's plugin kit for building plugins and rules.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -14,22 +14,14 @@
14
14
  "license": "MIT",
15
15
  "author": "Rel1cx<rel1cx@proton.me>",
16
16
  "sideEffects": false,
17
+ "type": "module",
17
18
  "exports": {
18
19
  ".": {
19
- "import": {
20
- "types": "./dist/index.d.mts",
21
- "default": "./dist/index.mjs"
22
- },
23
- "require": {
24
- "types": "./dist/index.d.ts",
25
- "default": "./dist/index.js"
26
- }
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
27
22
  },
28
23
  "./package.json": "./package.json"
29
24
  },
30
- "main": "dist/index.js",
31
- "module": "dist/index.mjs",
32
- "types": "dist/index.d.ts",
33
25
  "files": [
34
26
  "dist",
35
27
  "./package.json"
@@ -38,7 +30,7 @@
38
30
  "@typescript-eslint/utils": "^8.35.0",
39
31
  "ts-pattern": "^5.7.1",
40
32
  "zod": "^3.25.67",
41
- "@eslint-react/eff": "1.52.3-next.8"
33
+ "@eslint-react/eff": "2.0.0-beta.0"
42
34
  },
43
35
  "devDependencies": {
44
36
  "@tsconfig/node22": "^22.0.2",
@@ -48,7 +40,7 @@
48
40
  },
49
41
  "engines": {
50
42
  "bun": ">=1.0.15",
51
- "node": ">=18.18.0"
43
+ "node": ">=20.19.0"
52
44
  },
53
45
  "scripts": {
54
46
  "build": "tsup",
package/dist/index.d.mts DELETED
@@ -1,289 +0,0 @@
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
-
35
- declare const JsxEmit: {
36
- readonly None: 0;
37
- readonly Preserve: 1;
38
- readonly React: 2;
39
- readonly ReactNative: 3;
40
- readonly ReactJSX: 4;
41
- readonly ReactJSXDev: 5;
42
- };
43
- interface JsxConfig {
44
- jsx?: number;
45
- jsxFactory?: string;
46
- jsxFragmentFactory?: string;
47
- jsxImportSource?: string;
48
- }
49
- /**
50
- * Create a JsxConfig object
51
- * @returns JsxConfig
52
- */
53
- declare function make$2(): JsxConfig;
54
- /**
55
- * Get JsxConfig from RuleContext
56
- * @param context The RuleContext
57
- * @returns JsxConfig
58
- */
59
- declare function getFromContext$1(context: RuleContext): {
60
- jsx: 4 | typescript.JsxEmit;
61
- jsxFactory: string;
62
- jsxFragmentFactory: string;
63
- jsxImportSource: string;
64
- reactNamespace: string;
65
- };
66
- /**
67
- * Get JsxConfig from annotation
68
- * @param context The RuleContext
69
- * @returns JsxConfig
70
- */
71
- declare function getFromAnnotation(context: RuleContext): JsxConfig;
72
-
73
- type index$1_JsxConfig = JsxConfig;
74
- declare const index$1_JsxEmit: typeof JsxEmit;
75
- declare const index$1_getFromAnnotation: typeof getFromAnnotation;
76
- declare namespace index$1 {
77
- 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 };
78
- }
79
-
80
- /**
81
- * @internal
82
- */
83
- declare const LanguagePreferenceSchema: z.ZodObject<{
84
- indentStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"tab">, z.ZodLiteral<"space">]>>;
85
- indentWidth: z.ZodOptional<z.ZodNumber>;
86
- quoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
87
- semicolons: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"asNeeded">]>>;
88
- trailingCommas: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodLiteral<"es5">, z.ZodLiteral<"none">]>>;
89
- jsxQuoteStyle: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"single">, z.ZodLiteral<"double">]>>;
90
- }, z.core.$strip>;
91
-
92
- /**
93
- * @internal
94
- */
95
- type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
96
- /**
97
- * Get a copy of the default LanguagePreference.
98
- */
99
- declare function make$1(): LanguagePreference;
100
- /**
101
- * A default LanguagePreference object.
102
- */
103
- declare const defaultLanguagePreference: {
104
- indentStyle?: "tab" | "space" | undefined;
105
- indentWidth?: number | undefined;
106
- quoteStyle?: "single" | "double" | undefined;
107
- semicolons?: "always" | "asNeeded" | undefined;
108
- trailingCommas?: "all" | "es5" | "none" | undefined;
109
- jsxQuoteStyle?: "single" | "double" | undefined;
110
- };
111
- declare function getFromContext(): void;
112
- declare module "@typescript-eslint/utils/ts-eslint" {
113
- interface SharedConfigurationSettings {
114
- }
115
- }
116
-
117
- type index_LanguagePreference = LanguagePreference;
118
- declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
119
- declare const index_defaultLanguagePreference: typeof defaultLanguagePreference;
120
- declare const index_getFromContext: typeof getFromContext;
121
- declare namespace index {
122
- export { type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_defaultLanguagePreference as defaultLanguagePreference, index_getFromContext as getFromContext, make$1 as make };
123
- }
124
-
125
- /**
126
- * Regular expressions for matching a HTML tag name
127
- */
128
- declare const HTML_TAG: RegExp;
129
- /**
130
- * Regular expression for matching a TypeScript file extension.
131
- */
132
- declare const TS_EXT: RegExp;
133
- /**
134
- * Regular expression for matching a JavaScript file extension.
135
- */
136
- declare const JS_EXT: RegExp;
137
- /**
138
- * Regular expression for matching a PascalCase string.
139
- */
140
- declare const PASCAL_CASE: RegExp;
141
- /**
142
- * Regular expression for matching a camelCase string.
143
- */
144
- declare const CAMEL_CASE: RegExp;
145
- /**
146
- * Regular expression for matching a kebab-case string.
147
- */
148
- declare const KEBAB_CASE: RegExp;
149
- /**
150
- * Regular expression for matching a snake_case string.
151
- */
152
- declare const SNAKE_CASE: RegExp;
153
- /**
154
- * Regular expression for matching a CONSTANT_CASE string.
155
- */
156
- declare const CONSTANT_CASE: RegExp;
157
- declare const JAVASCRIPT_PROTOCOL: RegExp;
158
- /**
159
- * Regular expression for matching a valid JavaScript identifier.
160
- */
161
- declare const JS_IDENTIFIER: RegExp;
162
- /**
163
- * Regular expression for matching a RegExp string.
164
- */
165
- declare const REGEXP_STR: RegExp;
166
- /**
167
- * Regular expression for matching a `@jsx` annotation comment.
168
- */
169
- declare const ANNOTATION_JSX: RegExp;
170
- /**
171
- * Regular expression for matching a `@jsxFrag` annotation comment.
172
- */
173
- declare const ANNOTATION_JSX_FRAG: RegExp;
174
- /**
175
- * Regular expression for matching a `@jsxRuntime` annotation comment.
176
- */
177
- declare const ANNOTATION_JSX_RUNTIME: RegExp;
178
- /**
179
- * Regular expression for matching a `@jsxImportSource` annotation comment.
180
- */
181
- declare const ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
182
- /**
183
- * Regular expression for matching a React component name.
184
- */
185
- declare const COMPONENT_NAME: RegExp;
186
- /**
187
- * Regular expression for matching a React component name (loose).
188
- */
189
- declare const COMPONENT_NAME_LOOSE: RegExp;
190
- /**
191
- * Regular expression for matching a React Hook name.
192
- */
193
- declare const HOOK_NAME: RegExp;
194
- /**
195
- * Convert a string to the `RegExp`.
196
- * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
197
- * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
198
- * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
199
- * @param string The string to convert.
200
- * @returns Returns the `RegExp`.
201
- */
202
- declare function toRegExp(string: string): {
203
- test(s: string): boolean;
204
- };
205
- /**
206
- * Checks whether given string is regexp string
207
- * @param string The string to check
208
- * @returns boolean
209
- */
210
- declare function isRegExp(string: string): boolean;
211
-
212
- declare const RegExp$1_ANNOTATION_JSX: typeof ANNOTATION_JSX;
213
- declare const RegExp$1_ANNOTATION_JSX_FRAG: typeof ANNOTATION_JSX_FRAG;
214
- declare const RegExp$1_ANNOTATION_JSX_IMPORT_SOURCE: typeof ANNOTATION_JSX_IMPORT_SOURCE;
215
- declare const RegExp$1_ANNOTATION_JSX_RUNTIME: typeof ANNOTATION_JSX_RUNTIME;
216
- declare const RegExp$1_CAMEL_CASE: typeof CAMEL_CASE;
217
- declare const RegExp$1_COMPONENT_NAME: typeof COMPONENT_NAME;
218
- declare const RegExp$1_COMPONENT_NAME_LOOSE: typeof COMPONENT_NAME_LOOSE;
219
- declare const RegExp$1_CONSTANT_CASE: typeof CONSTANT_CASE;
220
- declare const RegExp$1_HOOK_NAME: typeof HOOK_NAME;
221
- declare const RegExp$1_HTML_TAG: typeof HTML_TAG;
222
- declare const RegExp$1_JAVASCRIPT_PROTOCOL: typeof JAVASCRIPT_PROTOCOL;
223
- declare const RegExp$1_JS_EXT: typeof JS_EXT;
224
- declare const RegExp$1_JS_IDENTIFIER: typeof JS_IDENTIFIER;
225
- declare const RegExp$1_KEBAB_CASE: typeof KEBAB_CASE;
226
- declare const RegExp$1_PASCAL_CASE: typeof PASCAL_CASE;
227
- declare const RegExp$1_REGEXP_STR: typeof REGEXP_STR;
228
- declare const RegExp$1_SNAKE_CASE: typeof SNAKE_CASE;
229
- declare const RegExp$1_TS_EXT: typeof TS_EXT;
230
- declare const RegExp$1_isRegExp: typeof isRegExp;
231
- declare const RegExp$1_toRegExp: typeof toRegExp;
232
- declare namespace RegExp$1 {
233
- 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 };
234
- }
235
-
236
- interface Reporter<TMessageID extends string> {
237
- send: (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
238
- sendOrElse: <TElse>(descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse) => unit | TElse;
239
- }
240
- declare const send: {
241
- <TMessageID extends string>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>): void;
242
- <TMessageID extends string>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => void;
243
- };
244
- declare const sendOrElse: {
245
- <TMessageID extends string, TElse>(context: RuleContext, descriptor: unit | null | ReportDescriptor<TMessageID>, cb: () => TElse): unit | TElse;
246
- <TMessageID extends string, TElse>(context: RuleContext): (descriptor: unit | null | ReportDescriptor<TMessageID>) => (cb: () => TElse) => unit | TElse;
247
- };
248
- declare function make<TMessageID extends string>(context: RuleContext): Reporter<TMessageID>;
249
-
250
- type Reporter$1_Reporter<TMessageID extends string> = Reporter<TMessageID>;
251
- declare const Reporter$1_make: typeof make;
252
- declare const Reporter$1_send: typeof send;
253
- declare const Reporter$1_sendOrElse: typeof sendOrElse;
254
- declare namespace Reporter$1 {
255
- export { type Reporter$1_Reporter as Reporter, Reporter$1_make as make, Reporter$1_send as send, Reporter$1_sendOrElse as sendOrElse };
256
- }
257
-
258
- type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
259
- body: TSESTree.Expression;
260
- };
261
- type ObjectDestructuringVariableDeclarator = TSESTree.VariableDeclarator & {
262
- id: TSESTree.ObjectPattern;
263
- init: TSESTree.Identifier;
264
- };
265
- type DisplayNameAssignmentExpression = TSESTree.AssignmentExpression & {
266
- type: "AssignmentExpression";
267
- left: TSESTree.MemberExpression & {
268
- property: TSESTree.Identifier & {
269
- name: "displayName";
270
- };
271
- };
272
- operator: "=";
273
- right: TSESTree.Literal;
274
- };
275
- declare const IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
276
- declare const OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
277
- declare const DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
278
-
279
- declare const Selector_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: typeof DISPLAY_NAME_ASSIGNMENT_EXPRESSION;
280
- type Selector_DisplayNameAssignmentExpression = DisplayNameAssignmentExpression;
281
- declare const Selector_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION: typeof IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION;
282
- type Selector_ImplicitReturnArrowFunctionExpression = ImplicitReturnArrowFunctionExpression;
283
- declare const Selector_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: typeof OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR;
284
- type Selector_ObjectDestructuringVariableDeclarator = ObjectDestructuringVariableDeclarator;
285
- declare namespace Selector {
286
- 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 };
287
- }
288
-
289
- export { index$1 as JsxConfig, index as LanguagePreference, RegExp$1 as RegExp, Reporter$1 as Reporter, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, Selector };
package/dist/index.mjs DELETED
@@ -1,219 +0,0 @@
1
- import { dual, getOrElseUpdate } from '@eslint-react/eff';
2
- import { z } from 'zod/v4';
3
-
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
- };
9
-
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;
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
- }
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
- );
115
- }
116
-
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");
140
- }
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
-
219
- export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RegExp_exports as RegExp, Reporter_exports as Reporter, Selector_exports as Selector };