@jsxtools/eslint-plugin-jsx-a11y
Version:
Static AST checker for accessibility rules on JSX elements for flat ESLint Config.
22 lines (19 loc) • 637 B
JavaScript
import { getLiteralPropValue, getPropValue } from './module/jsx-ast-utils.js';
function getTabIndex(tabIndex) {
const literalValue = getLiteralPropValue(tabIndex);
if (["string", "number"].indexOf(typeof literalValue) > -1) {
if (typeof literalValue === "string" && literalValue.length === 0) {
return void 0;
}
const value = Number(literalValue);
if (Number.isNaN(value)) {
return void 0;
}
return Number.isInteger(value) ? value : void 0;
}
if (literalValue === true || literalValue === false) {
return void 0;
}
return getPropValue(tabIndex);
}
export { getTabIndex as default };