Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enter(path) {
const { node } = path
// 排除 Fragment
// TODO: 考虑 Fragment 重命名情况
if (jsxHelpers.elementType(node).includes('Fragment')) {
return
}
const hasKey = jsxHelpers.hasProp(node.attributes, 'key')
const keyAttr = jsxHelpers.getProp(node.attributes, 'key')
const keyAttrValue = get(keyAttr, 'value.value')
// 排除 key 为以下的项,保证 SSR 时两端结果一致
if (
hasKey &&
['keep-alive-placeholder', 'keeper-container'].includes(
keyAttrValue
)
) {
return
}
const isArrayElement = node.__isArrayElement
// 不允许自定义 _ka 属性
JSXOpeningElement: (node: JSXOpeningElement) => {
if (
isTouchable(node, context) &&
!hasProp(node.attributes, 'accessibilityRole') &&
!hasEveryProp(node.attributes, deprecatedProps) &&
getLiteralPropValue(getProp(node.attributes, 'accessible')) !== false
) {
context.report({
node,
message: errorMessage(elementType(node))
});
}
}
})