@eslint-react/jsx 5.28.7 → 5.30.0-beta.0
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.ts +0 -16
- package/dist/index.js +9 -18
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TSESTreeJSXAttributeLike, TSESTreeJSXElementLike } from "@eslint-react/ast";
|
|
2
2
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
import { RuleContext } from "@eslint-react/eslint";
|
|
4
|
-
//#region src/attribute-find.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Find a JSX attribute (or a spread attribute containing the property) by name.
|
|
7
6
|
*
|
|
@@ -45,8 +44,6 @@ export declare function findParentAttribute(node: TSESTree.Node, test?: (node: T
|
|
|
45
44
|
* @returns The matching `Property` node, or `undefined` when the key is not found.
|
|
46
45
|
*/
|
|
47
46
|
export declare function findSpreadProperty(context: RuleContext, argument: TSESTree.Expression, name: string, seen?: Set<TSESTree.Node>): TSESTree.Property | undefined;
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/attribute-has.d.ts
|
|
50
47
|
/**
|
|
51
48
|
* Check if the element has an attribute with the given name.
|
|
52
49
|
*
|
|
@@ -74,8 +71,6 @@ export declare function hasAnyAttribute(context: RuleContext, element: TSESTree.
|
|
|
74
71
|
* @returns `true` if every attribute is present on the element.
|
|
75
72
|
*/
|
|
76
73
|
export declare function hasEveryAttribute(context: RuleContext, element: TSESTree.JSXElement, names: string[]): boolean;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/attribute-name.d.ts
|
|
79
74
|
/**
|
|
80
75
|
* Get the stringified name of a `JSXAttribute` node.
|
|
81
76
|
*
|
|
@@ -103,8 +98,6 @@ export declare const isAttribute: {
|
|
|
103
98
|
(name: string): (node: TSESTree.Node) => node is TSESTree.JSXAttribute;
|
|
104
99
|
(node: TSESTree.Node, name: string): node is TSESTree.JSXAttribute;
|
|
105
100
|
};
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/attribute-value.d.ts
|
|
108
101
|
/**
|
|
109
102
|
* Discriminated union representing the resolved value of a JSX attribute.
|
|
110
103
|
*
|
|
@@ -177,8 +170,6 @@ export declare function getAttributeValue(context: RuleContext, element: TSESTre
|
|
|
177
170
|
* @returns The static value of the attribute, or `undefined` when absent or indeterminate.
|
|
178
171
|
*/
|
|
179
172
|
export declare function getAttributeStaticValue(context: RuleContext, element: TSESTree.JSXElement, name: string): unknown;
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/children.d.ts
|
|
182
173
|
/**
|
|
183
174
|
* Get the meaningful children of a JSX element or fragment.
|
|
184
175
|
*
|
|
@@ -208,8 +199,6 @@ export declare function getChildren(element: TSESTreeJSXElementLike): TSESTree.J
|
|
|
208
199
|
* @returns `true` if the element has at least one meaningful child.
|
|
209
200
|
*/
|
|
210
201
|
export declare function hasChildren(element: TSESTreeJSXElementLike): boolean;
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/element-is.d.ts
|
|
213
202
|
/**
|
|
214
203
|
* A test that determines whether a JSX element matches.
|
|
215
204
|
*
|
|
@@ -256,8 +245,6 @@ export declare function isFragmentElement(node: TSESTree.Node, jsxFragmentFactor
|
|
|
256
245
|
* @returns `true` if the node is a `JSXElement` with a lowercase tag name.
|
|
257
246
|
*/
|
|
258
247
|
export declare function isHostElement(node: TSESTree.Node): node is TSESTree.JSXElement;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/element-type.d.ts
|
|
261
248
|
/**
|
|
262
249
|
* Get the string representation of a JSX element's type.
|
|
263
250
|
*
|
|
@@ -280,8 +267,6 @@ export declare function getElementFullType(node: TSESTreeJSXElementLike): string
|
|
|
280
267
|
* @returns The last segment of the element type, or `""` for fragments.
|
|
281
268
|
*/
|
|
282
269
|
export declare function getElementSelfType(node: TSESTreeJSXElementLike): string;
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region src/text.d.ts
|
|
285
270
|
/**
|
|
286
271
|
* Collapse a multiline JSX text string following React's whitespace rules.
|
|
287
272
|
*
|
|
@@ -333,5 +318,4 @@ export declare function isWhitespaceText(node: TSESTree.JSXChild): boolean;
|
|
|
333
318
|
* @returns `true` if the node is a `{""}` expression container.
|
|
334
319
|
*/
|
|
335
320
|
export declare function isEmptyStringExpression(node: TSESTree.JSXChild): boolean;
|
|
336
|
-
//#endregion
|
|
337
321
|
export type { AttributeValue, ElementTest };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { resolve } from "@eslint-react/var";
|
|
|
3
3
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
4
4
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
5
5
|
import { P, match } from "ts-pattern";
|
|
6
|
-
|
|
6
|
+
// ../../.pkgs/eff/dist/index.js
|
|
7
7
|
const pipeArguments = (self, args) => {
|
|
8
8
|
switch (args.length) {
|
|
9
9
|
case 0: return self;
|
|
@@ -94,8 +94,7 @@ dual(2, (self, predicate) => {
|
|
|
94
94
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
95
95
|
return input.slice(0, idx);
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
//#region src/attribute-name.ts
|
|
97
|
+
// src/attribute-name.ts
|
|
99
98
|
function getAttributeName(node) {
|
|
100
99
|
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) return node.name.name;
|
|
101
100
|
return node.name.namespace.name + ":" + node.name.name.name;
|
|
@@ -103,8 +102,7 @@ function getAttributeName(node) {
|
|
|
103
102
|
const isAttribute = dual(2, (node, name) => {
|
|
104
103
|
return node.type === AST_NODE_TYPES.JSXAttribute && node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === name;
|
|
105
104
|
});
|
|
106
|
-
|
|
107
|
-
//#region src/attribute-find.ts
|
|
105
|
+
// src/attribute-find.ts
|
|
108
106
|
function findAttribute(context, element, name) {
|
|
109
107
|
return element.openingElement.attributes.findLast((attr) => {
|
|
110
108
|
if (attr.type === AST_NODE_TYPES.JSXAttribute) return getAttributeName(attr) === name;
|
|
@@ -148,8 +146,7 @@ function findSpreadProperty(context, argument, name, seen = /* @__PURE__ */ new
|
|
|
148
146
|
if (found != null) return found;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
|
|
152
|
-
//#region src/attribute-has.ts
|
|
149
|
+
// src/attribute-has.ts
|
|
153
150
|
function hasAttribute(context, element, name) {
|
|
154
151
|
return findAttribute(context, element, name) != null;
|
|
155
152
|
}
|
|
@@ -159,8 +156,7 @@ function hasAnyAttribute(context, element, names) {
|
|
|
159
156
|
function hasEveryAttribute(context, element, names) {
|
|
160
157
|
return names.every((name) => findAttribute(context, element, name) != null);
|
|
161
158
|
}
|
|
162
|
-
|
|
163
|
-
//#region src/attribute-value.ts
|
|
159
|
+
// src/attribute-value.ts
|
|
164
160
|
function resolveAttributeValue(context, attribute, name) {
|
|
165
161
|
if (attribute.type === AST_NODE_TYPES.JSXAttribute) return resolveJSXAttribute(context, attribute);
|
|
166
162
|
return resolveJSXSpreadAttribute(context, attribute, name);
|
|
@@ -241,8 +237,7 @@ function resolveJSXSpreadAttribute(context, node, name) {
|
|
|
241
237
|
}
|
|
242
238
|
};
|
|
243
239
|
}
|
|
244
|
-
|
|
245
|
-
//#region src/text.ts
|
|
240
|
+
// src/text.ts
|
|
246
241
|
function collapseMultilineText(text) {
|
|
247
242
|
const lines = text.split(/\r\n|\n|\r/);
|
|
248
243
|
let lastNonEmptyLine = 0;
|
|
@@ -281,8 +276,7 @@ function isEmptyStringExpression(node) {
|
|
|
281
276
|
if (expr.type !== AST_NODE_TYPES.Literal) return false;
|
|
282
277
|
return expr.value === "";
|
|
283
278
|
}
|
|
284
|
-
|
|
285
|
-
//#region src/children.ts
|
|
279
|
+
// src/children.ts
|
|
286
280
|
function getChildren(element) {
|
|
287
281
|
const children = [];
|
|
288
282
|
for (const child of element.children) {
|
|
@@ -297,8 +291,7 @@ function hasChildren(element) {
|
|
|
297
291
|
if (element.children.length === 0) return false;
|
|
298
292
|
return !element.children.every(or(or(isWhitespaceText, isEmptyExpressionContainer), isEmptyStringExpression));
|
|
299
293
|
}
|
|
300
|
-
|
|
301
|
-
//#region src/element-type.ts
|
|
294
|
+
// src/element-type.ts
|
|
302
295
|
function getElementFullType(node) {
|
|
303
296
|
if (node.type === AST_NODE_TYPES.JSXFragment) return "";
|
|
304
297
|
function getQualifiedName(node) {
|
|
@@ -313,8 +306,7 @@ function getElementFullType(node) {
|
|
|
313
306
|
function getElementSelfType(node) {
|
|
314
307
|
return getElementFullType(node).split(".").at(-1) ?? "";
|
|
315
308
|
}
|
|
316
|
-
|
|
317
|
-
//#region src/element-is.ts
|
|
309
|
+
// src/element-is.ts
|
|
318
310
|
function isElement(node, test) {
|
|
319
311
|
if (node == null) return false;
|
|
320
312
|
if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
|
|
@@ -335,5 +327,4 @@ function isHostElement(node) {
|
|
|
335
327
|
if (name.type === AST_NODE_TYPES.JSXNamespacedName) return /^[a-z]/u.test(name.name.name);
|
|
336
328
|
return false;
|
|
337
329
|
}
|
|
338
|
-
//#endregion
|
|
339
330
|
export { collapseMultilineText, findAttribute, findParentAttribute, findSpreadProperty, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isAttribute, isElement, isEmptyStringExpression, isFragmentElement, isHostElement, isPaddingWhitespace, isWhitespaceText, resolveAttributeValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.30.0-beta.0",
|
|
4
4
|
"description": "ESLint React's TSESTree JSX utility module for static analysis of JSX patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/ast": "5.
|
|
33
|
-
"@eslint-react/eslint": "5.
|
|
34
|
-
"@eslint-react/var": "5.
|
|
32
|
+
"@eslint-react/ast": "5.30.0-beta.0",
|
|
33
|
+
"@eslint-react/eslint": "5.30.0-beta.0",
|
|
34
|
+
"@eslint-react/var": "5.30.0-beta.0",
|
|
35
35
|
"@typescript-eslint/types": "^8.72.0",
|
|
36
36
|
"@typescript-eslint/utils": "^8.72.0",
|
|
37
37
|
"ts-pattern": "^5.9.2"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tsconfig/node20": "^20.1.10",
|
|
44
44
|
"@types/node": "^20.19.43",
|
|
45
45
|
"eslint": "^10.13.0",
|
|
46
|
-
"tsdown": "^0.23.
|
|
46
|
+
"tsdown": "^0.23.2",
|
|
47
47
|
"typescript": "6.0.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|