@eslint-react/jsx 1.13.1-next.0 → 1.13.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 +35 -14
- package/dist/index.mjs +14 -14
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2,11 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
var types = require('@typescript-eslint/types');
|
|
4
4
|
var tools = require('@eslint-react/tools');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var AST = require('@eslint-react/ast');
|
|
6
|
+
var VAR = require('@eslint-react/var');
|
|
7
7
|
var astUtils = require('@typescript-eslint/utils/ast-utils');
|
|
8
8
|
var tsPattern = require('ts-pattern');
|
|
9
9
|
|
|
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 AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
29
|
+
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
30
|
+
|
|
10
31
|
// src/get-element-name.ts
|
|
11
32
|
function resolveJSXMemberExpressions(object, property) {
|
|
12
33
|
if (object.type === types.AST_NODE_TYPES.JSXMemberExpression) {
|
|
@@ -67,12 +88,12 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
|
|
|
67
88
|
case prop.argument.type === types.AST_NODE_TYPES.Identifier: {
|
|
68
89
|
const { name } = prop.argument;
|
|
69
90
|
const maybeInit = tools.O.flatMap(
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
VAR__namespace.findVariable(name, initialScope),
|
|
92
|
+
VAR__namespace.getVariableNode(0)
|
|
72
93
|
);
|
|
73
94
|
if (tools.O.isNone(maybeInit)) return false;
|
|
74
95
|
const init = maybeInit.value;
|
|
75
|
-
if (!
|
|
96
|
+
if (!AST__namespace.is(types.AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
76
97
|
if (seenProps.includes(name)) return false;
|
|
77
98
|
return tools.O.isSome(
|
|
78
99
|
findPropInProperties(init.properties, initialScope, [...seenProps, name])(propName)
|
|
@@ -108,12 +129,12 @@ function findPropInAttributes(attributes, initialScope) {
|
|
|
108
129
|
case types.AST_NODE_TYPES.Identifier: {
|
|
109
130
|
const { name } = attr.argument;
|
|
110
131
|
const maybeInit = tools.O.flatMap(
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
VAR__namespace.findVariable(name, initialScope),
|
|
133
|
+
VAR__namespace.getVariableNode(0)
|
|
113
134
|
);
|
|
114
135
|
if (tools.O.isNone(maybeInit)) return false;
|
|
115
136
|
const init = maybeInit.value;
|
|
116
|
-
if (!
|
|
137
|
+
if (!AST__namespace.is(types.AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
117
138
|
return tools.O.isSome(findPropInProperties(init.properties, initialScope)(propName));
|
|
118
139
|
}
|
|
119
140
|
case types.AST_NODE_TYPES.ObjectExpression:
|
|
@@ -222,21 +243,21 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
|
222
243
|
}).with({ type: types.AST_NODE_TYPES.Identifier }, (node2) => {
|
|
223
244
|
const { name } = node2;
|
|
224
245
|
if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral);
|
|
225
|
-
if (
|
|
246
|
+
if (AST__namespace.isJSXTagNameExpression(node2)) return true;
|
|
226
247
|
const initialScope = jsxCtx.getScope(node2);
|
|
227
248
|
return tools.F.pipe(
|
|
228
|
-
|
|
229
|
-
tools.O.flatMap(
|
|
249
|
+
VAR__namespace.findVariable(name, initialScope),
|
|
250
|
+
tools.O.flatMap(VAR__namespace.getVariableNode(0)),
|
|
230
251
|
tools.O.exists((n) => isJSXValue(n, jsxCtx, hint))
|
|
231
252
|
);
|
|
232
253
|
}).otherwise(tools.F.constFalse);
|
|
233
254
|
}
|
|
234
|
-
var isLiteral =
|
|
255
|
+
var isLiteral = AST__namespace.isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText]);
|
|
235
256
|
function isWhiteSpace(node) {
|
|
236
257
|
return tools.isString(node.value) && node.value.trim() === "";
|
|
237
258
|
}
|
|
238
259
|
function isLineBreak(node) {
|
|
239
|
-
return isLiteral(node) && isWhiteSpace(node) &&
|
|
260
|
+
return isLiteral(node) && isWhiteSpace(node) && AST__namespace.isMultiLine(node);
|
|
240
261
|
}
|
|
241
262
|
function isPaddingSpaces(node) {
|
|
242
263
|
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
@@ -245,7 +266,7 @@ function traverseUpProp(node, predicate = tools.F.constTrue) {
|
|
|
245
266
|
const guard = (node2) => {
|
|
246
267
|
return node2.type === types.AST_NODE_TYPES.JSXAttribute && predicate(node2);
|
|
247
268
|
};
|
|
248
|
-
return
|
|
269
|
+
return AST__namespace.traverseUpGuard(node, guard);
|
|
249
270
|
}
|
|
250
271
|
|
|
251
272
|
exports.DEFAULT_JSX_VALUE_HINT = DEFAULT_JSX_VALUE_HINT;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
2
|
import { O, isString, F } from '@eslint-react/tools';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as AST from '@eslint-react/ast';
|
|
4
|
+
import * as VAR from '@eslint-react/var';
|
|
5
5
|
import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
|
|
6
6
|
import { match, P } from 'ts-pattern';
|
|
7
7
|
|
|
@@ -65,12 +65,12 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
|
|
|
65
65
|
case prop.argument.type === AST_NODE_TYPES.Identifier: {
|
|
66
66
|
const { name } = prop.argument;
|
|
67
67
|
const maybeInit = O.flatMap(
|
|
68
|
-
findVariable(name, initialScope),
|
|
69
|
-
getVariableNode(0)
|
|
68
|
+
VAR.findVariable(name, initialScope),
|
|
69
|
+
VAR.getVariableNode(0)
|
|
70
70
|
);
|
|
71
71
|
if (O.isNone(maybeInit)) return false;
|
|
72
72
|
const init = maybeInit.value;
|
|
73
|
-
if (!is(AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
73
|
+
if (!AST.is(AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
74
74
|
if (seenProps.includes(name)) return false;
|
|
75
75
|
return O.isSome(
|
|
76
76
|
findPropInProperties(init.properties, initialScope, [...seenProps, name])(propName)
|
|
@@ -106,12 +106,12 @@ function findPropInAttributes(attributes, initialScope) {
|
|
|
106
106
|
case AST_NODE_TYPES.Identifier: {
|
|
107
107
|
const { name } = attr.argument;
|
|
108
108
|
const maybeInit = O.flatMap(
|
|
109
|
-
findVariable(name, initialScope),
|
|
110
|
-
getVariableNode(0)
|
|
109
|
+
VAR.findVariable(name, initialScope),
|
|
110
|
+
VAR.getVariableNode(0)
|
|
111
111
|
);
|
|
112
112
|
if (O.isNone(maybeInit)) return false;
|
|
113
113
|
const init = maybeInit.value;
|
|
114
|
-
if (!is(AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
114
|
+
if (!AST.is(AST_NODE_TYPES.ObjectExpression)(init)) return false;
|
|
115
115
|
return O.isSome(findPropInProperties(init.properties, initialScope)(propName));
|
|
116
116
|
}
|
|
117
117
|
case AST_NODE_TYPES.ObjectExpression:
|
|
@@ -220,21 +220,21 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
|
220
220
|
}).with({ type: AST_NODE_TYPES.Identifier }, (node2) => {
|
|
221
221
|
const { name } = node2;
|
|
222
222
|
if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral);
|
|
223
|
-
if (isJSXTagNameExpression(node2)) return true;
|
|
223
|
+
if (AST.isJSXTagNameExpression(node2)) return true;
|
|
224
224
|
const initialScope = jsxCtx.getScope(node2);
|
|
225
225
|
return F.pipe(
|
|
226
|
-
findVariable(name, initialScope),
|
|
227
|
-
O.flatMap(getVariableNode(0)),
|
|
226
|
+
VAR.findVariable(name, initialScope),
|
|
227
|
+
O.flatMap(VAR.getVariableNode(0)),
|
|
228
228
|
O.exists((n) => isJSXValue(n, jsxCtx, hint))
|
|
229
229
|
);
|
|
230
230
|
}).otherwise(F.constFalse);
|
|
231
231
|
}
|
|
232
|
-
var isLiteral = isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText]);
|
|
232
|
+
var isLiteral = AST.isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText]);
|
|
233
233
|
function isWhiteSpace(node) {
|
|
234
234
|
return isString(node.value) && node.value.trim() === "";
|
|
235
235
|
}
|
|
236
236
|
function isLineBreak(node) {
|
|
237
|
-
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
237
|
+
return isLiteral(node) && isWhiteSpace(node) && AST.isMultiLine(node);
|
|
238
238
|
}
|
|
239
239
|
function isPaddingSpaces(node) {
|
|
240
240
|
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
@@ -243,7 +243,7 @@ function traverseUpProp(node, predicate = F.constTrue) {
|
|
|
243
243
|
const guard = (node2) => {
|
|
244
244
|
return node2.type === AST_NODE_TYPES.JSXAttribute && predicate(node2);
|
|
245
245
|
};
|
|
246
|
-
return traverseUpGuard(node, guard);
|
|
246
|
+
return AST.traverseUpGuard(node, guard);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName, getElementType, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "1.13.1-next.
|
|
3
|
+
"version": "1.13.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": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@typescript-eslint/types": "^8.4.0",
|
|
40
40
|
"@typescript-eslint/utils": "^8.4.0",
|
|
41
41
|
"ts-pattern": "^5.3.1",
|
|
42
|
-
"@eslint-react/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/types": "1.13.1-next.
|
|
45
|
-
"@eslint-react/var": "1.13.1-next.
|
|
42
|
+
"@eslint-react/tools": "1.13.1-next.1",
|
|
43
|
+
"@eslint-react/ast": "1.13.1-next.1",
|
|
44
|
+
"@eslint-react/types": "1.13.1-next.1",
|
|
45
|
+
"@eslint-react/var": "1.13.1-next.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"tsup": "^8.2.4"
|