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

Behavior Change: Protect all comments before the first import (assume they're pragmas/top-of-file) #81

Closed
fbartho opened this issue May 14, 2023 · 0 comments · Fixed by #82
Assignees

Comments

@fbartho
Copy link
Collaborator

fbartho commented May 14, 2023

In #54 (comment) we decided to protect top-of-file (before-first-import) comments more aggressively.

Unhappy Test Case:

/**
 * @prettier
 */
import { b } from 'b';
import type { A } from 'a';
import { a } from 'a';

// Should not become: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import { a, type A } from "a";
/**
 * @prettier
 */
import { b } from "b";
IanVS added a commit that referenced this issue May 16, 2023
Fixes #81 

- This also reverts my `alpha.4` behavior-change where top-of-file
comments always got a newline injected below them. Now we neither inject
nor delete 1 blank line below the last top-of-file-comment.
- This reverts snapshot changes (around top-of-file blank-lines) as
compared to our pre-4.0.0-alpha.4 behavior.
- Fixes some cases where we would introduce a newline when combining type and value imports (reference #54)

---------

Co-authored-by: Ian VanSchooten <ian.vanschooten@gmail.com>
@IanVS IanVS closed this as completed in #82 May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants