<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<ul>
<li>Some text</li>
<li>More some text</li>
<li>I need more text</li>
</ul>
<ul>
<li>Some text <a href="#">and some link</a></li>
<li>More some text</li>
<li>I need more text</li>
</ul>
const isOnlyLinks = ul => Array
.from(ul.querySelectorAll(':scope > li'))
.every(({ childNodes: n }) => !~-n.length && n[0] instanceof HTMLAnchorElement);
const isOnlyLinks = ul =>
Array.prototype.every.call(
ul.children,
({ childNodes: [ a, b ] }) => a && a.tagName === 'A' && !b,
);