question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to lint MDX components in `2.0.0-next.2`

See original GitHub issue

Initial checklist

Affected packages and versions

2.0.0-next.2

Link to runnable example

No response

Steps to reproduce

module.exports = {
  overrides: [
    {
      files: '*.md{,x}',
      parser: 'eslint-mdx',
      processor: 'mdx/remark',
      plugins: ['mdx'],
      settings: {
        'mdx/code-blocks': true
      }
    },
    {
      files: ['*.md{,x}', '*.{j,t}s{,x}'],
      extends: 'plugin:react/recommended'
    }
  ]
}
# Hello world

\```js
<Foo />
\```

<Foo />

\```jsx
<Foo />
\```

Expected behavior

/Users/dimitri/Desktop/mdx-repro/test.mdx
   7:1  error  'React' must be in scope when using JSX  react/react-in-jsx-scope
   7:2  error  'Foo' is not defined                     react/jsx-no-undef
   4:1  error  'React' must be in scope when using JSX  react/react-in-jsx-scope
   4:2  error  'Foo' is not defined                     react/jsx-no-undef
  10:1  error  'React' must be in scope when using JSX  react/react-in-jsx-scope
  10:2  error  'Foo' is not defined                     react/jsx-no-undef

✖ 6 problems (6 errors, 0 warnings)

Actual behavior

   4:1  error  'React' must be in scope when using JSX  react/react-in-jsx-scope
   4:2  error  'Foo' is not defined                     react/jsx-no-undef
  10:1  error  'React' must be in scope when using JSX  react/react-in-jsx-scope
  10:2  error  'Foo' is not defined                     react/jsx-no-undef

✖ 4 problems (4 errors, 0 warnings)

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
JounQincommented, May 13, 2022

@B2o5T Besides, the two rules are disabled for mdx content in the recommended config at https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-plugin-mdx/src/configs/overrides.ts#L23-L35, that’s why I can’t reproduce it at #393

Of course, the missing tokens are still a problem, but that would be another issue, so close this one for now.


Edit, Just notice you didn’t use plugin:mdx/recommended at all.

1reaction
JounQincommented, May 14, 2022

@B2o5T

Please try:

# yarn 1
yarn add https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-plugin-mdx
# yarn 2, 3
yarn add eslint-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-mdx/_pkg.tgz eslint-plugin-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-plugin-mdx/_pkg.tgz
# npm
npm i https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/cc2cd6c2/eslint-plugin-mdx

It should just work now:

https://github.com/mdx-js/eslint-mdx/pull/394/files#diff-7dc63d54389fc5b805a5cebe74578027e4837d2eb08085555c7792fad8da8552R397

Read more comments on GitHub >

github_iconTop Results From Across the Web

MDX2: Can't resolve '@mdx-js/react' · Issue #18094 - GitHub
Describe the bug Trying to integrate storybook@next with CRA and running into a runtime error To Reproduce Please run 'npm run storybook' in ......
Read more >
Troubleshooting MDX
Unexpected `$type` in code: only import/exports are supported. This error is thrown by our MDX parser. It was introduced in version 2. It...
Read more >
eslint-plugin-mdx - npm
ESLint Parser/Plugin for MDX, helps you lint all ES syntaxes. Linting code blocks can be enabled with mdx/code-blocks setting too!
Read more >
Advanced Features: Using MDX - Next.js
MDX is a superset of markdown that lets you write JSX directly in your markdown files. It is a powerful way to add...
Read more >
storybook failed to fetch dynamically imported module - You.com
so I am using web test runner for lit element version 2 what is happening when I am importing scss file in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found