Prettier-eslint removes empty line between imports incorrectly
See original GitHub issueVersions:
prettier-eslint
version: 8.8.2node
version: 8.11.1yarn
version: 1.5.1
Have you followed the debugging tips?
Yes
Relevant code or config
.eslintrc.js
const path = require("path");
const config = {
parser: "babel-eslint",
env: {
node: true
},
plugins: ["import"],
rules: {
"import/order": [
"error",
{
groups: [
["builtin", "external"],
"internal",
"parent",
["sibling", "index"]
],
"newlines-between": "always"
}
]
},
settings: {
"import/resolver": {
node: {
root: __dirname
},
alias: [["appalias", path.resolve(__dirname, "src/app")]]
}
}
};
module.exports = config;
src/example.js (file being formatted)
const fs = require("fs");
const main = require("src/main");
const app = require("appalias");
const packageJson = require("../package.json");
const mainSibling = require("./main");
What I did:
Run yarn prettier-eslint --list-different --write src/example.js
.
What happened:
It removes the empty line between const main = require("src/main");
and const app = require("appalias");
. This causes an eslint error.
Reproduction repository:
https://github.com/amosyuen/prettier-eslint-import-empty-line-removal
Problem description:
Seems that the eslint --fix
run by prettier-eslint doesn’t handle the import/order
rule correctly. When running with trace logging it looks like import/order
rule is correctly set in the inferred options and that prettier doesn’t change the empty lines between import statements. However, for some reason the output after eslint --fix
will remove the empty line, causing an eslint error.
Running yarn eslint --fix src/example.js
will correctly add back the empty line. So there seems to be something wrong with how prettier-eslint is running eslint. I also made sure I used the same version of eslint.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (3 by maintainers)
Top GitHub Comments
We’re having problems with this as well in our team.
This is an old task, but we are experiencing this with our setup now which is very similar to the config in the initial bug report. ESlint expects the space that Prettier removes.