javascript-enforce-newline-after-imports
Add exactly one empty line after the final top-level import declaration block in JavaScript-family files to standardize module preamble formatting and align with eslint-plugin-import’s import/newline-after-import rule.
Installation
bash
Usage
The codemod scans JavaScript and TypeScript module files and normalizes the separator immediately after the final contiguous top-level import block.
- Targets:
*.js,*.jsx,*.mjs,*.cjs,*.ts,*.tsx,*.mts, and*.cts - Rewrites only top-level ES module
importdeclarations at the start of the file - Preserves shebangs, comments, import ordering, and the file's existing line ending style
- Keeps line-sensitive pragma comments such as
eslint-disable-next-lineand@ts-ignoreattached to the following statement - Treats
import typethe same as other imports - Leaves files unchanged when they already have exactly one blank line after the import preamble, contain no top-level imports, contain only imports, or use only
require(...)/ dynamicimport() - Parser failures are reported by the workflow and left unchanged
Example:
ts
becomes:
ts
Run the local package with:
bash
Development
bash
License
MIT