jsx-eslint/eslint-plugin-react

Rule proposal: no layout thrashing

Open

#1 889 ouverte le 20 juil. 2018

Voir sur GitHub
 (1 commentaire) (1 réaction) (0 assignés)JavaScript (2 797 forks)batch import
acceptedhelp wantednew rule

Métriques du dépôt

Stars
 (8 630 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

I've seen a lot of seemingly simple code lead to layout thrashing and performance problems that could have been statically detected and avoided. It would be nice to have a rule that could flag some of these scenarios.

I think it might make sense to take Paul Irish's list of what causes layout/reflow, and write a rule that flags when these happen synchronously in places like componentDidMount, render, and componentWillReceiveProps, etc.

Example:

class Foo extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      windowHeight: window.innerHeight, // <-- this forces layout
    };
  }
  // ...
}

Thoughts?

Guide contributeur