mdx-js / eslint-mdx

ESLint Parser/Plugin for MDX
https://npmjs.org/eslint-plugin-mdx
MIT License
259 stars 29 forks source link

Parser error for boolean attributes without an explicit value #429

Closed jvdl closed 1 year ago

jvdl commented 1 year ago

Initial checklist

Affected packages and versions

2.0.4

Link to runnable example

https://github.com/jvdl/eslint-plugin-mdx-boolean-attributes

Steps to reproduce

I was able to keep the reproduction very minimal and it only requires eslint and eslint-plugin-mdx together with some ESLint config and an MDX file to lint.

The ESLint configuration I used was

module.exports = {
  overrides: [
    {
      files: ['*.mdx'],
      extends: 'plugin:mdx/recommended',
    },
  ],
  rules: {},
};

Beyond this the only other required items are:

There's a minimal repro available, and I've also added a failing test in my fork of this repo.

Expected behavior

The file is linted correctly.

Boolean attributes are truthy by virtue of their presence, rather than their explicitly assigned value.

Actual behavior

The linter throws an error when attempting to parse the file.

Runtime

Node v16

Package manager

npm v8

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)

JounQin commented 1 year ago

Thanks for reproduction, I'll check soon.

JounQin commented 1 year ago

@jvdl Please help to test:

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

Nice one @JounQin that seems to work perfectly!

ransomledair commented 1 year ago

I have observed this same issue for empty string props. e.g.

<MyComponent myProp="" />

results in

  0:0  error  Parsing error: Expected value to be truthy

from mdx eslint.