@jsxtools/eslint-plugin-jsx-a11y
Version:
Static AST checker for accessibility rules on JSX elements for flat ESLint Config.
23 lines (20 loc) • 624 B
JavaScript
import { getProp } from './module/jsx-ast-utils.js';
const isNonLiteralProperty = (attributes, propName) => {
const prop = 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;
};
export { isNonLiteralProperty as default };