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

no-mocha-arrows autofix with parsers #243

Open
Hyzual opened this issue Apr 16, 2020 · 4 comments
Open

no-mocha-arrows autofix with parsers #243

Hyzual opened this issue Apr 16, 2020 · 4 comments
Labels

Comments

@Hyzual
Copy link

Hyzual commented Apr 16, 2020

Hi !
I wanted to use mocha/no-mocha-arrows for our Cypress test suite, but the autofix behaviour seems a bit odd in our case.
I've built a reproduction case on runkit here: https://runkit.com/hyzual/mocha-no-mocha-arrows

It looks like when you combine "vue-eslint-parser" with "@typescript-eslint/parser", the autofix breaks down and adds multiple function() at the top of the file instead of replacing arrow functions below.

Other autofixes for different plugins work well even with the two parsers.
Let me know if more info is needed.

@Naktibalda
Copy link

I have the same issue, but I don't use vue-eslint-parser.

I use

    "@typescript-eslint/eslint-plugin": "^2.28.0",
    "@typescript-eslint/parser": "^2.28.0",
    "eslint-config-airbnb-typescript": "^7.2.1",
    "eslint-config-prettier": "^6.10.1",
    "eslint-formatter-gitlab": "^1.1.0",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-mocha": "^6.3.0",
    "eslint-plugin-prettier": "^3.1.3",

@lo1tuma
Copy link
Owner

lo1tuma commented Apr 23, 2020

If this is only a problem with third-party parser but not the default parser I would think this is an issue in the parsers.

@saiya
Copy link

saiya commented May 2, 2020

Hi, I installed this plugin and it helps us to write healthy test code so much, thank you.

Talking about this issue, Vue.js is unrelated.
I encountered same issue with pure TypeScript project.

I forked @Hyzual 's reproduction code and removed Vue.js related things: https://runkit.com/saiya-moebius/mocha-no-mocha-arrows-autofix

mocha/no-mocha-arrows breaks TypeScript code parsed with @typescript-eslint/parser.
It inserts function() in the beginning of the file as shown in the reproduction code, this is what I see too.

If eslint-plugin-mocha's autofix works well with the @typescript-eslint/parser, it improves TypeScript w/mocha productivity a lot. Thank you for making this plugin.

@lo1tuma
Copy link
Owner

lo1tuma commented Jul 31, 2020

If someone provides an easy fix that doesn’t need to interact with @typescript-eslint/parser directly I’m happy to review and merge a PR.

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

No branches or pull requests

4 participants