newline-after-import
Enforce a newline after import statements
💼 This rule is enabled in the following configs: recommended, typescript.
🔧 This rule is automatically fixable by the --fix CLI option.
Rule Details
A blank line between the imports and the code that follows them separates a file's dependencies from its body. This rule reports an import statement whose next statement is not an import and starts on the same line or the very next line. The fix inserts the blank line.
- Import statements are
import ... from 'm'(alsoimport type) and TSimport x = require('m'); consecutive ones form one block, and only the last needs the blank line. - The end of the file needs nothing after the last import.
- A comment does not count as code: an import followed by a comment line and then code has its separating line.
Top-level require() calls are not import statements and are not checked.
❌ Incorrect
import a from './a';
const b = a();
import c = require('./c');
export const d = c;✅ Correct
import a from './a';
import c = require('./c');
const b = a();Options
[]No options.
When Not To Use It
When your formatter already enforces blank lines after imports.
Use this rule
npm install -D oxlint-plugin-import-next{ "jsPlugins": ["oxlint-plugin-import-next"], "rules": { "import-next/newline-after-import": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-import-next'], rules: { 'import-next/newline-after-import': 'error', }, },});oxlint-plugin-import-next re-exports eslint-plugin-import-next/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.