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

sort-comp reporting a bad error message #507

Closed
mikecousins opened this issue Mar 18, 2016 · 11 comments
Closed

sort-comp reporting a bad error message #507

mikecousins opened this issue Mar 18, 2016 · 11 comments
Labels

Comments

@mikecousins
Copy link

image

As you can see getCourtesyOptions IS before loadProvinces.

@calmdev
Copy link

calmdev commented Jun 21, 2016

What worked for me and may work applied to the context here is making sure that all get methods are defined prior to any load methods.

@neiker
Copy link

neiker commented Jul 19, 2016

Same issue, same fix

@yannickcr
Copy link
Member

Can you post your eslint configuration and a full code example that trigger the error? Thanks.

@neiker
Copy link

neiker commented Jul 25, 2016

Yes, no problem:

{
  "parser": "babel-eslint",
  "extends": [
    "airbnb"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true,
      "classes": true
    }
  },
  "rules": {
    "react-native/no-unused-styles": 2,
    "react-native/split-platform-components": 2,
    "react-native/no-inline-styles": 2,
    "react-native/no-color-literals": 2,
    "react/jsx-no-bind": [2, {
      "ignoreRefs": false,
      "allowArrowFunctions": false,
      "allowBind": false
    }],
    "complexity": [
      2,
      10
    ],
    "max-depth": [
      2,
      4
    ],
    "max-nested-callbacks": [
      2,
      2
    ],
    "max-params": [
      2,
      4
    ],
    "max-statements": [
      2,
      18
    ]
  },
  "globals": {
    "__DEV__": true
  },
  "plugins": [
    "react-native"
  ]
}

@yannickcr
Copy link
Member

Thanks. Can you also post a React Component that trigger the bug?

@neiker
Copy link

neiker commented Jul 26, 2016

I could not find it, but I remember it was something like:

constructor()
shouldComponentUpdate()
setSomething()
onDragStart()
getBound()
onSomething()

@calmdev
Copy link

calmdev commented Jul 27, 2016

I haven't been able to intentionally reproduce it either. It happen while I was refactoring a component. If I come across it again I'll post an example.

@yannickcr
Copy link
Member

Ok, thanks @calmdev .

For now I tried with:

class Hello extends React.Component {
  constructor() {}
  shouldComponentUpdate() {}
  setSomething() {}
  onDragStart() {}
  getBound() {}
  onSomething() {}
  render() {}
}

And the airbnb configuration (since it is the one @neiker is using) but all I got is

setSomething should be placed after onSomething (react/sort-comp)

Which is correct in this case.

@mikecousins
Copy link
Author

Yes, I can no longer reproduce this. Maybe it was fixed by accident?

@calmdev
Copy link

calmdev commented Jul 27, 2016

This is by no means a practical example, but it will cause the message to appear at least.

Maybe it will help.

export default class View extends React.Component {
  getA() {}
  componentDidMountOk() {} // message doesn't show using `componentDidMount`
  getB() {}
  componentWillMount() {}
  render() {}
}

screen shot 2016-07-27 at 5 18 44 pm

@yannickcr
Copy link
Member

Thanks @calmdev , I was able to reproduce the bug with your example. I'll fix this.

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

No branches or pull requests

4 participants