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

Works differently with ESLint? #671

Closed
JounQin opened this issue Jun 20, 2022 · 2 comments
Closed

Works differently with ESLint? #671

JounQin opened this issue Jun 20, 2022 · 2 comments

Comments

@JounQin
Copy link

JounQin commented Jun 20, 2022

// .eslintrc
{
  "root": true,
  "rules": {
    "no-unused-expressions": "error",
    "no-unused-vars": "error"
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  },
  "overrides": [
    {
      "files": ["**/*.md"],
      "extends": ["plugin:mdx/recommended", "plugin:prettier/recommended"],
      "rules": {
        "prettier/prettier": [
          "error",
          {
            "parser": "markdown"
          }
        ]
      }
    },
    {
      "files": ["**/*.mdx"],
      "extends": [
        "plugin:react/recommended",
        "plugin:mdx/recommended",
        "plugin:prettier/recommended"
      ],
      "rules": {
        "prettier/prettier": [
          "error",
          {
            "parser": "mdx"
          }
        ]
      }
    }
  ]
}
{
  "xo": {
    "extensions": ["md", "mdx"],
    "rules": {
      "indent": 0,
      "semi": 0
    },
    "overrides": [
      {
        "files": ["**/*.md"],
        "extends": ["plugin:mdx/recommended", "plugin:prettier/recommended"],
        "rules": {
          "prettier/prettier": [
            "error",
            {
              "parser": "markdown"
            }
          ]
        }
      },
      {
        "files": ["**/*.mdx"],
        "extends": [
          "xo-react",
          "plugin:mdx/recommended",
          "plugin:prettier/recommended"
        ],
        "rules": {
          "prettier/prettier": [
            "error",
            {
              "parser": "mdx"
            }
          ]
        }
      }
    ]
  }
}

test.mdx

import { Note } from './_component/note.server.js'

export { Home as default } from './_component/home.server.js'
export const navExclude = true

# 404: Not found

Aww, snap.
Unfortunately this page doesn’t exist.
Perhaps you can find what you’re looking for [on GitHub][search]?

<Note type="info">
  **Note**: Did you come here from a website linking to it? Pretty sure this
  page used to exist? Please [open an
  issue](https://github.com/mdx-js/mdx/issues/new) to let us know so we can fix
  it!
</Note>

[search]: https://github.com/mdx-js/mdx/search
# npx xo test.mdx

test.mdx:12:1
  ✖  12:1  Empty components are self-closing                                       react/self-closing-comp
  ✖  12:2  Expected an assignment or function call and instead saw an expression.  no-unused-expressions

  2 errors
# npx eslint test.mdx

# No error

Reproduction: https://github.com/JounQin/test/tree/xo

@JounQin JounQin changed the title Works different with ESLint? Works differently with ESLint? Jun 20, 2022
@JounQin
Copy link
Author

JounQin commented Jun 20, 2022

react/self-closing-comp error is the same as ESLint if enabled, but not no-unused-expressions.

@JounQin
Copy link
Author

JounQin commented Jun 20, 2022

npx xo --print-config test.mdx > .eslintrc.json

Seems the difference is

{
  "no-unused-expressions": [
  2,
  {
    "enforceForJSX": true,
    "allowShortCircuit": false,
    "allowTernary": false,
    "allowTaggedTemplates": false
    }
  ]
}

@JounQin JounQin closed this as completed Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant