eslint-plugin-mocha
eslint-plugin-mocha copied to clipboard
no-mocha-arrows autofix with parsers
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.
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",
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.
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.
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.