<p dir="auto">(I don't know if it's really a bug or if we're not supposed to do this, but it works fine when using jsx)</p>
<p dir="auto">When using the arrow function as a module exports, the generated code is wrong.<br>
The following (useless but minimal) example</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = () =&gt; arguments;"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">arguments</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">will lead to the generated code</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var _arguments = arguments;
module.exports = function () {
  return _arguments;
};"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">_arguments</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">;</span>
<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-s1">_arguments</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">while</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = function () { return arguments; };"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-smi">arguments</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">leads to the correct version.</p>
<h2 dir="auto">Bug Report</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I would like to work on a fix!</li>
</ul>

<p dir="auto"><strong>Current behavior</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: Cannot read property 'range' of null
Occurred while linting /home/jayen/docs/work/ridethewaverley/ride-the-waverley/src/util/writeresource.js:1
    at OffsetStorage.setDesiredOffset (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:341:45)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1397:29
    at Array.forEach (&lt;anonymous&gt;)
    at Object.TemplateLiteral [as listener] (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1389:34)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1635:55
    at Array.forEach (&lt;anonymous&gt;)
    at Program:exit (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1635:26)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (&lt;anonymous&gt;)
    at Object.emit (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/linter/safe-emitter.js:45:38)"><pre class="notranslate"><code class="notranslate">TypeError: Cannot read property 'range' of null
Occurred while linting /home/jayen/docs/work/ridethewaverley/ride-the-waverley/src/util/writeresource.js:1
    at OffsetStorage.setDesiredOffset (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:341:45)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1397:29
    at Array.forEach (&lt;anonymous&gt;)
    at Object.TemplateLiteral [as listener] (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1389:34)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1635:55
    at Array.forEach (&lt;anonymous&gt;)
    at Program:exit (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/rules/indent.js:1635:26)
    at /home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (&lt;anonymous&gt;)
    at Object.emit (/home/jayen/docs/work/ridethewaverley/ride-the-waverley/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
</code></pre></div>
<p dir="auto">Was not able to reproduce in codesandbox.</p>
<p dir="auto"><strong>Input Code</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const foo = '';
require(`${foo}`)?.bar;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s">''</span><span class="pl-kos">;</span>
<span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">foo</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span><span class="pl-kos">?.</span><span class="pl-c1">bar</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior</strong></p>

<p dir="auto">Expected an assignment or function call and instead saw an expression. (no-unused-expressions)</p>
<p dir="auto"><strong>Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)</strong></p>
<ul dir="auto">
<li>Filename: <code class="notranslate">eslintrc-that-CRA4-wont-find.json</code></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;extends&quot;: &quot;react-app&quot;,
  &quot;rules&quot;: {
    &quot;array-bracket-spacing&quot;: [
      &quot;error&quot;,
      &quot;never&quot;
    ],
    &quot;comma-dangle&quot;: [
      &quot;error&quot;,
      &quot;always-multiline&quot;
    ],
    &quot;indent&quot;: [
      &quot;error&quot;,
      2,
      {
        &quot;CallExpression&quot;: {
          &quot;arguments&quot;: &quot;first&quot;
        },
        &quot;MemberExpression&quot;: &quot;off&quot;,
        &quot;flatTernaryExpressions&quot;: true,
        &quot;ignoredNodes&quot;: [
          &quot;JSXElement *&quot;
        ]
      }
    ],
    &quot;object-curly-spacing&quot;: [
      &quot;error&quot;,
      &quot;never&quot;
    ],
    &quot;react/jsx-indent-props&quot;: [
      &quot;error&quot;,
      &quot;first&quot;
    ],
    &quot;react/jsx-tag-spacing&quot;: [
      &quot;error&quot;,
      {
        &quot;beforeSelfClosing&quot;: &quot;never&quot;,
        &quot;beforeClosing&quot;: &quot;never&quot;
      }
    ],
    &quot;react/self-closing-comp&quot;: [
      &quot;error&quot;,
      {
        &quot;component&quot;: true,
        &quot;html&quot;: true
      }
    ],
    &quot;sort-keys&quot;: [
      &quot;error&quot;,
      &quot;asc&quot;,
      {
        &quot;caseSensitive&quot;: false,
        &quot;natural&quot;: true
      }
    ],
    &quot;sort-vars&quot;: &quot;error&quot;
  }
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"extends"</span>: <span class="pl-s">"react-app"</span><span class="pl-kos">,</span>
  <span class="pl-s">"rules"</span>: <span class="pl-kos">{</span>
    <span class="pl-s">"array-bracket-spacing"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-s">"never"</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"comma-dangle"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-s">"always-multiline"</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"indent"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-c1">2</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span>
        <span class="pl-s">"CallExpression"</span>: <span class="pl-kos">{</span>
          <span class="pl-s">"arguments"</span>: <span class="pl-s">"first"</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-s">"MemberExpression"</span>: <span class="pl-s">"off"</span><span class="pl-kos">,</span>
        <span class="pl-s">"flatTernaryExpressions"</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-s">"ignoredNodes"</span>: <span class="pl-kos">[</span>
          <span class="pl-s">"JSXElement *"</span>
        <span class="pl-kos">]</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"object-curly-spacing"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-s">"never"</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"react/jsx-indent-props"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-s">"first"</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"react/jsx-tag-spacing"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span>
        <span class="pl-s">"beforeSelfClosing"</span>: <span class="pl-s">"never"</span><span class="pl-kos">,</span>
        <span class="pl-s">"beforeClosing"</span>: <span class="pl-s">"never"</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"react/self-closing-comp"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span>
        <span class="pl-s">"component"</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-s">"html"</span>: <span class="pl-c1">true</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"sort-keys"</span>: <span class="pl-kos">[</span>
      <span class="pl-s">"error"</span><span class="pl-kos">,</span>
      <span class="pl-s">"asc"</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span>
        <span class="pl-s">"caseSensitive"</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
        <span class="pl-s">"natural"</span>: <span class="pl-c1">true</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"sort-vars"</span>: <span class="pl-s">"error"</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
  Binaries:
    Node: 14.16.0 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.11 - /usr/bin/npm
  npmPackages:
    @babel/eslint-parser: ^7.13.10 =&gt; 7.13.10 
    eslint: ^7.23.0 =&gt; 7.23.0 "><pre class="notranslate"><code class="notranslate">  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
  Binaries:
    Node: 14.16.0 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.11 - /usr/bin/npm
  npmPackages:
    @babel/eslint-parser: ^7.13.10 =&gt; 7.13.10 
    eslint: ^7.23.0 =&gt; 7.23.0 
</code></pre></div>
<ul dir="auto">
<li>Babel version(s): [7.12.3]</li>
<li>Node/npm version: [Node 14.16.0/npm 6.14.11]</li>
<li>OS: [Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)]</li>
<li>Monorepo: [no]</li>
<li>How you are using Babel: [<code class="notranslate">eslint</code>]</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong></p>

<p dir="auto">No but my workaround is to separate the require from the optional chaining.</p>
<p dir="auto"><strong>Additional context</strong></p>