Skip to content

Incorrect differences being generated with eslintv9 #697

Description

@Stono

Hello
I originally raised this issue over on eslint : eslint/eslint#19258 so there's quite a bit of context there, however I've been debugging and the issue appears to be in the generateDifferences function of the eslint-plugin-prettier package.

It's a bit crude this debugging but on eslint-plugin-prettier.js, lines 243, I added:

            if (source !== prettierSource) {
              const differences = generateDifferences(source, prettierSource);
              if(onDiskFilepath === '/Users/karl.stoney/git/autotrader/node-at-webserver/examples/basic-app/types/client/sdk.gen.ts') {
                console.log(source)
                console.log('--------------->')
                console.log(prettierSource)
                console.log('--------------->')
                console.log(differences)
              }
              for (const difference of differences) {
                reportDifference(context, difference);
              }
            }

If you notice the output in my terminal both source and prettierSource are correct, but the differences generated by generateDifferences includes

{ offset: 622, operation: 'delete', deleteText: '}' }

Which is incorrect.

Screenshot 2024-12-20 at 07 32 42

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions