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 error: visit is not a function #403

Closed
4 tasks done
frankandrobot opened this issue Jun 26, 2022 · 13 comments
Closed
4 tasks done

Parsing error: visit is not a function #403

frankandrobot opened this issue Jun 26, 2022 · 13 comments

Comments

@frankandrobot
Copy link

Initial checklist

Affected packages and versions

2.0.0

Link to runnable example

No response

Steps to reproduce

The following sample file fails to lint:

---
title: "Summer Duran"
type: art
draft: false
created: "2021-05-28"
---

<SummerDuran1 />

eslint config:

"eslintConfig": {
    "parser": "@typescript-eslint/parser",
    "plugins": [
      "@typescript-eslint"
    ],
    "extends": [
      "eslint:recommended",
      "plugin:react/recommended",
      "plugin:@typescript-eslint/recommended",
      "plugin:react-hooks/recommended",
      "prettier"
    ],
    "overrides": [
      {
        "files": [
          "*.mdx"
        ],
        "extends": [
          "plugin:mdx/recommended"
        ],
        "globals": {
          "AwesomeCutScenes": "readonly"
        },
        "rules": {
          "react/jsx-no-undef": [
            2,
            {
              "allowGlobals": true
            }
          ]
        }
      }
    ],
    "env": {
      "es6": true,
      "browser": true,
      "jest": true,
      "node": true
    },
    "rules": {
      "react/react-in-jsx-scope": 0,
      "react/display-name": 0,
      "react/prop-types": 0,
      "@typescript-eslint/explicit-function-return-type": 0,
      "@typescript-eslint/explicit-module-boundary-types": 0,
      "@typescript-eslint/explicit-member-accessibility": 0,
      "@typescript-eslint/indent": 0,
      "@typescript-eslint/member-delimiter-style": 0,
      "@typescript-eslint/no-explicit-any": 0,
      "@typescript-eslint/no-var-requires": 0,
      "@typescript-eslint/no-use-before-define": 0,
      "@typescript-eslint/no-unused-vars": [
        2,
        {
          "argsIgnorePattern": "^_"
        }
      ],
      "no-console": [
        2,
        {
          "allow": [
            "warn",
            "error"
          ]
        }
      ]
    },
    "settings": {
      "react": {
        "version": "detect"
      }
    }
  },

Expected behavior

  • should lint
  • but upgrading to eslint 8.X breaks the MDX parser

Actual behavior

  • the above error

environment

"eslint": "8.18.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-mdx": "2.0.0",
    "eslint-plugin-react": "7.21.5",
    "eslint-plugin-react-hooks": "4.6.0",

Runtime

Node v16

Package manager

yarn v1

OS

macOS

Build and bundle tools

Next.js

@JounQin
Copy link
Member

JounQin commented Jun 26, 2022

A minimal reproduction is required.

@frankandrobot
Copy link
Author

frankandrobot commented Jun 26, 2022 via email

@JounQin
Copy link
Member

JounQin commented Jun 26, 2022

Please remember, we're using our free time to support OSS, a minimal reproduction is a basic respect for us so that we don't waste time to reproduce.

A GitHub repository or fork this repository and PR with a failing test will save time both of us.

@JounQin
Copy link
Member

JounQin commented Jun 26, 2022

Like privatenumber/get-tsconfig#19, you can add a test case at https://github.com/mdx-js/eslint-mdx/tree/master/test/fixtures

If it can't be reproduced this way, then a GitHub repository minimal reproduction is required.

@JounQin
Copy link
Member

JounQin commented Jun 26, 2022

close for now, feel free to comment if you provide reproduction correctly.

@JounQin JounQin closed this as completed Jun 26, 2022
@Manubi
Copy link

Manubi commented Jun 27, 2022

I do get the same error: Parsing error: visit is not a function eslint
CleanShot 2022-06-27 at 15 12 10@2x

jgerigmeyer added a commit to oddbird/Metecho that referenced this issue Jun 27, 2022
jgerigmeyer added a commit to oddbird/Metecho that referenced this issue Jun 27, 2022
* main:
  Do not upgrade eslint-plugin-mdx: mdx-js/eslint-mdx#403
  Automated dependency upgrades
jgerigmeyer added a commit to oddbird/MetaDeploy that referenced this issue Jun 27, 2022
jgerigmeyer added a commit to oddbird/MetaDeploy that referenced this issue Jun 27, 2022
* main:
  Do not upgrade eslint-plugin-mdx: mdx-js/eslint-mdx#403
  Automated dependency upgrades
  Re-enable regular runners
@JounQin
Copy link
Member

JounQin commented Jun 27, 2022

Again, please provide a runnable reproduction instead of just screenshots. That doesn’t help anything.

@JounQin
Copy link
Member

JounQin commented Jun 27, 2022

Just guessing, it should be related to different version of unist-util-visit installed, it can be added into package.json.

@JounQin
Copy link
Member

JounQin commented Jun 28, 2022

workaround yarn add -D unist-util-visit vfile

I'll raise a PR to fix it soon.

@JounQin
Copy link
Member

JounQin commented Jun 28, 2022

@JounQin
Copy link
Member

JounQin commented Jun 28, 2022

I can confirm it's working as expected now:

gitpod /workspace/eslint-mdx-visit-issue (main) $ yarn add -D https://pkg.csb.dev/mdx-js/eslint-mdx/commit/98013f6e/eslint-plugin-mdx

gitpod /workspace/eslint-mdx-visit-issue (main) $ yarn lint
yarn run v1.22.19
$ eslint --ext .ts,.tsx,.js,.jsx,.mdx src

/workspace/eslint-mdx-visit-issue/src/App.tsx
  1:10  warning  'useState' is defined but never used     @typescript-eslint/no-unused-vars
  5:5   error    'React' must be in scope when using JSX  react/react-in-jsx-scope
  6:7   error    'React' must be in scope when using JSX  react/react-in-jsx-scope
  7:9   error    'React' must be in scope when using JSX  react/react-in-jsx-scope

/workspace/eslint-mdx-visit-issue/src/stories/Button.stories.mdx
  1:24  warning  'Story' is defined but never used  @typescript-eslint/no-unused-vars

✖ 5 problems (3 errors, 2 warnings)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
gitpod /workspace/eslint-mdx-visit-issue (main) $ 

@frankandrobot
Copy link
Author

frankandrobot commented Jun 28, 2022

What's the workaround @JounQin ? When I try to install vifile, yarn says that package doesn't exist :-)

Update: BTW, when I yarn install the build, still getting the same error.

@JounQin
Copy link
Member

JounQin commented Jun 28, 2022

What's the workaround @JounQin ? When I try to install vifile, yarn says that package doesn't exist :-)

Update: BTW, when I yarn install the build, still getting the same error.

Sorry, it's vfile.

And a new temporary fixed version of eslint-plugin-mdx is

yarn add https://pkg.csb.dev/mdx-js/eslint-mdx/commit/98013f6e/eslint-plugin-mdx

See https://ci.codesandbox.io/status/mdx-js/eslint-mdx/pr/405/builds/265745 for more installation details for other npm clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants