eslint-plugin-import-x icon indicating copy to clipboard operation
eslint-plugin-import-x copied to clipboard

Rule `newline-after-import` conflicates with prettier

Open ntnyq opened this issue 2 months ago • 2 comments

ESLint config

import { defineConfig } from 'eslint/config'
import pluginImportX from 'eslint-plugin-import-x'

export default defineConfig([
  {
    plugins: {
      'import-x': pluginImportX,
    },
    rules: {
      'import-x/newline-after-import': 'error',
    },
  },
])

Source code

import prettier from 'prettier'

;(() => {})()

ESLint expected output

ESLint consider the code from import to ; as an ImportDeclaration and requires a newline after ; .

import prettier from 'prettier'

;

(() => {})()

Prettier expected output

Prettier treat the IIFE with semi as a whole part and want to delete the newline before it.

import prettier from 'prettier'
;(() => {})()

Repro repo

https://github.com/ntnyq/import-x-and-prettier

ntnyq avatar Sep 16 '25 07:09 ntnyq