@eslint-react/kit 1.45.3 → 1.45.4-beta.5
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.mts +26 -37
- package/dist/index.d.ts +26 -37
- package/dist/index.js +99 -67
- package/dist/index.mjs +79 -67
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { _ } from '@eslint-react/eff';
|
|
2
1
|
import * as tseslint from '@typescript-eslint/utils/ts-eslint';
|
|
3
2
|
import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
|
|
4
3
|
import { CompilerOptions, JsxEmit } from 'typescript';
|
|
5
|
-
import * as
|
|
6
|
-
import {
|
|
4
|
+
import * as z from '@zod/mini';
|
|
5
|
+
import { _ } from '@eslint-react/eff';
|
|
7
6
|
import { TSESTree } from '@typescript-eslint/utils';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -33,19 +32,12 @@ type RuleContext<MessageIds extends string = string, Options extends readonly un
|
|
|
33
32
|
*/
|
|
34
33
|
type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
* Creates a report function that can conditionally report a descriptor.
|
|
38
|
-
* @param context - The context of the rule
|
|
39
|
-
* @returns A function that takes a descriptor and reports it if it's not null or undefined
|
|
40
|
-
*/
|
|
41
|
-
declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
|
|
42
|
-
|
|
43
35
|
type JsxConfig = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
44
36
|
/**
|
|
45
37
|
* Create a JsxConfig object
|
|
46
38
|
* @returns JsxConfig
|
|
47
39
|
*/
|
|
48
|
-
declare function make$
|
|
40
|
+
declare function make$2(): JsxConfig;
|
|
49
41
|
/**
|
|
50
42
|
* Get JsxConfig from RuleContext
|
|
51
43
|
* @param context The RuleContext
|
|
@@ -68,53 +60,40 @@ declare function getFromAnnotation(context: RuleContext): JsxConfig;
|
|
|
68
60
|
type index$1_JsxConfig = JsxConfig;
|
|
69
61
|
declare const index$1_getFromAnnotation: typeof getFromAnnotation;
|
|
70
62
|
declare namespace index$1 {
|
|
71
|
-
export { type index$1_JsxConfig as JsxConfig, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$
|
|
63
|
+
export { type index$1_JsxConfig as JsxConfig, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$2 as make };
|
|
72
64
|
}
|
|
73
65
|
|
|
74
66
|
/**
|
|
75
67
|
* @internal
|
|
76
68
|
*/
|
|
77
|
-
declare const LanguagePreferenceSchema:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
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
|
+
}, {}>;
|
|
85
77
|
|
|
86
78
|
/**
|
|
87
79
|
* @internal
|
|
88
80
|
*/
|
|
89
|
-
type LanguagePreference =
|
|
90
|
-
/**
|
|
91
|
-
* The default language preference.
|
|
92
|
-
*/
|
|
93
|
-
declare const DEFAULT_LANGUAGE_PREFERENCE: {
|
|
94
|
-
readonly indentStyle: "space";
|
|
95
|
-
readonly indentWidth: 2;
|
|
96
|
-
readonly jsxQuoteStyle: "double";
|
|
97
|
-
readonly quoteStyle: "single";
|
|
98
|
-
readonly semicolons: "always";
|
|
99
|
-
readonly trailingCommas: "all";
|
|
100
|
-
};
|
|
81
|
+
type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
|
|
101
82
|
/**
|
|
102
83
|
* Get a copy of the default LanguagePreference.
|
|
103
84
|
*/
|
|
104
|
-
declare function make(): LanguagePreference;
|
|
85
|
+
declare function make$1(): LanguagePreference;
|
|
105
86
|
declare function getFromContext(): void;
|
|
106
87
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
107
88
|
interface SharedConfigurationSettings {
|
|
108
89
|
}
|
|
109
90
|
}
|
|
110
91
|
|
|
111
|
-
declare const index_DEFAULT_LANGUAGE_PREFERENCE: typeof DEFAULT_LANGUAGE_PREFERENCE;
|
|
112
92
|
type index_LanguagePreference = LanguagePreference;
|
|
113
93
|
declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
|
|
114
94
|
declare const index_getFromContext: typeof getFromContext;
|
|
115
|
-
declare const index_make: typeof make;
|
|
116
95
|
declare namespace index {
|
|
117
|
-
export {
|
|
96
|
+
export { type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_getFromContext as getFromContext, make$1 as make };
|
|
118
97
|
}
|
|
119
98
|
|
|
120
99
|
/**
|
|
@@ -223,6 +202,16 @@ declare namespace RE {
|
|
|
223
202
|
export { RE_ANNOTATION_JSX as ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG as ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE as ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME as ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE as CAMEL_CASE, RE_COMPONENT_NAME as COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE as COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE as CONSTANT_CASE, RE_HOOK_NAME as HOOK_NAME, RE_JAVASCRIPT_PROTOCOL as JAVASCRIPT_PROTOCOL, RE_JS_EXT as JS_EXT, RE_JS_IDENTIFIER as JS_IDENTIFIER, RE_KEBAB_CASE as KEBAB_CASE, RE_PASCAL_CASE as PASCAL_CASE, RE_REGEXP_STR as REGEXP_STR, RE_SNAKE_CASE as SNAKE_CASE, RE_TS_EXT as TS_EXT, RE_isRegExp as isRegExp, RE_toRegExp as toRegExp };
|
|
224
203
|
}
|
|
225
204
|
|
|
205
|
+
declare function make<TMessageID extends string>(context: RuleContext<TMessageID>): {
|
|
206
|
+
readonly send: (descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
|
|
207
|
+
readonly sendOrElse: <TElse>(descriptor: _ | null | ReportDescriptor<TMessageID>, fallback: () => TElse) => void | TElse;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
declare const Report_make: typeof make;
|
|
211
|
+
declare namespace Report {
|
|
212
|
+
export { Report_make as make };
|
|
213
|
+
}
|
|
214
|
+
|
|
226
215
|
type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
|
|
227
216
|
body: TSESTree.Expression;
|
|
228
217
|
};
|
|
@@ -254,4 +243,4 @@ declare namespace SEL {
|
|
|
254
243
|
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION as DISPLAY_NAME_ASSIGNMENT_EXPRESSION, type SEL_DisplayNameAssignmentExpression as DisplayNameAssignmentExpression, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION as IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, type SEL_ImplicitReturnArrowFunctionExpression as ImplicitReturnArrowFunctionExpression, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR as OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, type SEL_ObjectDestructuringVariableDeclarator as ObjectDestructuringVariableDeclarator };
|
|
255
244
|
}
|
|
256
245
|
|
|
257
|
-
export { index$1 as JsxConfig, index as LanguagePreference, RE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, SEL
|
|
246
|
+
export { index$1 as JsxConfig, index as LanguagePreference, RE, Report, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, SEL };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { _ } from '@eslint-react/eff';
|
|
2
1
|
import * as tseslint from '@typescript-eslint/utils/ts-eslint';
|
|
3
2
|
import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
|
|
4
3
|
import { CompilerOptions, JsxEmit } from 'typescript';
|
|
5
|
-
import * as
|
|
6
|
-
import {
|
|
4
|
+
import * as z from '@zod/mini';
|
|
5
|
+
import { _ } from '@eslint-react/eff';
|
|
7
6
|
import { TSESTree } from '@typescript-eslint/utils';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -33,19 +32,12 @@ type RuleContext<MessageIds extends string = string, Options extends readonly un
|
|
|
33
32
|
*/
|
|
34
33
|
type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
* Creates a report function that can conditionally report a descriptor.
|
|
38
|
-
* @param context - The context of the rule
|
|
39
|
-
* @returns A function that takes a descriptor and reports it if it's not null or undefined
|
|
40
|
-
*/
|
|
41
|
-
declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
|
|
42
|
-
|
|
43
35
|
type JsxConfig = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
|
|
44
36
|
/**
|
|
45
37
|
* Create a JsxConfig object
|
|
46
38
|
* @returns JsxConfig
|
|
47
39
|
*/
|
|
48
|
-
declare function make$
|
|
40
|
+
declare function make$2(): JsxConfig;
|
|
49
41
|
/**
|
|
50
42
|
* Get JsxConfig from RuleContext
|
|
51
43
|
* @param context The RuleContext
|
|
@@ -68,53 +60,40 @@ declare function getFromAnnotation(context: RuleContext): JsxConfig;
|
|
|
68
60
|
type index$1_JsxConfig = JsxConfig;
|
|
69
61
|
declare const index$1_getFromAnnotation: typeof getFromAnnotation;
|
|
70
62
|
declare namespace index$1 {
|
|
71
|
-
export { type index$1_JsxConfig as JsxConfig, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$
|
|
63
|
+
export { type index$1_JsxConfig as JsxConfig, index$1_getFromAnnotation as getFromAnnotation, getFromContext$1 as getFromContext, make$2 as make };
|
|
72
64
|
}
|
|
73
65
|
|
|
74
66
|
/**
|
|
75
67
|
* @internal
|
|
76
68
|
*/
|
|
77
|
-
declare const LanguagePreferenceSchema:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
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
|
+
}, {}>;
|
|
85
77
|
|
|
86
78
|
/**
|
|
87
79
|
* @internal
|
|
88
80
|
*/
|
|
89
|
-
type LanguagePreference =
|
|
90
|
-
/**
|
|
91
|
-
* The default language preference.
|
|
92
|
-
*/
|
|
93
|
-
declare const DEFAULT_LANGUAGE_PREFERENCE: {
|
|
94
|
-
readonly indentStyle: "space";
|
|
95
|
-
readonly indentWidth: 2;
|
|
96
|
-
readonly jsxQuoteStyle: "double";
|
|
97
|
-
readonly quoteStyle: "single";
|
|
98
|
-
readonly semicolons: "always";
|
|
99
|
-
readonly trailingCommas: "all";
|
|
100
|
-
};
|
|
81
|
+
type LanguagePreference = z.infer<typeof LanguagePreferenceSchema>;
|
|
101
82
|
/**
|
|
102
83
|
* Get a copy of the default LanguagePreference.
|
|
103
84
|
*/
|
|
104
|
-
declare function make(): LanguagePreference;
|
|
85
|
+
declare function make$1(): LanguagePreference;
|
|
105
86
|
declare function getFromContext(): void;
|
|
106
87
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
107
88
|
interface SharedConfigurationSettings {
|
|
108
89
|
}
|
|
109
90
|
}
|
|
110
91
|
|
|
111
|
-
declare const index_DEFAULT_LANGUAGE_PREFERENCE: typeof DEFAULT_LANGUAGE_PREFERENCE;
|
|
112
92
|
type index_LanguagePreference = LanguagePreference;
|
|
113
93
|
declare const index_LanguagePreferenceSchema: typeof LanguagePreferenceSchema;
|
|
114
94
|
declare const index_getFromContext: typeof getFromContext;
|
|
115
|
-
declare const index_make: typeof make;
|
|
116
95
|
declare namespace index {
|
|
117
|
-
export {
|
|
96
|
+
export { type index_LanguagePreference as LanguagePreference, index_LanguagePreferenceSchema as LanguagePreferenceSchema, index_getFromContext as getFromContext, make$1 as make };
|
|
118
97
|
}
|
|
119
98
|
|
|
120
99
|
/**
|
|
@@ -223,6 +202,16 @@ declare namespace RE {
|
|
|
223
202
|
export { RE_ANNOTATION_JSX as ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG as ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE as ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME as ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE as CAMEL_CASE, RE_COMPONENT_NAME as COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE as COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE as CONSTANT_CASE, RE_HOOK_NAME as HOOK_NAME, RE_JAVASCRIPT_PROTOCOL as JAVASCRIPT_PROTOCOL, RE_JS_EXT as JS_EXT, RE_JS_IDENTIFIER as JS_IDENTIFIER, RE_KEBAB_CASE as KEBAB_CASE, RE_PASCAL_CASE as PASCAL_CASE, RE_REGEXP_STR as REGEXP_STR, RE_SNAKE_CASE as SNAKE_CASE, RE_TS_EXT as TS_EXT, RE_isRegExp as isRegExp, RE_toRegExp as toRegExp };
|
|
224
203
|
}
|
|
225
204
|
|
|
205
|
+
declare function make<TMessageID extends string>(context: RuleContext<TMessageID>): {
|
|
206
|
+
readonly send: (descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
|
|
207
|
+
readonly sendOrElse: <TElse>(descriptor: _ | null | ReportDescriptor<TMessageID>, fallback: () => TElse) => void | TElse;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
declare const Report_make: typeof make;
|
|
211
|
+
declare namespace Report {
|
|
212
|
+
export { Report_make as make };
|
|
213
|
+
}
|
|
214
|
+
|
|
226
215
|
type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
|
|
227
216
|
body: TSESTree.Expression;
|
|
228
217
|
};
|
|
@@ -254,4 +243,4 @@ declare namespace SEL {
|
|
|
254
243
|
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION as DISPLAY_NAME_ASSIGNMENT_EXPRESSION, type SEL_DisplayNameAssignmentExpression as DisplayNameAssignmentExpression, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION as IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, type SEL_ImplicitReturnArrowFunctionExpression as ImplicitReturnArrowFunctionExpression, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR as OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, type SEL_ObjectDestructuringVariableDeclarator as ObjectDestructuringVariableDeclarator };
|
|
255
244
|
}
|
|
256
245
|
|
|
257
|
-
export { index$1 as JsxConfig, index as LanguagePreference, RE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, SEL
|
|
246
|
+
export { index$1 as JsxConfig, index as LanguagePreference, RE, Report, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, SEL };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var eff = require('@eslint-react/eff');
|
|
3
4
|
var typescript = require('typescript');
|
|
4
|
-
var
|
|
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);
|
|
5
26
|
|
|
6
27
|
var __defProp = Object.defineProperty;
|
|
7
28
|
var __export = (target, all) => {
|
|
@@ -9,13 +30,6 @@ var __export = (target, all) => {
|
|
|
9
30
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
31
|
};
|
|
11
32
|
|
|
12
|
-
// src/helpers.ts
|
|
13
|
-
function createReport(context) {
|
|
14
|
-
return (descriptor) => {
|
|
15
|
-
if (descriptor != null) context.report(descriptor);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
33
|
// src/JsxConfig/index.ts
|
|
20
34
|
var JsxConfig_exports = {};
|
|
21
35
|
__export(JsxConfig_exports, {
|
|
@@ -87,88 +101,106 @@ function getFromContext(context) {
|
|
|
87
101
|
reactNamespace: options.reactNamespace ?? "React"
|
|
88
102
|
};
|
|
89
103
|
}
|
|
104
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
90
105
|
function getFromAnnotation(context) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
return eff.getOrElseUpdate(
|
|
107
|
+
cache,
|
|
108
|
+
context.sourceCode,
|
|
109
|
+
() => {
|
|
110
|
+
const options = make();
|
|
111
|
+
if (!context.sourceCode.text.includes("@jsx")) return options;
|
|
112
|
+
let jsx, jsxFrag, jsxRuntime, jsxImportSource;
|
|
113
|
+
for (const comment of context.sourceCode.getAllComments().reverse()) {
|
|
114
|
+
const value = comment.value;
|
|
115
|
+
jsx ??= value.match(ANNOTATION_JSX)?.[1];
|
|
116
|
+
jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
|
|
117
|
+
jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
|
|
118
|
+
jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
|
|
119
|
+
}
|
|
120
|
+
if (jsx != null) options.jsxFactory = jsx;
|
|
121
|
+
if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
|
|
122
|
+
if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? typescript.JsxEmit.React : typescript.JsxEmit.ReactJSX;
|
|
123
|
+
if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
|
|
124
|
+
return options;
|
|
125
|
+
}
|
|
126
|
+
);
|
|
106
127
|
}
|
|
107
128
|
|
|
108
129
|
// src/LanguagePreference/index.ts
|
|
109
130
|
var LanguagePreference_exports = {};
|
|
110
131
|
__export(LanguagePreference_exports, {
|
|
111
|
-
DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
|
|
112
132
|
LanguagePreferenceSchema: () => LanguagePreferenceSchema,
|
|
113
133
|
getFromContext: () => getFromContext2,
|
|
114
134
|
make: () => make2
|
|
115
135
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
indentWidth: 2,
|
|
119
|
-
jsxQuoteStyle: "double",
|
|
120
|
-
quoteStyle: "single",
|
|
121
|
-
semicolons: "always",
|
|
122
|
-
trailingCommas: "all"
|
|
123
|
-
};
|
|
136
|
+
|
|
137
|
+
// src/LanguagePreference/LanguagePreference.ts
|
|
124
138
|
function make2() {
|
|
125
139
|
return {
|
|
126
|
-
|
|
140
|
+
indentStyle: "space",
|
|
141
|
+
indentWidth: 2,
|
|
142
|
+
jsxQuoteStyle: "double",
|
|
143
|
+
quoteStyle: "single",
|
|
144
|
+
semicolons: "always",
|
|
145
|
+
trailingCommas: "all"
|
|
127
146
|
};
|
|
128
147
|
}
|
|
129
148
|
function getFromContext2() {
|
|
130
149
|
throw new Error("getFromContext is not implemented");
|
|
131
150
|
}
|
|
132
|
-
var LanguagePreferenceSchema =
|
|
133
|
-
indentStyle:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
])
|
|
138
|
-
"space"
|
|
151
|
+
var LanguagePreferenceSchema = z__namespace.object({
|
|
152
|
+
indentStyle: z__namespace.optional(
|
|
153
|
+
z__namespace.union([
|
|
154
|
+
z__namespace.literal("tab"),
|
|
155
|
+
z__namespace.literal("space")
|
|
156
|
+
])
|
|
139
157
|
),
|
|
140
|
-
indentWidth:
|
|
141
|
-
quoteStyle:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
])
|
|
146
|
-
"single"
|
|
158
|
+
indentWidth: z__namespace.optional(z__namespace.number()),
|
|
159
|
+
quoteStyle: z__namespace.optional(
|
|
160
|
+
z__namespace.union([
|
|
161
|
+
z__namespace.literal("single"),
|
|
162
|
+
z__namespace.literal("double")
|
|
163
|
+
])
|
|
147
164
|
),
|
|
148
|
-
semicolons:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
])
|
|
153
|
-
"always"
|
|
165
|
+
semicolons: z__namespace.optional(
|
|
166
|
+
z__namespace.union([
|
|
167
|
+
z__namespace.literal("always"),
|
|
168
|
+
z__namespace.literal("asNeeded")
|
|
169
|
+
])
|
|
154
170
|
),
|
|
155
|
-
trailingCommas:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
])
|
|
161
|
-
"all"
|
|
171
|
+
trailingCommas: z__namespace.optional(
|
|
172
|
+
z__namespace.union([
|
|
173
|
+
z__namespace.literal("all"),
|
|
174
|
+
z__namespace.literal("es5"),
|
|
175
|
+
z__namespace.literal("none")
|
|
176
|
+
])
|
|
162
177
|
),
|
|
163
178
|
// JSX specific options
|
|
164
|
-
jsxQuoteStyle:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
])
|
|
169
|
-
"double"
|
|
179
|
+
jsxQuoteStyle: z__namespace.optional(
|
|
180
|
+
z__namespace.union([
|
|
181
|
+
z__namespace.literal("single"),
|
|
182
|
+
z__namespace.literal("double")
|
|
183
|
+
])
|
|
170
184
|
)
|
|
185
|
+
}, {});
|
|
186
|
+
|
|
187
|
+
// src/Report.ts
|
|
188
|
+
var Report_exports = {};
|
|
189
|
+
__export(Report_exports, {
|
|
190
|
+
make: () => make3
|
|
171
191
|
});
|
|
192
|
+
function make3(context) {
|
|
193
|
+
return {
|
|
194
|
+
send(descriptor) {
|
|
195
|
+
if (descriptor == null) return;
|
|
196
|
+
return context.report(descriptor);
|
|
197
|
+
},
|
|
198
|
+
sendOrElse(descriptor, fallback) {
|
|
199
|
+
if (descriptor == null) return fallback();
|
|
200
|
+
return context.report(descriptor);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
172
204
|
|
|
173
205
|
// src/SEL.ts
|
|
174
206
|
var SEL_exports = {};
|
|
@@ -193,5 +225,5 @@ var DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
|
|
|
193
225
|
exports.JsxConfig = JsxConfig_exports;
|
|
194
226
|
exports.LanguagePreference = LanguagePreference_exports;
|
|
195
227
|
exports.RE = RE_exports;
|
|
228
|
+
exports.Report = Report_exports;
|
|
196
229
|
exports.SEL = SEL_exports;
|
|
197
|
-
exports.createReport = createReport;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getOrElseUpdate } from '@eslint-react/eff';
|
|
1
2
|
import { JsxEmit } from 'typescript';
|
|
2
|
-
import
|
|
3
|
+
import * as z from '@zod/mini';
|
|
3
4
|
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
@@ -7,13 +8,6 @@ var __export = (target, all) => {
|
|
|
7
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
// src/helpers.ts
|
|
11
|
-
function createReport(context) {
|
|
12
|
-
return (descriptor) => {
|
|
13
|
-
if (descriptor != null) context.report(descriptor);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
// src/JsxConfig/index.ts
|
|
18
12
|
var JsxConfig_exports = {};
|
|
19
13
|
__export(JsxConfig_exports, {
|
|
@@ -85,88 +79,106 @@ function getFromContext(context) {
|
|
|
85
79
|
reactNamespace: options.reactNamespace ?? "React"
|
|
86
80
|
};
|
|
87
81
|
}
|
|
82
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
88
83
|
function getFromAnnotation(context) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
return getOrElseUpdate(
|
|
85
|
+
cache,
|
|
86
|
+
context.sourceCode,
|
|
87
|
+
() => {
|
|
88
|
+
const options = make();
|
|
89
|
+
if (!context.sourceCode.text.includes("@jsx")) return options;
|
|
90
|
+
let jsx, jsxFrag, jsxRuntime, jsxImportSource;
|
|
91
|
+
for (const comment of context.sourceCode.getAllComments().reverse()) {
|
|
92
|
+
const value = comment.value;
|
|
93
|
+
jsx ??= value.match(ANNOTATION_JSX)?.[1];
|
|
94
|
+
jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
|
|
95
|
+
jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
|
|
96
|
+
jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
|
|
97
|
+
}
|
|
98
|
+
if (jsx != null) options.jsxFactory = jsx;
|
|
99
|
+
if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
|
|
100
|
+
if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.React : JsxEmit.ReactJSX;
|
|
101
|
+
if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
|
|
102
|
+
return options;
|
|
103
|
+
}
|
|
104
|
+
);
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
// src/LanguagePreference/index.ts
|
|
107
108
|
var LanguagePreference_exports = {};
|
|
108
109
|
__export(LanguagePreference_exports, {
|
|
109
|
-
DEFAULT_LANGUAGE_PREFERENCE: () => DEFAULT_LANGUAGE_PREFERENCE,
|
|
110
110
|
LanguagePreferenceSchema: () => LanguagePreferenceSchema,
|
|
111
111
|
getFromContext: () => getFromContext2,
|
|
112
112
|
make: () => make2
|
|
113
113
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
indentWidth: 2,
|
|
117
|
-
jsxQuoteStyle: "double",
|
|
118
|
-
quoteStyle: "single",
|
|
119
|
-
semicolons: "always",
|
|
120
|
-
trailingCommas: "all"
|
|
121
|
-
};
|
|
114
|
+
|
|
115
|
+
// src/LanguagePreference/LanguagePreference.ts
|
|
122
116
|
function make2() {
|
|
123
117
|
return {
|
|
124
|
-
|
|
118
|
+
indentStyle: "space",
|
|
119
|
+
indentWidth: 2,
|
|
120
|
+
jsxQuoteStyle: "double",
|
|
121
|
+
quoteStyle: "single",
|
|
122
|
+
semicolons: "always",
|
|
123
|
+
trailingCommas: "all"
|
|
125
124
|
};
|
|
126
125
|
}
|
|
127
126
|
function getFromContext2() {
|
|
128
127
|
throw new Error("getFromContext is not implemented");
|
|
129
128
|
}
|
|
130
|
-
var LanguagePreferenceSchema = object({
|
|
131
|
-
indentStyle: optional(
|
|
132
|
-
union([
|
|
133
|
-
literal("tab"),
|
|
134
|
-
literal("space")
|
|
135
|
-
])
|
|
136
|
-
"space"
|
|
129
|
+
var LanguagePreferenceSchema = z.object({
|
|
130
|
+
indentStyle: z.optional(
|
|
131
|
+
z.union([
|
|
132
|
+
z.literal("tab"),
|
|
133
|
+
z.literal("space")
|
|
134
|
+
])
|
|
137
135
|
),
|
|
138
|
-
indentWidth: optional(number()
|
|
139
|
-
quoteStyle: optional(
|
|
140
|
-
union([
|
|
141
|
-
literal("single"),
|
|
142
|
-
literal("double")
|
|
143
|
-
])
|
|
144
|
-
"single"
|
|
136
|
+
indentWidth: z.optional(z.number()),
|
|
137
|
+
quoteStyle: z.optional(
|
|
138
|
+
z.union([
|
|
139
|
+
z.literal("single"),
|
|
140
|
+
z.literal("double")
|
|
141
|
+
])
|
|
145
142
|
),
|
|
146
|
-
semicolons: optional(
|
|
147
|
-
union([
|
|
148
|
-
literal("always"),
|
|
149
|
-
literal("asNeeded")
|
|
150
|
-
])
|
|
151
|
-
"always"
|
|
143
|
+
semicolons: z.optional(
|
|
144
|
+
z.union([
|
|
145
|
+
z.literal("always"),
|
|
146
|
+
z.literal("asNeeded")
|
|
147
|
+
])
|
|
152
148
|
),
|
|
153
|
-
trailingCommas: optional(
|
|
154
|
-
union([
|
|
155
|
-
literal("all"),
|
|
156
|
-
literal("es5"),
|
|
157
|
-
literal("none")
|
|
158
|
-
])
|
|
159
|
-
"all"
|
|
149
|
+
trailingCommas: z.optional(
|
|
150
|
+
z.union([
|
|
151
|
+
z.literal("all"),
|
|
152
|
+
z.literal("es5"),
|
|
153
|
+
z.literal("none")
|
|
154
|
+
])
|
|
160
155
|
),
|
|
161
156
|
// JSX specific options
|
|
162
|
-
jsxQuoteStyle: optional(
|
|
163
|
-
union([
|
|
164
|
-
literal("single"),
|
|
165
|
-
literal("double")
|
|
166
|
-
])
|
|
167
|
-
"double"
|
|
157
|
+
jsxQuoteStyle: z.optional(
|
|
158
|
+
z.union([
|
|
159
|
+
z.literal("single"),
|
|
160
|
+
z.literal("double")
|
|
161
|
+
])
|
|
168
162
|
)
|
|
163
|
+
}, {});
|
|
164
|
+
|
|
165
|
+
// src/Report.ts
|
|
166
|
+
var Report_exports = {};
|
|
167
|
+
__export(Report_exports, {
|
|
168
|
+
make: () => make3
|
|
169
169
|
});
|
|
170
|
+
function make3(context) {
|
|
171
|
+
return {
|
|
172
|
+
send(descriptor) {
|
|
173
|
+
if (descriptor == null) return;
|
|
174
|
+
return context.report(descriptor);
|
|
175
|
+
},
|
|
176
|
+
sendOrElse(descriptor, fallback) {
|
|
177
|
+
if (descriptor == null) return fallback();
|
|
178
|
+
return context.report(descriptor);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
170
182
|
|
|
171
183
|
// src/SEL.ts
|
|
172
184
|
var SEL_exports = {};
|
|
@@ -188,4 +200,4 @@ var DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
|
|
|
188
200
|
"[left.property.name='displayName']"
|
|
189
201
|
].join("");
|
|
190
202
|
|
|
191
|
-
export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RE_exports as RE, SEL_exports as SEL
|
|
203
|
+
export { JsxConfig_exports as JsxConfig, LanguagePreference_exports as LanguagePreference, RE_exports as RE, Report_exports as Report, SEL_exports as SEL };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/kit",
|
|
3
|
-
"version": "1.45.
|
|
3
|
+
"version": "1.45.4-beta.5",
|
|
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": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@typescript-eslint/utils": "^8.29.1",
|
|
39
|
+
"@zod/mini": "^4.0.0-beta.0",
|
|
39
40
|
"ts-pattern": "^5.7.0",
|
|
40
|
-
"
|
|
41
|
-
"@eslint-react/eff": "1.45.3"
|
|
41
|
+
"@eslint-react/eff": "1.45.4-beta.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@tsconfig/node22": "^22.0.1",
|