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

How to sort ES6 getters? #100

Closed
dugokontov opened this issue Jun 10, 2015 · 5 comments
Closed

How to sort ES6 getters? #100

dugokontov opened this issue Jun 10, 2015 · 5 comments

Comments

@dugokontov
Copy link

dugokontov commented Jun 10, 2015

If I extend React.Component using ES6 classes, how can I set order of react/sort-comp to put getters before render? For example

import React from 'react';

class Test extends React.Component {
    get something() {
        return 'something';
    }

    render() {
        const options = this.something;
        return <span>{options}</span>;
    }
}
@yannickcr
Copy link
Member

yannickcr commented Jun 14, 2015

react/sort-comp do not take the method type (static, get, set) into account, the sorting rule is only based on the method name (here something). So for now you do not have the possibility to "force" the getters to be before the render method, unless you use a different naming convention for setters, getters, etc.

Maybe it can be a future rule enhancement.

@dugokontov
Copy link
Author

dugokontov commented Jun 18, 2015

It would be nice to have this enhancement, since it is hard to force some naming convention for properties.

@djalmajr
Copy link

djalmajr commented Oct 8, 2015

+1

@lencioni
Copy link
Collaborator

lencioni commented Jul 24, 2016

I did something similar for static methods in #429, if you are looking for an example of how this might be accomplished.

@aequasi
Copy link

aequasi commented Dec 3, 2016

Oy yeah. Unfortunate. I have a lot of getters and setters that i dont want to be randomly sorted throughout my class.

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

No branches or pull requests

5 participants