import-js/eslint-plugin-import

Import order autofix should move above comments with the import too (e.g. @ts-ignore etc)

stefanicai opened this issue · 2 comments

Currently reordering leaves the comments behind. Thus something like:

import { connect } from 'formik'
import { useReferenceData } from '../../reference'

// @ts-ignore
import { FormikRadioGroup } from '@external/radio-group'

Becomes:

import { connect } from 'formik'
import { FormikRadioGroup } from '@external/radio-group'
import { useReferenceData } from '../../reference'

// @ts-ignore

That's incorrect. The autofix should move the above comment as well.

Comment attachment is difficult; I believe eslint doesn't actually attach comments to nodes. For you (and for ts-ignore comments, specifically), they go above, but some people put comments on the same line, and some below.

I'm not sure how to address this reliably except perhaps to bail on moving any line that has a comment adjacent in any direction.

This is a very annoying bug indeed. Has anyone found a workaround ?