close

newline-after-import

Configuration

rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/newline-after-import': 'error',
    },
  },
]);

Rule Details

Enforces having one or more empty lines after the last top-level import statement or require call.

This rule supports the following options:

  • count which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to 1.
  • exactCount which enforces the exact number of newlines mentioned in count. This option defaults to false.
  • considerComments which enforces the rule on comments after the last import statement as well when set to true. This option defaults to false.

Examples of incorrect code for this rule:

import * as foo from 'foo';
const FOO = 'BAR';
const FOO = require('./foo');
const BAZ = 1;

Examples of correct code for this rule:

import defaultExport from './foo';

const FOO = 'BAR';
const FOO = require('./foo');
const BAR = require('./bar');

const BAZ = 1;

Original Documentation