prettier / prettier/eslint-plugin-prettier
Incorrect differences being generated with eslintv9
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
Hello
I originally raised this issue over on eslint : https://github.com/eslint/eslint/issues/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in eslint-plugin-prettier.js around line 243 and inspect generateDifferences, using the reported ESLint 9 case where source and prettierSource are correct but a delete for '}' is produced. Trace how the reported difference is derived, then add or update a regression test showing that no incorrect difference is generated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100