<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" checked=""> I would like to work on a fix!</li>
</ul>
<p dir="auto"><strong>Current behavior</strong><br>
As suggested in your documentation, if you create a fork of @babel/parser and try to call that in <code class="notranslate">parserOverride()</code>, it will fail with a parsing error. Even if you make a copy of the @babel/parser folder in node_modules, call it @babel/parser2, it will fail with the same error if you try to use that instead. It is the same issue reported here in the old babel-eslint repo:</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="474696080" data-permission-text="Title is private" data-url="https://github.com/babel/babel-eslint/issues/786" data-hovercard-type="issue" data-hovercard-url="/babel/babel-eslint/issues/786/hovercard" href="https://github.com/babel/babel-eslint/issues/786">babel/babel-eslint#786</a></p>
<p dir="auto">Basically because <code class="notranslate">eslint/babel-eslint-parser/src/convert/convertTokens.js</code> is using the types exported by @babel/core, (which is from @babel/parser), all type comparisons will fail, <em>unless</em> you are using the parser from @babel/parser, which defeats the point of <code class="notranslate">parserOverride()</code></p>
<p dir="auto"><strong>Environment</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  Babel: 7.12.11
  System:
    OS: Windows 10 10.0.19041
  Binaries:
    Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD"><pre class="notranslate"><code class="notranslate">  Babel: 7.12.11
  System:
    OS: Windows 10 10.0.19041
  Binaries:
    Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
</code></pre></div>
<p dir="auto"><strong>Possible Solution</strong><br>
As suggested here, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="379294926" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/9009" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/9009/hovercard" href="https://github.com/babel/babel/issues/9009">#9009</a>, a <code class="notranslate">typesOverride</code> option either for babel itself or babel-eslint-parser could solve this issue. I have already implemented this on my own fork as an option to babel-eslint-parser and it works fine, although it would make more sense to put this on a lower level and change the types exported by @babel/core. What do you think?</p>
<p dir="auto"><strong>Additional context</strong><br>
Related issues:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="379294926" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/9009" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/9009/hovercard" href="https://github.com/babel/babel/issues/9009">#9009</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="474696080" data-permission-text="Title is private" data-url="https://github.com/babel/babel-eslint/issues/786" data-hovercard-type="issue" data-hovercard-url="/babel/babel-eslint/issues/786/hovercard" href="https://github.com/babel/babel-eslint/issues/786">babel/babel-eslint#786</a></p>
<p dir="auto">Is there a way to specify a custom version of <code class="notranslate">@babel/types</code> to be used when using a custom parser with the <code class="notranslate">parserOverride</code> option? I am working on an experimental plugin that requires custom syntax, so I forked @babel/parser and got the parsing part working, and <code class="notranslate">parserOverride</code> works well to tell Babel to use my custom version of babel-parser. I also forked babel-types and pointed my package.json to the forked version. But <code class="notranslate">@babel/core</code> is still loading the official version of <code class="notranslate">@babel/types</code>, so in my transform plugin, I can't write visitors for the new AST types I added.</p>
<p dir="auto">If the ability to specify a custom version of babel-types isn't currently available, I think this would be an important feature to add, otherwise it definitely limits the usefulness of <code class="notranslate">parserOverride</code>. It occurred to me that I might be able to use yarn's <a href="https://yarnpkg.com/lang/en/docs/selective-version-resolutions/" rel="nofollow">resolutions</a> feature as a workaround, but then anyone else who wants to try my plugin would also need this configuration in their project. I'm open to any other ideas of how to force <code class="notranslate">@babel/core</code> to use my forked version of <code class="notranslate">@babel/types</code>... Thanks!</p>