Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error in mdx files #1433

Closed
cdfa opened this issue Aug 2, 2019 · 9 comments · Fixed by #1435
Closed

Parse error in mdx files #1433

cdfa opened this issue Aug 2, 2019 · 9 comments · Fixed by #1435

Comments

@cdfa
Copy link

cdfa commented Aug 2, 2019

Hi, I'm reporting here too, because I realized an issue I originally reported at babel-plugin-module-resolver might not be specific to that resolver. Please read it for more information.

As I commented there, I also get parse errors when using the default node resolver, but on a different import.

import:

import styled from "styled-components";

Error:

21:20  error    Parse errors in imported module 'styled-components': parser.parse is not a function (undefined:undefined)  import/namespace
21:20  error    Parse errors in imported module 'styled-components': parser.parse is not a function (undefined:undefined)  import/default
21:20  warning  Parse errors in imported module 'styled-components': parser.parse is not a function (undefined:undefined)  import/no-named-as-default
21:20  warning  Parse errors in imported module 'styled-components': parser.parse is not a function (undefined:undefined)  import/no-named-as-default-member
JounQin added a commit to mdx-js/eslint-mdx that referenced this issue Aug 3, 2019
@JounQin
Copy link
Collaborator

JounQin commented Aug 3, 2019

Please try @rxts/eslint-plugin-mdx@0.7.1.

Notice about these new rules: https://github.com/rx-ts/eslint-plugin-mdx#rules

@ljharb
Copy link
Member

ljharb commented Aug 3, 2019

i have no idea what mdx is, but it’s not JavaScript, or supported by node, or Babel, so you’d definitely need your own eslint parser.

@JounQin
Copy link
Collaborator

JounQin commented Aug 3, 2019

It would be better to support parseForESLint at https://github.com/benmosher/eslint-plugin-import/blob/master/utils/parse.js#L45, I can make a PR for it.

@ljharb
Copy link
Member

ljharb commented Aug 3, 2019

I'm not sure what you mean.

That particular utility is for parsing ES Modules or CJS modules (which are files, one module per file) - it's not meant to parse anything else.

@JounQin
Copy link
Collaborator

JounQin commented Aug 3, 2019

@ljharb .mdx is handlered by @rxts/eslint-plugin-mdx, which exported a parseForESLint method without parse method, it should be supported by ESLint.

Reference: https://eslint.org/docs/developer-guide/working-with-custom-parsers

@ljharb
Copy link
Member

ljharb commented Aug 3, 2019

Gotcha - in that case, I agree with your suggestion, and a PR would be great. Thanks!

@JounQin
Copy link
Collaborator

JounQin commented Aug 3, 2019

@ljharb Please take a look at #1435

@cdfa
Copy link
Author

cdfa commented Aug 3, 2019

I updated to @rxts/eslint-plugin-mdx@^0.8.1 and I'm getting a lot less errors, but still some. Please checkout my repo at https://github.com/cdfa/react-turn-reveal/tree/81bcee9cd3a34fdd18904f181c04fc9d5138a56e. The npm script to run eslint on MDX files is lint:mdx:eslint. You can also check out the CI job.

@JounQin
Copy link
Collaborator

JounQin commented Aug 3, 2019

@cdfa please add a separated issue to @rxts/eslint-plugin-mdx repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants