@eslint-react/jsx 1.8.1-next.1 → 1.8.1-next.3
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
|
11
11
|
*/
|
|
12
12
|
declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
|
|
13
13
|
|
|
14
|
-
declare function getElementType(context: RuleContext, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
14
|
+
declare function getElementType(context: RuleContext, components?: Map<string, string>, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
15
15
|
|
|
16
16
|
declare function getJSXPragma(context: RuleContext): O.Option<string>;
|
|
17
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
|
11
11
|
*/
|
|
12
12
|
declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
|
|
13
13
|
|
|
14
|
-
declare function getElementType(context: RuleContext, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
14
|
+
declare function getElementType(context: RuleContext, components?: Map<string, string>, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
15
15
|
|
|
16
16
|
declare function getJSXPragma(context: RuleContext): O.Option<string>;
|
|
17
17
|
|
package/dist/index.js
CHANGED
|
@@ -153,8 +153,12 @@ function findPropInAttributes(attributes, context, initialScope) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// src/get-element-type.ts
|
|
156
|
-
function getElementType(context, polymorphicPropName) {
|
|
156
|
+
function getElementType(context, components, polymorphicPropName) {
|
|
157
157
|
return (node) => {
|
|
158
|
+
const elementName = getElementName(node);
|
|
159
|
+
if (elementName === elementName.toLowerCase()) return elementName;
|
|
160
|
+
const asElementName = components?.get(elementName);
|
|
161
|
+
if (R__namespace.isString(asElementName)) return asElementName;
|
|
158
162
|
const initialScope = context.sourceCode.getScope(node);
|
|
159
163
|
return tools.F.pipe(
|
|
160
164
|
tools.O.fromNullable(polymorphicPropName),
|
|
@@ -162,7 +166,7 @@ function getElementType(context, polymorphicPropName) {
|
|
|
162
166
|
tools.O.flatMap((attr) => getPropValue(attr, context)),
|
|
163
167
|
tools.O.flatMapNullable((v) => v?.value),
|
|
164
168
|
tools.O.filter(R__namespace.isString),
|
|
165
|
-
tools.O.getOrElse(() =>
|
|
169
|
+
tools.O.getOrElse(() => elementName)
|
|
166
170
|
);
|
|
167
171
|
};
|
|
168
172
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -131,8 +131,12 @@ function findPropInAttributes(attributes, context, initialScope) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/get-element-type.ts
|
|
134
|
-
function getElementType(context, polymorphicPropName) {
|
|
134
|
+
function getElementType(context, components, polymorphicPropName) {
|
|
135
135
|
return (node) => {
|
|
136
|
+
const elementName = getElementName(node);
|
|
137
|
+
if (elementName === elementName.toLowerCase()) return elementName;
|
|
138
|
+
const asElementName = components?.get(elementName);
|
|
139
|
+
if (R.isString(asElementName)) return asElementName;
|
|
136
140
|
const initialScope = context.sourceCode.getScope(node);
|
|
137
141
|
return F.pipe(
|
|
138
142
|
O.fromNullable(polymorphicPropName),
|
|
@@ -140,7 +144,7 @@ function getElementType(context, polymorphicPropName) {
|
|
|
140
144
|
O.flatMap((attr) => getPropValue(attr, context)),
|
|
141
145
|
O.flatMapNullable((v) => v?.value),
|
|
142
146
|
O.filter(R.isString),
|
|
143
|
-
O.getOrElse(() =>
|
|
147
|
+
O.getOrElse(() => elementName)
|
|
144
148
|
);
|
|
145
149
|
};
|
|
146
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "1.8.1-next.
|
|
3
|
+
"version": "1.8.1-next.3",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"@typescript-eslint/scope-manager": "^8.0.0",
|
|
39
39
|
"@typescript-eslint/types": "^8.0.0",
|
|
40
40
|
"@typescript-eslint/utils": "^8.0.0",
|
|
41
|
-
"remeda": "^2.
|
|
41
|
+
"remeda": "^2.7.0",
|
|
42
42
|
"ts-pattern": "^5.2.0",
|
|
43
|
-
"@eslint-react/ast": "1.8.1-next.
|
|
44
|
-
"@eslint-react/tools": "1.8.1-next.
|
|
45
|
-
"@eslint-react/types": "1.8.1-next.
|
|
46
|
-
"@eslint-react/var": "1.8.1-next.
|
|
43
|
+
"@eslint-react/ast": "1.8.1-next.3",
|
|
44
|
+
"@eslint-react/tools": "1.8.1-next.3",
|
|
45
|
+
"@eslint-react/types": "1.8.1-next.3",
|
|
46
|
+
"@eslint-react/var": "1.8.1-next.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"tsup": "8.2.
|
|
49
|
+
"tsup": "8.2.4"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup",
|