xojs/xo

Works differently with ESLint?

JounQin opened this issue · 2 comments

// .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

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

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

Seems the difference is

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