non-idempotent comment position before await statement inside try block
Open
Nobody has claimed this yet.
area:comments
area:idempotency
lang:javascript
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.1.2
Input Playground Link
Rerun on Output Playground Link
Note:
Using /* this type of comment */ works around the issue.
Input:
async function promptForSetUpSkeleton(): Promise<SkeletonAnswers> {
let defaultAuthor
try {
defaultAuthor = ( // $FlowFixMe
await spawn('git', ['config', 'user.name'], {
maxBuffer: 1024,
})
).stdout
.toString('utf8')
.trim()
} catch (error) {
// ignore
}
}
Output:
async function promptForSetUpSkeleton(): Promise<SkeletonAnswers> {
let defaultAuthor;
try {
defaultAuthor = // $FlowFixMe
(
await spawn("git", ["config", "user.name"], {
maxBuffer: 1024,
})
).stdout
.toString("utf8")
.trim();
} catch (error) {
// ignore
}
}
Rerun on Output:
async function promptForSetUpSkeleton(): Promise<SkeletonAnswers> {
let defaultAuthor;
try {
defaultAuthor = ( // $FlowFixMe
await spawn("git", ["config", "user.name"], {
maxBuffer: 1024,
})
).stdout
.toString("utf8")
.trim();
} catch (error) {
// ignore
}
}
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 by reproducing the example from the Input Playground Link and compare the first formatting result with the Rerun on Output Playground Link. Trace the formatter entry point for this JavaScript/TypeScript case; done means formatting is idempotent and preserves the comment position around the await statement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100