Closed PaulTondeur closed 2 years ago
Please provide a runnable reproduction.
There is a default ecmaVersion
for parsing at https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-mdx/src/parser.ts#L48
What else would you like to have to reproduce? As detailed above with the basic eslint config. All that might be missing is another simplest mdx file with an import or jsx code.
A demo GitHub repository for example.
Hi everyone,
In my case I ended up with the following .eslintrc.json
config to get rid of this error:
{
"plugins": ["@typescript-eslint"],
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:storybook/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "error",
"semi": [1, "never"]
},
"overrides": [
{
"files": ["*.mdx", "*.md"],
"extends": "plugin:mdx/recommended",
"parserOptions": {
"ecmaVersion": "latest"
}
}
]
}
What I added for mdx is in overrides.
I had to add *.md in files because #
was being reported as invalid character in VSCode
# yarn 1
yarn add https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx
# yarn 2, 3
yarn add eslint-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx/_pkg.tgz eslint-plugin-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx/_pkg.tgz
# npm
npm i https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx
Please help us to test the fresh new version.
Close in favor of #402, wait for a release from release-v1
branch @wooorm.
I can't explain why but this issue is still happening with latest version. I had to make a mix of multiple suggestions above:
overrides: [
{
files: ['*.md', '*.mdx'],
extends: 'plugin:mdx/recommended',
parserOptions: {
ecmaVersion: 12,
},
},
],
(using latest
for ecmaVersion
was doing nothing, maybe that's the 13 (latest)
that is problematic?)
Initial checklist
Affected packages and versions
latest
Link to runnable example
No response
Steps to reproduce
A very basic example following the instructions within this repo is already failing for me with a parsing error:
I've reduced my
.eslintrc.json
to the simplest possible.When I add the following to the
.eslintrc.json
it works as expectedIf this isn't a bug, it should be documented somewhere. It took a lot of time to figure this out.
Expected behavior
My MDX file should be linted without errors
Actual behavior
0:0 error Parsing error: ImportDeclaration should appear when the mode is ES6 and in the module context
Runtime
Node v16
Package manager
yarn v2, yarn v1
OS
macOS
Build and bundle tools
Next.js