IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
951 stars 21 forks source link

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

Closed fbartho closed 1 year ago

fbartho commented 1 year ago

In https://github.com/IanVS/prettier-plugin-sort-imports/issues/54#issuecomment-1546917730 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";