eslint-config-prettier icon indicating copy to clipboard operation
eslint-config-prettier copied to clipboard

Conflict with import/newline-after-import

Open codectl opened this issue 1 year ago • 5 comments
trafficstars

I have the following set of rules:

import importPlugin from "eslint-plugin-import"
import prettierPlugin from "eslint-plugin-prettier"

export default [
  {
    plugins: {
      "import": importPlugin,
      "prettier": prettierPlugin,
    },
    rules: {
      "prettier/prettier": "error",
      "import/newline-after-import": ["error", { count: 2 }],
  }
]

Which results in an error:

Expected 2 empty lines after import statement not followed by another import  import/newline-after-import

codectl avatar May 02 '24 14:05 codectl

What do you mean by conflict? prettier will not add new lines at all.

JounQin avatar May 03 '24 04:05 JounQin

@JounQin Not sure OP came here with the same issue as I have but prettier basically overwrites 2 newlines with 1, so it doesn't respect that rule for some reason.

vilnytskyi avatar Jun 23 '24 10:06 vilnytskyi

Sorry, but that's how prettier works that it prints codes on its own style, so two empty lines will be reprinted as one line.

JounQin avatar Jun 23 '24 11:06 JounQin

Or do you mean we should disable import/newline-after-import in this config?

JounQin avatar Jul 04 '24 14:07 JounQin

To me, this issue sounds like a feature request for supporting the eslint-plugin-import plugin (and its fork?). For import/newline-after-import, it looks safe to use with Prettier as long as you set it to 1 empty line (not more), so it would need a validator and “special rule” docs.

lydell avatar Jul 04 '24 15:07 lydell