@eslint-react/jsx 1.9.0 → 1.9.1-next.1
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 +3 -24
- package/dist/index.mjs +4 -5
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -2,31 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var ast = require('@eslint-react/ast');
|
|
4
4
|
var tools = require('@eslint-react/tools');
|
|
5
|
-
var R = require('remeda');
|
|
6
5
|
var _var = require('@eslint-react/var');
|
|
7
6
|
var astUtils = require('@typescript-eslint/utils/ast-utils');
|
|
8
7
|
var tsPattern = require('ts-pattern');
|
|
9
8
|
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var R__namespace = /*#__PURE__*/_interopNamespace(R);
|
|
29
|
-
|
|
30
9
|
// src/get-element-name.ts
|
|
31
10
|
function resolveJSXMemberExpressions(object, property) {
|
|
32
11
|
if (object.type === ast.NodeType.JSXMemberExpression) {
|
|
@@ -158,14 +137,14 @@ function getElementType(context, components, polymorphicPropName) {
|
|
|
158
137
|
const elementName = getElementName(node);
|
|
159
138
|
if (elementName === elementName.toLowerCase()) return elementName;
|
|
160
139
|
const asElementName = components?.get(elementName);
|
|
161
|
-
if (
|
|
140
|
+
if (tools.isString(asElementName)) return asElementName;
|
|
162
141
|
const initialScope = context.sourceCode.getScope(node);
|
|
163
142
|
return tools.F.pipe(
|
|
164
143
|
tools.O.fromNullable(polymorphicPropName),
|
|
165
144
|
tools.O.flatMap(findPropInAttributes(node.attributes, context, initialScope)),
|
|
166
145
|
tools.O.flatMap((attr) => getPropValue(attr, context)),
|
|
167
146
|
tools.O.flatMapNullable((v) => v?.value),
|
|
168
|
-
tools.O.filter(
|
|
147
|
+
tools.O.filter(tools.isString),
|
|
169
148
|
tools.O.getOrElse(() => elementName)
|
|
170
149
|
);
|
|
171
150
|
};
|
|
@@ -263,7 +242,7 @@ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
|
263
242
|
}
|
|
264
243
|
var isLiteral = ast.isOneOf([ast.NodeType.Literal, ast.NodeType.JSXText]);
|
|
265
244
|
function isWhiteSpace(node) {
|
|
266
|
-
return
|
|
245
|
+
return tools.isString(node.value) && node.value.trim() === "";
|
|
267
246
|
}
|
|
268
247
|
function isLineBreak(node) {
|
|
269
248
|
return isLiteral(node) && isWhiteSpace(node) && ast.isMultiLine(node);
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isOneOf, NodeType, is, isJSXTagNameExpression, isMultiLine, traverseUpGuard } from '@eslint-react/ast';
|
|
2
|
-
import { O, F } from '@eslint-react/tools';
|
|
3
|
-
import * as R from 'remeda';
|
|
2
|
+
import { O, isString, F } from '@eslint-react/tools';
|
|
4
3
|
import { findVariable, getVariableNode } from '@eslint-react/var';
|
|
5
4
|
import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
|
|
6
5
|
import { match, P } from 'ts-pattern';
|
|
@@ -136,14 +135,14 @@ function getElementType(context, components, polymorphicPropName) {
|
|
|
136
135
|
const elementName = getElementName(node);
|
|
137
136
|
if (elementName === elementName.toLowerCase()) return elementName;
|
|
138
137
|
const asElementName = components?.get(elementName);
|
|
139
|
-
if (
|
|
138
|
+
if (isString(asElementName)) return asElementName;
|
|
140
139
|
const initialScope = context.sourceCode.getScope(node);
|
|
141
140
|
return F.pipe(
|
|
142
141
|
O.fromNullable(polymorphicPropName),
|
|
143
142
|
O.flatMap(findPropInAttributes(node.attributes, context, initialScope)),
|
|
144
143
|
O.flatMap((attr) => getPropValue(attr, context)),
|
|
145
144
|
O.flatMapNullable((v) => v?.value),
|
|
146
|
-
O.filter(
|
|
145
|
+
O.filter(isString),
|
|
147
146
|
O.getOrElse(() => elementName)
|
|
148
147
|
);
|
|
149
148
|
};
|
|
@@ -241,7 +240,7 @@ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
|
241
240
|
}
|
|
242
241
|
var isLiteral = isOneOf([NodeType.Literal, NodeType.JSXText]);
|
|
243
242
|
function isWhiteSpace(node) {
|
|
244
|
-
return
|
|
243
|
+
return isString(node.value) && node.value.trim() === "";
|
|
245
244
|
}
|
|
246
245
|
function isLineBreak(node) {
|
|
247
246
|
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1-next.1",
|
|
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,12 +38,11 @@
|
|
|
38
38
|
"@typescript-eslint/scope-manager": "^8.0.1",
|
|
39
39
|
"@typescript-eslint/types": "^8.0.1",
|
|
40
40
|
"@typescript-eslint/utils": "^8.0.1",
|
|
41
|
-
"remeda": "^2.7.1",
|
|
42
41
|
"ts-pattern": "^5.2.0",
|
|
43
|
-
"@eslint-react/ast": "1.9.
|
|
44
|
-
"@eslint-react/tools": "1.9.
|
|
45
|
-
"@eslint-react/var": "1.9.
|
|
46
|
-
"@eslint-react/types": "1.9.
|
|
42
|
+
"@eslint-react/ast": "1.9.1-next.1",
|
|
43
|
+
"@eslint-react/tools": "1.9.1-next.1",
|
|
44
|
+
"@eslint-react/var": "1.9.1-next.1",
|
|
45
|
+
"@eslint-react/types": "1.9.1-next.1"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"tsup": "^8.2.4"
|