Skip to content

"Fix-on-Save" Produces Incorrect Output #1143

Closed
@SE2Dev

Description

@SE2Dev

When enabling "fix on save", vscode-eslint appears to produce different results than it would if you were to explicitly run the "ESLint: Fix all auto-fixable problems" command.

I've managed to correct this behavior by overriding the mode in (resolveSettings](https://github.com/microsoft/vscode-eslint/blob/master/server/src/eslintServer.ts#L1933) by forcing it to treat all fix requests as though they originated from the command.

By the time resolveSettings completes in the attached example, "\n;\n" is included in the results.

The attached example illustrates my point a bit better. Using the included workspace settings, saving index.js will produce a different result than if a user were to explicitly call "ESLint: Fix all auto-fixable problems" or run ESLint from the CLI.

Original Source

const myconst = "hello"
const anothervar = 4

"ESLint: Fix all auto-fixable problems" output:
(eslint cli produces these same results)

const myconst = "hello";
const anothervar = 4;

Fix on Save Output

const myconst = "hello";
const anothervar = 4
;

I've also included lint.js which can be used to see what ESLint's raw message set is, as well as to see how ESLint's CLI resolves file edits (apply_edits is taken almost entirely directly from ESLint's CLI source).

vscode-eslint-bug.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions