UNPKG

eslint-plugin-sonarjs

Version:
31 lines (30 loc) • 2.09 kB
import type { TSESTree } from '@typescript-eslint/utils'; import type { JSXAttribute } from 'estree-jsx'; export declare function getJsxShortCircuitNodes(logicalExpression: TSESTree.LogicalExpression): TSESTree.LogicalExpression[] | null; /** * Checks whether a JSX element has a matching descendant in a rendered child position. * * This follows JSX children, expressions, conditionals, arrays, TypeScript wrappers, and * map/flatMap callbacks. It deliberately excludes JSX attributes, non-rendering callbacks, * and bare function children. */ export declare function someRenderedJsxDescendant(element: TSESTree.JSXElement, predicate: (element: TSESTree.JSXElement) => boolean, shouldPrune?: (element: TSESTree.JSXElement) => boolean): boolean; /** * Returns the shared conditional root when `child` is one of `parent`'s mutually exclusive * branches - a ternary/`&&`/`||`/`??` operand, an `if` branch, or a `switch` case body - so that * two nodes with the same root are never presented to the user at the same time. Undefined when * `parent` isn't a conditional-rendering construct, or `child` isn't one of its branches. */ export declare function getConditionalBranchRoot(parent: TSESTree.Node, child: TSESTree.Node): TSESTree.Node | undefined; export declare function isArgumentOfRenderingCall(node: TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression): boolean; /** * Checks whether a JSX tag-name expression is a plain identifier, optionally restricted to * one of the given names. Member (`<Foo.Bar>`) and namespaced (`<svg:rect>`) names never match. */ export declare function isJsxIdentifierNamed(name: TSESTree.JSXTagNameExpression | undefined, ...values: string[]): name is TSESTree.JSXIdentifier; /** * Checks whether a node is a JSX element whose tag is a plain identifier, optionally * restricted to one of the given tag names. */ export declare function isJsxElementNamed(node: TSESTree.Node | undefined, ...tagNames: string[]): node is TSESTree.JSXElement; export declare function getStaticText(value: JSXAttribute['value']): string | undefined;