Skip to contentSlop Block

require-blank-line-between-import-groups

Warning

Separate import groups with one blank line and keep the imports of a group together.

import { zod } from 'zod'import { delta } from './delta'Separate import groups with exactly one blank line and keep a group together
import { zod } from "zod"; // pinnedimport { delta } from "./delta";Separate import groups with exactly one blank line and keep a group together
import { alpha } from "bun";import { beta } from "bunyan";Separate import groups with exactly one blank line and keep a group together
import { zod } from "zod";import { delta } from "./delta";Separate import groups with exactly one blank line and keep a group together
import "./polyfill";import type { Alpha } from "~/alpha";Separate import groups with exactly one blank line and keep a group together
import type { Alpha } from "~/alpha";import { delta } from "~/delta";Separate import groups with exactly one blank line and keep a group together
import { readFile } from "node:fs";import { zod } from "zod";Separate import groups with exactly one blank line and keep a group together
import {	alpha,	beta,} from "zod";import { root } from ".";Separate import groups with exactly one blank line and keep a group together
import { gamma } from "../gamma";import Icon from "virtual:icons/alpha";Separate import groups with exactly one blank line and keep a group together
import { zod } from "zod";import { delta } from "./delta";Separate import groups with exactly one blank line and keep a group together
import { zod } from "zod";import { react } from "react";Separate import groups with exactly one blank line and keep a group together
import { gamma } from "../gamma";import { delta } from "./delta";Separate import groups with exactly one blank line and keep a group together
import type { Alpha } from "alpha";import type { Beta } from "beta";Separate import groups with exactly one blank line and keep a group together
import "./polyfill";import "./reset";Separate import groups with exactly one blank line and keep a group together
// ast-grep-ignore: require-blank-line-between-import-groups-typescript

How to fix

Leave one blank line between import groups and none inside a group. The groups and their order are the ones in require-import-group-order, with internal and relative imports sharing one group.

The check reads the file's text because the syntax tree omits blank lines. It reports the first import of a group that lacks the blank line before it, or the second import of a group that has a blank line before it. When a block has several mistakes, the report can land on a neighboring import.