@eslint-react/jsx 0.8.12-beta.4 → 0.8.13-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.cjs +30 -59
- package/dist/index.d.mts +1 -15
- package/dist/index.d.ts +1 -15
- package/dist/index.js +30 -59
- package/dist/index.mjs +31 -57
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -7363,36 +7363,6 @@ const hdlWheel = [
|
|
|
7363
7363
|
...hdlWheel
|
|
7364
7364
|
];
|
|
7365
7365
|
|
|
7366
|
-
/**
|
|
7367
|
-
* Check if a node is a Literal or JSXText
|
|
7368
|
-
* @param node The AST node to check
|
|
7369
|
-
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7370
|
-
*/ const isLiteral = isOneOf([
|
|
7371
|
-
NodeType.Literal,
|
|
7372
|
-
NodeType.JSXText
|
|
7373
|
-
]);
|
|
7374
|
-
/**
|
|
7375
|
-
* Check if a Literal or JSXText node is whitespace
|
|
7376
|
-
* @param node The AST node to check
|
|
7377
|
-
* @returns boolean `true` if the node is whitespace
|
|
7378
|
-
*/ function isWhiteSpace(node) {
|
|
7379
|
-
return isString(node.value) && node.value.trim() === "";
|
|
7380
|
-
}
|
|
7381
|
-
/**
|
|
7382
|
-
* Check if a Literal or JSXText node is a line break
|
|
7383
|
-
* @param node The AST node to check
|
|
7384
|
-
* @returns boolean
|
|
7385
|
-
*/ function isLineBreak(node) {
|
|
7386
|
-
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7387
|
-
}
|
|
7388
|
-
/**
|
|
7389
|
-
* Check if a Literal or JSXText node is padding spaces
|
|
7390
|
-
* @param node The AST node to check
|
|
7391
|
-
* @returns boolean
|
|
7392
|
-
*/ function isPaddingSpaces(node) {
|
|
7393
|
-
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7394
|
-
}
|
|
7395
|
-
|
|
7396
7366
|
const isFragment = (node, pragma, fragment)=>{
|
|
7397
7367
|
if (!isOneOf([
|
|
7398
7368
|
NodeType.JSXElement,
|
|
@@ -7419,32 +7389,6 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
7419
7389
|
// <Pragma.Fragment>
|
|
7420
7390
|
return name.type === NodeType.JSXMemberExpression && name.object.type === NodeType.JSXIdentifier && name.object.name === pragma && name.property.name === fragment;
|
|
7421
7391
|
}
|
|
7422
|
-
/**
|
|
7423
|
-
* Check if a JSXElement or JSXFragment has only one literal child and is not a child
|
|
7424
|
-
* @param node The AST node to check
|
|
7425
|
-
* @returns `true` if the node has only one literal child and is not a child
|
|
7426
|
-
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} />
|
|
7427
|
-
*/ function isFragmentWithOnlyTextAndIsNotChild(node) {
|
|
7428
|
-
return node.children.length === 1 && isLiteral(node.children[0]) && !(node.parent.type === NodeType.JSXElement || node.parent.type === NodeType.JSXFragment);
|
|
7429
|
-
}
|
|
7430
|
-
function containsCallExpression(node) {
|
|
7431
|
-
return node.type === NodeType.JSXExpressionContainer && node.expression.type === NodeType.CallExpression;
|
|
7432
|
-
}
|
|
7433
|
-
/**
|
|
7434
|
-
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression
|
|
7435
|
-
* @param node The AST node to check
|
|
7436
|
-
* @returns boolean
|
|
7437
|
-
*/ function isFragmentHasLessThanTwoChildren(node) {
|
|
7438
|
-
const nonPaddingChildren = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7439
|
-
if (nonPaddingChildren.length === 1) {
|
|
7440
|
-
return !containsCallExpression(nonPaddingChildren[0]);
|
|
7441
|
-
}
|
|
7442
|
-
return nonPaddingChildren.length === 0;
|
|
7443
|
-
}
|
|
7444
|
-
function isFragmentWithSingleExpression(node) {
|
|
7445
|
-
const children = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7446
|
-
return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
|
|
7447
|
-
}
|
|
7448
7392
|
|
|
7449
7393
|
// type ReactNode =
|
|
7450
7394
|
// | ReactElement
|
|
@@ -7739,6 +7683,36 @@ function getProp(props, propName, context) {
|
|
|
7739
7683
|
return Option.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
|
|
7740
7684
|
}
|
|
7741
7685
|
|
|
7686
|
+
/**
|
|
7687
|
+
* Check if a node is a Literal or JSXText
|
|
7688
|
+
* @param node The AST node to check
|
|
7689
|
+
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7690
|
+
*/ const isLiteral = isOneOf([
|
|
7691
|
+
NodeType.Literal,
|
|
7692
|
+
NodeType.JSXText
|
|
7693
|
+
]);
|
|
7694
|
+
/**
|
|
7695
|
+
* Check if a Literal or JSXText node is whitespace
|
|
7696
|
+
* @param node The AST node to check
|
|
7697
|
+
* @returns boolean `true` if the node is whitespace
|
|
7698
|
+
*/ function isWhiteSpace(node) {
|
|
7699
|
+
return isString(node.value) && node.value.trim() === "";
|
|
7700
|
+
}
|
|
7701
|
+
/**
|
|
7702
|
+
* Check if a Literal or JSXText node is a line break
|
|
7703
|
+
* @param node The AST node to check
|
|
7704
|
+
* @returns boolean
|
|
7705
|
+
*/ function isLineBreak(node) {
|
|
7706
|
+
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7707
|
+
}
|
|
7708
|
+
/**
|
|
7709
|
+
* Check if a Literal or JSXText node is padding spaces
|
|
7710
|
+
* @param node The AST node to check
|
|
7711
|
+
* @returns boolean
|
|
7712
|
+
*/ function isPaddingSpaces(node) {
|
|
7713
|
+
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7742
7716
|
exports.JSXValueCheckHint = JSXValueCheckHint;
|
|
7743
7717
|
exports.defaultJSXValueCheckHint = defaultJSXValueCheckHint;
|
|
7744
7718
|
exports.elementType = elementType;
|
|
@@ -7774,10 +7748,7 @@ exports.isCloneElementCall = isCloneElementCall;
|
|
|
7774
7748
|
exports.isCreateElementCall = isCreateElementCall;
|
|
7775
7749
|
exports.isFragment = isFragment;
|
|
7776
7750
|
exports.isFragmentElement = isFragmentElement;
|
|
7777
|
-
exports.isFragmentHasLessThanTwoChildren = isFragmentHasLessThanTwoChildren;
|
|
7778
7751
|
exports.isFragmentSyntax = isFragmentSyntax;
|
|
7779
|
-
exports.isFragmentWithOnlyTextAndIsNotChild = isFragmentWithOnlyTextAndIsNotChild;
|
|
7780
|
-
exports.isFragmentWithSingleExpression = isFragmentWithSingleExpression;
|
|
7781
7752
|
exports.isFunctionReturningJSXValue = isFunctionReturningJSXValue;
|
|
7782
7753
|
exports.isInitializedFromPragma = isInitializedFromPragma;
|
|
7783
7754
|
exports.isInsideCreateElementProps = isInsideCreateElementProps;
|
package/dist/index.d.mts
CHANGED
|
@@ -103,20 +103,6 @@ declare const isFragmentSyntax: (node: TSESTree.Node | null | undefined) => node
|
|
|
103
103
|
* @param fragment
|
|
104
104
|
*/
|
|
105
105
|
declare function isFragmentElement(node: TSESTree.JSXElement, pragma: string, fragment: string): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Check if a JSXElement or JSXFragment has only one literal child and is not a child
|
|
108
|
-
* @param node The AST node to check
|
|
109
|
-
* @returns `true` if the node has only one literal child and is not a child
|
|
110
|
-
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} />
|
|
111
|
-
*/
|
|
112
|
-
declare function isFragmentWithOnlyTextAndIsNotChild(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression
|
|
115
|
-
* @param node The AST node to check
|
|
116
|
-
* @returns boolean
|
|
117
|
-
*/
|
|
118
|
-
declare function isFragmentHasLessThanTwoChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
119
|
-
declare function isFragmentWithSingleExpression(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
120
106
|
|
|
121
107
|
/**
|
|
122
108
|
* Check if function is returning JSX
|
|
@@ -246,4 +232,4 @@ declare const defaultJSXValueCheckHint: bigint;
|
|
|
246
232
|
*/
|
|
247
233
|
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
248
234
|
|
|
249
|
-
export { type CallFromPragmaPredicate, JSXValueCheckHint, defaultJSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement,
|
|
235
|
+
export { type CallFromPragmaPredicate, JSXValueCheckHint, defaultJSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/dist/index.d.ts
CHANGED
|
@@ -103,20 +103,6 @@ declare const isFragmentSyntax: (node: TSESTree.Node | null | undefined) => node
|
|
|
103
103
|
* @param fragment
|
|
104
104
|
*/
|
|
105
105
|
declare function isFragmentElement(node: TSESTree.JSXElement, pragma: string, fragment: string): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Check if a JSXElement or JSXFragment has only one literal child and is not a child
|
|
108
|
-
* @param node The AST node to check
|
|
109
|
-
* @returns `true` if the node has only one literal child and is not a child
|
|
110
|
-
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} />
|
|
111
|
-
*/
|
|
112
|
-
declare function isFragmentWithOnlyTextAndIsNotChild(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression
|
|
115
|
-
* @param node The AST node to check
|
|
116
|
-
* @returns boolean
|
|
117
|
-
*/
|
|
118
|
-
declare function isFragmentHasLessThanTwoChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
119
|
-
declare function isFragmentWithSingleExpression(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
120
106
|
|
|
121
107
|
/**
|
|
122
108
|
* Check if function is returning JSX
|
|
@@ -246,4 +232,4 @@ declare const defaultJSXValueCheckHint: bigint;
|
|
|
246
232
|
*/
|
|
247
233
|
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
248
234
|
|
|
249
|
-
export { type CallFromPragmaPredicate, JSXValueCheckHint, defaultJSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement,
|
|
235
|
+
export { type CallFromPragmaPredicate, JSXValueCheckHint, defaultJSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/dist/index.js
CHANGED
|
@@ -7363,36 +7363,6 @@ const hdlWheel = [
|
|
|
7363
7363
|
...hdlWheel
|
|
7364
7364
|
];
|
|
7365
7365
|
|
|
7366
|
-
/**
|
|
7367
|
-
* Check if a node is a Literal or JSXText
|
|
7368
|
-
* @param node The AST node to check
|
|
7369
|
-
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7370
|
-
*/ const isLiteral = isOneOf([
|
|
7371
|
-
NodeType.Literal,
|
|
7372
|
-
NodeType.JSXText
|
|
7373
|
-
]);
|
|
7374
|
-
/**
|
|
7375
|
-
* Check if a Literal or JSXText node is whitespace
|
|
7376
|
-
* @param node The AST node to check
|
|
7377
|
-
* @returns boolean `true` if the node is whitespace
|
|
7378
|
-
*/ function isWhiteSpace(node) {
|
|
7379
|
-
return isString(node.value) && node.value.trim() === "";
|
|
7380
|
-
}
|
|
7381
|
-
/**
|
|
7382
|
-
* Check if a Literal or JSXText node is a line break
|
|
7383
|
-
* @param node The AST node to check
|
|
7384
|
-
* @returns boolean
|
|
7385
|
-
*/ function isLineBreak(node) {
|
|
7386
|
-
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7387
|
-
}
|
|
7388
|
-
/**
|
|
7389
|
-
* Check if a Literal or JSXText node is padding spaces
|
|
7390
|
-
* @param node The AST node to check
|
|
7391
|
-
* @returns boolean
|
|
7392
|
-
*/ function isPaddingSpaces(node) {
|
|
7393
|
-
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7394
|
-
}
|
|
7395
|
-
|
|
7396
7366
|
const isFragment = (node, pragma, fragment)=>{
|
|
7397
7367
|
if (!isOneOf([
|
|
7398
7368
|
NodeType.JSXElement,
|
|
@@ -7419,32 +7389,6 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
7419
7389
|
// <Pragma.Fragment>
|
|
7420
7390
|
return name.type === NodeType.JSXMemberExpression && name.object.type === NodeType.JSXIdentifier && name.object.name === pragma && name.property.name === fragment;
|
|
7421
7391
|
}
|
|
7422
|
-
/**
|
|
7423
|
-
* Check if a JSXElement or JSXFragment has only one literal child and is not a child
|
|
7424
|
-
* @param node The AST node to check
|
|
7425
|
-
* @returns `true` if the node has only one literal child and is not a child
|
|
7426
|
-
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} />
|
|
7427
|
-
*/ function isFragmentWithOnlyTextAndIsNotChild(node) {
|
|
7428
|
-
return node.children.length === 1 && isLiteral(node.children[0]) && !(node.parent.type === NodeType.JSXElement || node.parent.type === NodeType.JSXFragment);
|
|
7429
|
-
}
|
|
7430
|
-
function containsCallExpression(node) {
|
|
7431
|
-
return node.type === NodeType.JSXExpressionContainer && node.expression.type === NodeType.CallExpression;
|
|
7432
|
-
}
|
|
7433
|
-
/**
|
|
7434
|
-
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression
|
|
7435
|
-
* @param node The AST node to check
|
|
7436
|
-
* @returns boolean
|
|
7437
|
-
*/ function isFragmentHasLessThanTwoChildren(node) {
|
|
7438
|
-
const nonPaddingChildren = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7439
|
-
if (nonPaddingChildren.length === 1) {
|
|
7440
|
-
return !containsCallExpression(nonPaddingChildren[0]);
|
|
7441
|
-
}
|
|
7442
|
-
return nonPaddingChildren.length === 0;
|
|
7443
|
-
}
|
|
7444
|
-
function isFragmentWithSingleExpression(node) {
|
|
7445
|
-
const children = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7446
|
-
return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
|
|
7447
|
-
}
|
|
7448
7392
|
|
|
7449
7393
|
// type ReactNode =
|
|
7450
7394
|
// | ReactElement
|
|
@@ -7739,6 +7683,36 @@ function getProp(props, propName, context) {
|
|
|
7739
7683
|
return Option.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
|
|
7740
7684
|
}
|
|
7741
7685
|
|
|
7686
|
+
/**
|
|
7687
|
+
* Check if a node is a Literal or JSXText
|
|
7688
|
+
* @param node The AST node to check
|
|
7689
|
+
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7690
|
+
*/ const isLiteral = isOneOf([
|
|
7691
|
+
NodeType.Literal,
|
|
7692
|
+
NodeType.JSXText
|
|
7693
|
+
]);
|
|
7694
|
+
/**
|
|
7695
|
+
* Check if a Literal or JSXText node is whitespace
|
|
7696
|
+
* @param node The AST node to check
|
|
7697
|
+
* @returns boolean `true` if the node is whitespace
|
|
7698
|
+
*/ function isWhiteSpace(node) {
|
|
7699
|
+
return isString(node.value) && node.value.trim() === "";
|
|
7700
|
+
}
|
|
7701
|
+
/**
|
|
7702
|
+
* Check if a Literal or JSXText node is a line break
|
|
7703
|
+
* @param node The AST node to check
|
|
7704
|
+
* @returns boolean
|
|
7705
|
+
*/ function isLineBreak(node) {
|
|
7706
|
+
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7707
|
+
}
|
|
7708
|
+
/**
|
|
7709
|
+
* Check if a Literal or JSXText node is padding spaces
|
|
7710
|
+
* @param node The AST node to check
|
|
7711
|
+
* @returns boolean
|
|
7712
|
+
*/ function isPaddingSpaces(node) {
|
|
7713
|
+
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7742
7716
|
exports.JSXValueCheckHint = JSXValueCheckHint;
|
|
7743
7717
|
exports.defaultJSXValueCheckHint = defaultJSXValueCheckHint;
|
|
7744
7718
|
exports.elementType = elementType;
|
|
@@ -7774,10 +7748,7 @@ exports.isCloneElementCall = isCloneElementCall;
|
|
|
7774
7748
|
exports.isCreateElementCall = isCreateElementCall;
|
|
7775
7749
|
exports.isFragment = isFragment;
|
|
7776
7750
|
exports.isFragmentElement = isFragmentElement;
|
|
7777
|
-
exports.isFragmentHasLessThanTwoChildren = isFragmentHasLessThanTwoChildren;
|
|
7778
7751
|
exports.isFragmentSyntax = isFragmentSyntax;
|
|
7779
|
-
exports.isFragmentWithOnlyTextAndIsNotChild = isFragmentWithOnlyTextAndIsNotChild;
|
|
7780
|
-
exports.isFragmentWithSingleExpression = isFragmentWithSingleExpression;
|
|
7781
7752
|
exports.isFunctionReturningJSXValue = isFunctionReturningJSXValue;
|
|
7782
7753
|
exports.isInitializedFromPragma = isInitializedFromPragma;
|
|
7783
7754
|
exports.isInsideCreateElementProps = isInsideCreateElementProps;
|
package/dist/index.mjs
CHANGED
|
@@ -7361,36 +7361,6 @@ const hdlWheel = [
|
|
|
7361
7361
|
...hdlWheel
|
|
7362
7362
|
];
|
|
7363
7363
|
|
|
7364
|
-
/**
|
|
7365
|
-
* Check if a node is a Literal or JSXText
|
|
7366
|
-
* @param node The AST node to check
|
|
7367
|
-
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7368
|
-
*/ const isLiteral = isOneOf([
|
|
7369
|
-
NodeType.Literal,
|
|
7370
|
-
NodeType.JSXText
|
|
7371
|
-
]);
|
|
7372
|
-
/**
|
|
7373
|
-
* Check if a Literal or JSXText node is whitespace
|
|
7374
|
-
* @param node The AST node to check
|
|
7375
|
-
* @returns boolean `true` if the node is whitespace
|
|
7376
|
-
*/ function isWhiteSpace(node) {
|
|
7377
|
-
return isString(node.value) && node.value.trim() === "";
|
|
7378
|
-
}
|
|
7379
|
-
/**
|
|
7380
|
-
* Check if a Literal or JSXText node is a line break
|
|
7381
|
-
* @param node The AST node to check
|
|
7382
|
-
* @returns boolean
|
|
7383
|
-
*/ function isLineBreak(node) {
|
|
7384
|
-
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7385
|
-
}
|
|
7386
|
-
/**
|
|
7387
|
-
* Check if a Literal or JSXText node is padding spaces
|
|
7388
|
-
* @param node The AST node to check
|
|
7389
|
-
* @returns boolean
|
|
7390
|
-
*/ function isPaddingSpaces(node) {
|
|
7391
|
-
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7392
|
-
}
|
|
7393
|
-
|
|
7394
7364
|
const isFragment = (node, pragma, fragment)=>{
|
|
7395
7365
|
if (!isOneOf([
|
|
7396
7366
|
NodeType.JSXElement,
|
|
@@ -7417,32 +7387,6 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
7417
7387
|
// <Pragma.Fragment>
|
|
7418
7388
|
return name.type === NodeType.JSXMemberExpression && name.object.type === NodeType.JSXIdentifier && name.object.name === pragma && name.property.name === fragment;
|
|
7419
7389
|
}
|
|
7420
|
-
/**
|
|
7421
|
-
* Check if a JSXElement or JSXFragment has only one literal child and is not a child
|
|
7422
|
-
* @param node The AST node to check
|
|
7423
|
-
* @returns `true` if the node has only one literal child and is not a child
|
|
7424
|
-
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} />
|
|
7425
|
-
*/ function isFragmentWithOnlyTextAndIsNotChild(node) {
|
|
7426
|
-
return node.children.length === 1 && isLiteral(node.children[0]) && !(node.parent.type === NodeType.JSXElement || node.parent.type === NodeType.JSXFragment);
|
|
7427
|
-
}
|
|
7428
|
-
function containsCallExpression(node) {
|
|
7429
|
-
return node.type === NodeType.JSXExpressionContainer && node.expression.type === NodeType.CallExpression;
|
|
7430
|
-
}
|
|
7431
|
-
/**
|
|
7432
|
-
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression
|
|
7433
|
-
* @param node The AST node to check
|
|
7434
|
-
* @returns boolean
|
|
7435
|
-
*/ function isFragmentHasLessThanTwoChildren(node) {
|
|
7436
|
-
const nonPaddingChildren = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7437
|
-
if (nonPaddingChildren.length === 1) {
|
|
7438
|
-
return !containsCallExpression(nonPaddingChildren[0]);
|
|
7439
|
-
}
|
|
7440
|
-
return nonPaddingChildren.length === 0;
|
|
7441
|
-
}
|
|
7442
|
-
function isFragmentWithSingleExpression(node) {
|
|
7443
|
-
const children = node.children.filter((child)=>!isPaddingSpaces(child));
|
|
7444
|
-
return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
|
|
7445
|
-
}
|
|
7446
7390
|
|
|
7447
7391
|
// type ReactNode =
|
|
7448
7392
|
// | ReactElement
|
|
@@ -7737,4 +7681,34 @@ function getProp(props, propName, context) {
|
|
|
7737
7681
|
return Option.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
|
|
7738
7682
|
}
|
|
7739
7683
|
|
|
7740
|
-
|
|
7684
|
+
/**
|
|
7685
|
+
* Check if a node is a Literal or JSXText
|
|
7686
|
+
* @param node The AST node to check
|
|
7687
|
+
* @returns boolean `true` if the node is a Literal or JSXText
|
|
7688
|
+
*/ const isLiteral = isOneOf([
|
|
7689
|
+
NodeType.Literal,
|
|
7690
|
+
NodeType.JSXText
|
|
7691
|
+
]);
|
|
7692
|
+
/**
|
|
7693
|
+
* Check if a Literal or JSXText node is whitespace
|
|
7694
|
+
* @param node The AST node to check
|
|
7695
|
+
* @returns boolean `true` if the node is whitespace
|
|
7696
|
+
*/ function isWhiteSpace(node) {
|
|
7697
|
+
return isString(node.value) && node.value.trim() === "";
|
|
7698
|
+
}
|
|
7699
|
+
/**
|
|
7700
|
+
* Check if a Literal or JSXText node is a line break
|
|
7701
|
+
* @param node The AST node to check
|
|
7702
|
+
* @returns boolean
|
|
7703
|
+
*/ function isLineBreak(node) {
|
|
7704
|
+
return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
|
|
7705
|
+
}
|
|
7706
|
+
/**
|
|
7707
|
+
* Check if a Literal or JSXText node is padding spaces
|
|
7708
|
+
* @param node The AST node to check
|
|
7709
|
+
* @returns boolean
|
|
7710
|
+
*/ function isPaddingSpaces(node) {
|
|
7711
|
+
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
7712
|
+
}
|
|
7713
|
+
|
|
7714
|
+
export { JSXValueCheckHint, defaultJSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.13-beta.0",
|
|
4
4
|
"description": "ESLint x React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"./package.json"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@typescript-eslint/scope-manager": "6.13.
|
|
38
|
-
"@typescript-eslint/types": "6.13.
|
|
39
|
-
"@typescript-eslint/utils": "6.13.
|
|
37
|
+
"@typescript-eslint/scope-manager": "6.13.1",
|
|
38
|
+
"@typescript-eslint/types": "6.13.1",
|
|
39
|
+
"@typescript-eslint/utils": "6.13.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"micro-memoize": "4.1.2",
|
|
43
|
-
"@eslint-react/ast": "0.8.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/shared": "0.8.
|
|
43
|
+
"@eslint-react/ast": "0.8.13-beta.0",
|
|
44
|
+
"@eslint-react/types": "0.8.13-beta.0",
|
|
45
|
+
"@eslint-react/tools": "0.8.13-beta.0",
|
|
46
|
+
"@eslint-react/shared": "0.8.13-beta.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "rollup -c rollup.config.ts --configPlugin swc3 && cp dist/index.d.ts dist/index.d.mts",
|