UNPKG

@jsxtools/eslint-plugin-jsx-a11y

Version:

Static AST checker for accessibility rules on JSX elements for flat ESLint Config.

23 lines (20 loc) 637 B
const jsxAstUtils = require('./module/jsx-ast-utils.cjs'); const isNonLiteralProperty = (attributes, propName) => { const prop = jsxAstUtils.getProp(attributes, propName); if (!prop) return false; const propValue = prop.value; if (!propValue) return false; if (propValue.type === "Literal") return false; if (propValue.type === "JSXExpressionContainer") { const { expression } = propValue; if (expression.type === "Identifier" && expression.name === "undefined") return false; if (expression.type === "JSXText") return false; } return true; }; module.exports = isNonLiteralProperty;