Determine if an HTML tag name is valid
The original code is fine IMO, but technically it's possible to flatten using a complete regexp

var isTagName = /^[A-Za-z]([A-Za-z0-9-]*[A-Za-z0-9])?$/


plus dubious/stinky value fallbacks and ES2015 arrow function:

  create: context =&gt; ({
    CallExpression: node =&gt; {
      if ((node.callee.object || {}).name !== 'by' ||
          (node.callee.property || {}).name !== 'tagName') {
        return
      }
      var tagName = ((node.arguments || [])[0] || {}).value
      if (tagName &amp;&amp; !tagName.match(isTagName)) {
        context.report({
          node,
          message: `Invalid tag name: "${tagName}"`
        })
      }
    }
  })