Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect differences being generated with eslintv9 #697

Open
Stono opened this issue Dec 20, 2024 · 2 comments
Open

Incorrect differences being generated with eslintv9 #697

Stono opened this issue Dec 20, 2024 · 2 comments

Comments

@Stono
Copy link

Stono commented Dec 20, 2024

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
@Stono
Copy link
Author

Stono commented Dec 20, 2024

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.

@Stono Stono closed this as completed Dec 20, 2024
@Stono Stono reopened this Dec 20, 2024
@Stono
Copy link
Author

Stono commented Dec 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant