@eslint-react/jsx
Advanced tools
Comparing version 0.5.8 to 0.5.9
@@ -8,10 +8,32 @@ import { TSESTree } from '@typescript-eslint/types'; | ||
/** | ||
* Check if a JSXElement or JSXFragment has children | ||
* Check if a `JSXElement` or `JSXFragment` has children | ||
* @param node The AST node to check | ||
* @param predicate A predicate to filter the children | ||
* @returns `true` if the node has children | ||
*/ | ||
declare function hasChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean; | ||
declare function hasChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment, predicate?: (node: TSESTree.JSXChild) => boolean): boolean; | ||
/** | ||
* Check if a node is a child of a `JSXElement` | ||
* @param node The AST node to check | ||
* @returns `true` if the node is a child of a `JSXElement` | ||
*/ | ||
declare function isChildOfJSXElement(node: TSESTree.Node): node is TSESTree.JSXElement & { | ||
parent: TSESTree.JSXElement; | ||
}; | ||
declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean; | ||
/** | ||
* Check if a node is a `JSXElement` of `User-Defined Component` type | ||
* @param node The AST node to check | ||
* @returns `true` if the node is a `JSXElement` of `User-Defined Component` type | ||
*/ | ||
declare function isJSXElementOfUserDefinedComponent(node: TSESTree.Node): node is TSESTree.JSXElement; | ||
/** | ||
* Check if a node is a `JSXFragment` of `Built-in Component` type | ||
* @param node The AST node to check | ||
* @returns `true` if the node is a `JSXFragment` of `Built-in Component` type | ||
*/ | ||
declare function isJSXElementOfBuiltinComponent(node: TSESTree.Node): node is TSESTree.JSXFragment; | ||
declare function getFragmentFromContext<T extends RuleContext>(context: T): string; | ||
@@ -76,2 +98,29 @@ declare const getPragmaFromContext: <T extends RuleContext>(context: T) => string; | ||
declare const isFragment: (node: TSESTree.Node, pragma: string, fragment: string) => node is TSESTree.JSXElement | TSESTree.JSXFragment; | ||
/** | ||
* Check if a node is `<></>` | ||
*/ | ||
declare const isFragmentSyntax: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment; | ||
/** | ||
* Check if a node is `<Fragment></Fragment>` or `<Pragma.Fragment></Pragma.Fragment>` | ||
* @param node | ||
* @param pragma | ||
* @param fragment | ||
*/ | ||
declare function isFragmentElement(node: TSESTree.JSXElement, pragma: string, fragment: string): boolean; | ||
/** | ||
* Check if a JSXElement or JSXFragment has only one literal child and is not a child | ||
* @param node The AST node to check | ||
* @returns `true` if the node has only one literal child and is not a child | ||
* @example Somehow fragment like this is useful: <Foo content={<>ee eeee eeee ...</>} /> | ||
*/ | ||
declare function isFragmentWithOnlyTextAndIsNotChild(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean; | ||
/** | ||
* Check if a JSXElement or JSXFragment has less than two non-padding children and the first child is not a call expression | ||
* @param node The AST node to check | ||
* @returns boolean | ||
*/ | ||
declare function isFragmentHasLessThanTwoChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean; | ||
declare function isFragmentWithSingleExpression(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean; | ||
type JSXValueCheckOptions = { | ||
@@ -201,3 +250,9 @@ /** | ||
declare function isLineBreak(node: TSESTree.Node): boolean; | ||
/** | ||
* Check if a Literal or JSXText node is padding spaces | ||
* @param node The AST node to check | ||
* @returns boolean | ||
*/ | ||
declare function isPaddingSpaces(node: TSESTree.Node): boolean; | ||
export { type CallFromPragmaPredicate, type JSXValueCheckOptions, defaultJSXValueCheckOptions, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getPropName, getPropNameWithNamespace, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXValue, isLineBreak, isLiteral, isPropertyOfPragma, isWhiteSpace, traverseUpProp }; | ||
export { type CallFromPragmaPredicate, type JSXValueCheckOptions, defaultJSXValueCheckOptions, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getPropName, getPropNameWithNamespace, 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, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp }; |
{ | ||
"name": "@eslint-react/jsx", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"description": "AST Utility Module for Static Analysis of JSX", | ||
@@ -43,6 +43,6 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"devDependencies": { | ||
"@eslint-react/ast": "0.5.8", | ||
"@eslint-react/types": "0.5.8", | ||
"@eslint-react/tools": "0.5.8", | ||
"@eslint-react/shared": "0.5.8" | ||
"@eslint-react/shared": "0.5.9", | ||
"@eslint-react/types": "0.5.9", | ||
"@eslint-react/ast": "0.5.9", | ||
"@eslint-react/tools": "0.5.9" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
718276
21856