How to use the jsx-ast-utils.elementType function in jsx-ast-utils

To help you get started, we’ve selected a few jsx-ast-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CJY0208 / webpack-multiple-pages / src / vendor / demo / KeepAlive @ / babel / index.js View on Github external
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
          }
github FormidableLabs / eslint-plugin-react-native-a11y / src / factory / valid-prop.js View on Github external
JSXAttribute: (node: JSXAttribute) => {
      const attrName = elementType(node);
      if (attrName === propName) {
        // ensure we are only checking literal prop values
        const attrValue = getLiteralPropValue(node);
        let invalid = false;

        if (Array.isArray(attrValue)) {
          const validate = attrValue.map(strValue =>
            isOneOf(strValue, validValues)
          );
          invalid = validate.indexOf(false) > -1;
        } else {
          invalid = !isOneOf(attrValue, validValues);
        }

        if (invalid) {
          context.report({
github FormidableLabs / eslint-plugin-react-native-a11y / src / rules / has-accessibility-props.js View on Github external
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))
        });
      }
    }
  })