Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stefanicai opened this issue Aug 12, 2019 · 2 comments

Comments

@stefanicai
Copy link

stefanicai commented Aug 12, 2019

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.

@ljharb
Copy link
Member

ljharb commented Aug 12, 2019

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.

@belgattitude
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants