Skip to content

no-mocha-arrows fix produces invalid code with comments #303

@gabssnake

Description

@gabssnake

Hi, thanks for your work, love this eslint-plugin :)

I encountered an issue where some code, admittedly very bad, produces invalid output after fixing no-mocha-arrows.

it("writes code in strange ways", () =>
  // This is a disaster waiting to happen
    assert(true)
);

When running eslint --fix it produces output:

it("writes code in strange ways", function ()// This is a disaster waiting to happen { return assert(true)
});

Here's a failing test case (not sure of the expected code) :

+++ b/test/rules/no-mocha-arrows.js
@@ -31,6 +31,11 @@ ruleTester.run('no-mocha-arrows', rules['no-mocha-arrows'], {
+        {
+            code: 'it(() => \n//hello\nassert(hello, false))',
+            errors,
+            output: 'it(function() {\n//hello\nreturn assert(hello, false); })'
+        },

Do you have any pointers for a fix? I'll be happy to contribute!

Kind regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions