airbnb/ts-migrate

hoist-class-statics plugin is removing indentation

protoEvangelion opened this issue · 2 comments

Before

import PropTypes from 'prop-types'
import * as React from 'react'

class B {

}

class A extends B {
    render () {
        return (<div>hi</div>);
    }
}

A.propTypes = {
    data: PropTypes.array
}

After

class A extends B {
static propTypes = {
    data: PropTypes.array
};

    render () {
        return (<div>hi</div>);
    }
}

While not ideal, this seems like something that can be easily fixed through ESLint and the eslint-fix plugin, either using the indent rule or with eslint-plugin-prettier. Were you running the hoist-class-statics plugin by itself? If so, why? Just as a matter of curiosity.

Unless there's a compelling use case to run the plugin all by itself, I'd consider this pretty low priority to fix. Contrast it with something like #97, where the lost blank lines cannot be recovered easily through automation.

I tried eslint & surprisingly it can't fix it. I'm leaning towards running prettier with precise commits to fix this to minimize the amount of formatting that takes place: https://github.com/nrwl/precise-commits

I'm running almost all of the plugins. I just identified that specific plugin as the one causing the indentation issue.

You can close if you would like.