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

Parsing Errors: Unterminated JSX contents when using details element #207

Closed
patricklafrance opened this issue May 29, 2020 · 5 comments
Closed
Labels
help wanted 🙏 This could use your insight or help 🙅 no/wontfix This is not (enough of) an issue for this project 🐛 type/bug This is a problem 🙆 yes/confirmed This is confirmed and ready to be worked on

Comments

@patricklafrance
Copy link

Subject of the issue

In VSCode, when using a details element I get the following error: "Parsing Errors: Unterminated JSX contents".

image

I am pretty sure this is because of this plugin since it goes away if I remove the plugin from my ESLint config (bug then I have other errors ;)).

Here's my ESLint config:

module.exports = {
    overrides: [
        {
            globals: {
                "props": true
            },
            files: ["*.mdx"],
            extends: ["plugin:mdx/recommended"],
            rules: {
                "semi": "off",
                "react/jsx-tag-spacing": "off",
                "max-len": "off",
                "react-hooks/rules-of-hooks": "off"
            }
        }
    ]
};

All the tags are closed. I try to paste the code but it doesn't format well becaise it contains markdown.

The file is available here: https://github.com/gsoft-inc/sg-orbit/blob/master/packages/react-components/src/button/stories/custom-color-hover.mdx

Thank you for your help,

Patrick

Your environment

  • OS:
    Windows 10
  • Packages:
    "eslint": "7.1.0",
    "eslint-plugin-mdx": "1.7.0"
  • Env:
    node v13.11.0
    yarn v1.22.4

Steps to reproduce

Tell us how to reproduce this issue. Please provide a working and simplified example.

🎉 BONUS POINTS for creating a minimal reproduction and uploading it to GitHub. This will get you the fastest support. 🎉

Expected behaviour

No error when using <details><summary>

Actual behaviour

What happens instead?

A Parsing Error

@patricklafrance patricklafrance added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels May 29, 2020
JounQin added a commit that referenced this issue May 30, 2020
@JounQin JounQin added 🐛 type/bug This is a problem 🙆 yes/confirmed This is confirmed and ready to be worked on and removed 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels May 30, 2020
@satazor
Copy link

satazor commented Sep 5, 2020

@JounQin The PR at #208 removed the ability to validate JS inside code blocks, such as js or jsx. I would want to validate JS code inside it as well. What's the reason for removing it?

@JounQin
Copy link
Member

JounQin commented Sep 5, 2020

@JounQin The PR at #208 removed the ability to validate JS inside code blocks, such as js or jsx. I would want to validate JS code inside it as well. What's the reason for removing it?

That PR has been closed.

And code block is intended to be ignored because they're not source code but something like string literal. But if you want to lint code blocks, maybe you can try eslint-plugin-markdown.

@satazor
Copy link

satazor commented Sep 5, 2020

@JounQin it seems that both plugins are incompatible. I've tried to setup both with this config:

// .eslintrc.js
const markdownRecommended = require('eslint-plugin-markdown').configs.recommended;

module.exports = {
    root: true,
    env: {
        browser: true,
        node: true,
    },
    extends: [
        'eslint:recommended',
        'plugin:react/recommended',
    ],
    overrides: [
        {
            files: ['*.mdx'],
            extends: ['plugin:mdx/recommended'],
            plugins: ['markdown'],
            processor: 'markdown/markdown',
            parserOptions: markdownRecommended.overrides[0].parserOptions,
            rules: markdownRecommended.overrides[0].rules,
        },
    ],
};

However, only errors coming from eslint-plugin-markdown are reported. Once I comment the line with processor, only errors coming from eslint-mdx are reported. It seems both are incompatible.

Is there anything I'm missing?

@satazor
Copy link

satazor commented Sep 5, 2020

Let me know if you want me to create a new issue.

@JounQin JounQin added the help wanted 🙏 This could use your insight or help label Sep 9, 2020
JounQin added a commit that referenced this issue Feb 20, 2021
@JounQin
Copy link
Member

JounQin commented Feb 20, 2021

@satazor Sorry markdown code in jsx is not supported and not going to happen in v1, but it should be possible in v2.

And I tried to fix part of this issue in #273. What means the following will be able to be parsed.

<details><summary >Override element states</summary>

The previous code sample show how to specify a custom color for a `naked` button by using a `style` attribute. It works great to provide a basic property like a `background-color`. What about [element states](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes) though? You can't specify an hover state with a `style` attribute.

Here's another technique to specify a custom color by using a few CSS classes and a [CSS variable](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties). This technique leverage the ability to override a CSS variable of a stylesheet from the `style` attribute.

In the following example a React component render a button with a custom color `background-color` and a darker hover state by overriding the `--color` CSS variable from the `style` prop.

</details>

JounQin added a commit that referenced this issue Feb 20, 2021
…g - close #272 (#273)

* feat: bump (dev)Dependencies, fix related errors

* fix: consider first jsx node as open tag - close #272

the parsed remark-mdx jsx nodes are not precise, but it will be resolved in v2

* chore: lerna config changes

* test: do not use user environment related test cases

* fix: open close tag regex, push remaining nodes

* fix: part of #207, markdown in jsx is still not supported

improve fixtures test case

* test: remove unnecessary fixture

* docs: add comments for // @ts-ignore and never
@JounQin JounQin added the 🙅 no/wontfix This is not (enough of) an issue for this project label Feb 21, 2021
@JounQin JounQin closed this as completed Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment