import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.42k stars 1.54k forks source link

Issue with eslint-mdx plugin. #2720

Open andrewplummer opened 1 year ago

andrewplummer commented 1 year ago

With the latest eslint-plugin-mdx and eslint-plugin-import, the following eslint config:

{
  "extends": [
    "plugin:mdx/recommended",
    "plugin:import/recommended"
  ]
}

And a single mdx file:

import foo from './foo';

The parser throws an error:

Error while parsing .../foo.js
Line undefined, column undefined: Unsupported file extension, make sure setting the `extensions` or `markdownExtensions` option correctly.
`parseForESLint` from parser `.../node_modules/eslint-mdx/lib/index.js` is invalid and will just be ignored

It seems to be trying to send JS files included from MDX through the eslint-mdx parser. I've tried various configurations (extensions, overrides, etc) but it doesn't seem to work.

Thanks!

ljharb commented 1 year ago

switch the order of your extends array, so mdx comes last.

andrewplummer commented 1 year ago

That didn't seem to have any effect. The resulting error is the same regardless of the order.

ljharb commented 1 year ago

hmm, i'm not really sure then :-/ we don't have any tests for mdx, and i have no experience with it.

If you could provide a repro repo, then hopefully someone will be able to pick it up.

andrewplummer commented 1 year ago

Sure, here's a very simple repro: https://github.com/andrewplummer/repro-mdx-imports

DamienCassou commented 8 months ago

I'm also affected by this issue.