Skip to content

Incorrect differences being generated with eslintv9 #697

Open

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

Activity

  1. Stono commented on Dec 20, 2024

    @Stono
    Author

    hmmm actually no this may be fine because you're inserting { on the difference above it.... gah
    So it's back to being an eslint issue I think.

  2. reopened this on Dec 20, 2024
  3. Stono commented on Dec 20, 2024

    @Stono
    Author

    Decided to reopen this because I'm not sure if the issue is with prettier, or eslint, but it only manifests since eslint v9.
    https://github.com/Stono/eslint-19258 contains a reproduction

  4. JounQin commented on Jan 15, 2025

    @JounQin
    Member

    Should report to https://github.com/prettier/prettier-linter-helpers instead.

    cc @BPScott

    Image

    See the last two reports, they can not be applied one by one.

  5. fisker commented on Mar 6, 2025

    @fisker
    Member

    I haven't looked deep, but I highly doubt this is not related to prettier-linter-helpers, should be another conflicting rule.

  6. JounQin commented on Mar 6, 2025

    @JounQin
    Member

    I haven't looked deep, but I highly doubt this is not related to prettier-linter-helpers, should be another conflicting rule.

    Nope. :(

  7. fisker commented on Mar 6, 2025

    @fisker
    Member
  8. fisker commented on Mar 6, 2025

    @fisker
    Member

    No, not related to prettier-linter-helpers, the diff is correct. It's conflicting with no-trailing-spaces. But in a strange way.

  9. JounQin commented on Mar 6, 2025

    @JounQin
    Member

    But in a strange way.

    Yep.

  10. fisker commented on Mar 6, 2025

    @fisker
    Member

    I'll report to ESLint.

  11. fisker commented on Mar 6, 2025

    @fisker
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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