Eslint-plugin-react: "sort-comp" Flow property definitions

Created on 7 Oct 2015  路  5Comments  路  Source: yannickcr/eslint-plugin-react

I was wondering if it was possible to have property definitions at the top when using this rule, cause if I write something like this:

class Something extends Component {

  state: Object;

  constructor(props: Object) {
...

it complains that constructor must be placed before state

flow

Most helpful comment

For the record, you can now use the "type-annotations" group to determine where you would like to place your type annotations. https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md#rule-options

type-annotations. This group is not specified by default, but can be used to enforce flow annotations to be at the top.

All 5 comments

It is not currently possible to sort classes properties according to their type (property, method, etc.). See #128 for this issue.

But you can still configure the rule to force state to be placed before constructor. See the rule options for this.

Let me know if you need more help.

+1

I am facing the same issue and I am using babel-plugin-flow-react-proptypes that transform the static value to propTypes (so this make sense to be defined before constructor). I will take a look to custom order to "fix" this :)

If people that use flow can use my branch and tell me if it works properly for them, that would be cool! It's based on 6.0.0-alpha.1

"eslint-plugin-react": "https://github.com/dozoisch/eslint-plugin-react#typeannotations",

For the record, you can now use the "type-annotations" group to determine where you would like to place your type annotations. https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md#rule-options

type-annotations. This group is not specified by default, but can be used to enforce flow annotations to be at the top.

Was this page helpful?
0 / 5 - 0 ratings