Skip to content

Rule newline-after-import conflicates with prettier #430

@ntnyq

Description

@ntnyq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions