prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.34k stars 251 forks source link

Conflict with import/newline-after-import #287

Open codectl opened 2 months ago

codectl commented 2 months ago

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
JounQin commented 2 months ago

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

vilnytskyi commented 3 weeks ago

@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.

JounQin commented 3 weeks ago

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 commented 1 week ago

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

lydell commented 1 week ago

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.