prettier-plugin-imports
Version:
A prettier plugins to sort imports in provided RegEx order
34 lines (30 loc) • 819 B
text/typescript
import { expect, test } from 'vitest';
import { getImportFlavorOfNode } from './get-import-flavor-of-node';
import { getImportNodes } from './get-import-nodes';
test('should correctly classify a bunch of import expressions', () => {
expect(
getImportNodes(
`
import "./side-effects";
import { a } from "a";
import type { b } from "b";
import { type C } from "c";
import D from "d";
import e = require("e"); // Doesn't count as import
const f = require("f"); // Doesn't count as import
// prettier-ignore
import { g } from "g";
`,
{ plugins: ['typescript'] },
).map((node) => getImportFlavorOfNode(node)),
).toMatchInlineSnapshot(`
[
"side-effect",
"value",
"type",
"value",
"value",
"prettier-ignore",
]
`);
});