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

Interpretation of trailing comments with ASI formatting #609

Open
cjpearson opened this issue Jan 30, 2024 · 0 comments
Open

Interpretation of trailing comments with ASI formatting #609

cjpearson opened this issue Jan 30, 2024 · 0 comments

Comments

@cjpearson
Copy link

Describe the bug

dprint-plugin-typescript version: 0.88.10

When using the "asi" option for semicolons, formatters will sometimes have to insert a semicolon at the beginning of a line. An example with dprint:

Input

let line1 = 'hello';

// Comment
[].filter(x => x)

Formatted

let line1 = "hello"

// Comment
;[].filter(x => x)

However, if the code is already formatted, dprint will attach the comment to the first statement. Although technically the comment may be contained within the first statement, developers would typically understand the comment to belong to the latter statement and it would nice if dprint could handle this case.

Input Code

let line1 = "hello"

// Comment
;[].filter(x => x)

Expected Output

let line1 = "hello"

// Comment
;[].filter(x => x)

Actual Output

let line1 = "hello" // Comment
;[].filter(x => x)
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