eslint-plugin-sonarjs
Version:
34 lines (33 loc) • 2.19 kB
TypeScript
import type { TSESTree } from '@typescript-eslint/utils';
import type { JSXOpeningElement } from 'estree-jsx';
import type { Rule } from 'eslint';
/** Attributes that can hide an element from everyone; see {@link getOwnHiddenState}. */
export declare const HIDING_ATTRIBUTES: readonly ["aria-hidden", "hidden", "style"];
export type HiddenState = 'hidden' | 'visible' | 'unknown';
/** Returns the first recognized, non-abstract role in an ordered fallback list. */
export declare function getFirstConcreteRole(roleValue: string): string | undefined;
export declare function isPresentationTable(context: Rule.RuleContext, node: TSESTree.JSXOpeningElement): boolean;
export declare function getRole(node: TSESTree.JSXOpeningElement): string | undefined;
/**
* Checks whether an accessible-name attribute has a statically non-empty or dynamic value.
*/
export declare function hasAccessibleNameAttribute(attributes: JSXOpeningElement['attributes'], name: string): boolean;
/**
* Checks whether an element has an accessible name via aria-labelledby, aria-label, or a
* direct-child <title> element (in that precedence order). Id references in aria-labelledby
* are not resolved to their target's text, treated purely as a presence check like aria-label.
* Not specific to SVG: the caller decides which elements this check applies to.
*/
export declare function hasAccessibleName(node: TSESTree.JSXOpeningElement): boolean;
export declare const getElementType: (context: Rule.RuleContext) => ((node: TSESTree.JSXOpeningElement) => string);
/**
* Whether the element or an ancestor is hidden via `aria-hidden`, `hidden`, or `display: none`.
* `'unknown'` when none is known to hide it but some value can't be resolved; callers decide how
* to treat it.
*/
export declare function getHiddenState(node: TSESTree.JSXOpeningElement, context: Rule.RuleContext): HiddenState;
/**
* Like {@link getHiddenState}, but for the element's own attributes only. An unresolvable
* `aria-hidden` or `hidden` gives `'unknown'`; an unresolvable `style` never hides.
*/
export declare function getOwnHiddenState(attributes: JSXOpeningElement['attributes'], context: Rule.RuleContext): HiddenState;