eslint-config-prettier
eslint-config-prettier copied to clipboard
Conflict with import/newline-after-import
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
What do you mean by conflict? prettier will not add new lines at all.
@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.
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.
Or do you mean we should disable import/newline-after-import in this config?
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.