<p dir="auto">Asked a bit in the IRC channel and it was suggested that this should be the case. Basically, if you imagine a real time linter (kind of like Babel's Try It) that just wants to show errors, or a syntax highlighter that also shows errors, it would be nice to show Duplicate Declaration Errors (let x = 10; let x = 10;).</p>
<p dir="auto">As of right now it appears that the only way to get this is through going through a transform (as opposed to babylon.parse just throwing it). This is unfortunate since its a lot of extra work since I won't actually be using the transform, just wanting to get this one error. I might be wrong here and there is some in-between step you can do to get this but I don't know.</p>
<p dir="auto">I am aware that this is kind of a strange error since it waits to happen until called, so its kind of in the middle, but again unfortunate to require the full sweep.</p>
<p dir="auto">The following ES6 code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var x = {x: 1, x: 2};"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-c1">x</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">x</span>: <span class="pl-c1">2</span><span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">generates the following code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var x = { x: 1, x: 2 };"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">x</span>: <span class="pl-c1">2</span> <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">which will result in an error for ES5-compliant engines. I'm not sure what should be done here instead as duplicate keys are back to being valid in strict mode in ES6, but maybe something like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var x = { x: 1 };
x.x = 2;"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-c1">1</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-s1">x</span><span class="pl-kos">.</span><span class="pl-c1">x</span> <span class="pl-c1">=</span> <span class="pl-c1">2</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">This bug also occurs with JSX:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var x = &lt;x x={1} x={2} /&gt;;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-c1">&lt;</span><span class="pl-s1">x</span> <span class="pl-c1">x</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-c1">1</span><span class="pl-kos">}</span> <span class="pl-c1">x</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-c1">2</span><span class="pl-kos">}</span> <span class="pl-c1">/</span><span class="pl-c1">&gt;</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">becomes</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var x = React.createElement(&quot;x&quot;, { x: 1, x: 2 });"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-v">React</span><span class="pl-kos">.</span><span class="pl-en">createElement</span><span class="pl-kos">(</span><span class="pl-s">"x"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">x</span>: <span class="pl-c1">2</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>