eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

autofixing "no-duplicates" does not add whitespace after commas

Open resolritter opened this issue 4 years ago • 2 comments

I had some code like this

import { a } from "pkg"
import { b } from "pkg"

ESLint's autofix for "import/no-duplicates" did work, but it left a and b glued together like so

import { a,b } from "pkg"

Having the imports glued by commas upsets Prettier. A sensible solution is to add a whitespace after the comma(s).

import { a, b } from "pkg"

resolritter avatar Nov 28 '20 06:11 resolritter

It seems that setting up eslint-plugin-prettier gets around this... But it'd be nice if this plugin could add the whitespaces by itself

resolritter avatar Nov 28 '20 06:11 resolritter

prettier should only ever be run via eslint anyways :-)

an alternative solution is to use the comma-spacing eslint rule to correct it. I’d be fine changing this rule to add the whitespaces by default tho, since that’s by far the more common style.

ljharb avatar Nov 28 '20 15:11 ljharb