@jsxtools/eslint-plugin-jsx-a11y
Version:
Static AST checker for accessibility rules on JSX elements for flat ESLint Config.
22 lines (19 loc) • 636 B
JavaScript
const jsxAstUtils = require('./module/jsx-ast-utils.cjs');
function getTabIndex(tabIndex) {
const literalValue = jsxAstUtils.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 jsxAstUtils.getPropValue(tabIndex);
}
module.exports = getTabIndex;