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