I decided that `WrappedComponent` is clearer than `Component` here, so I
made the switch. I also realized that `WrappedComponent.name` might
still be undefined, so I added a fallback value of "Component".
This new version renames most of the rules, and adds a number of new
rules that we will need to evaluate. I simply added them for now with
TODO comments so we remember to come back to them and make decisions
about each one. I also alphabetized the list to make it easier to find
what you are looking for.
After digging into this rule a little more with @evcohen, we believe that
it is okay for images to have an empty string for alt text and have
updated the plugin to reflect that understanding. This commit bumps our
dependency on the rule to include this fix and updates our guideline to
match.
GitHub knows how to do JSX syntax highlighting. Since we are using JSX
in this document, I figured we might as well tell GitHub to highlight
the syntax as JSX here. This will lead to a better reading experience.
Screenreaders already announce `img` elements as images, so there is no
need to include this information in the alt text. This will give people
using assistive technologies a smoother experience.
We want our React apps to be accessible. One thing that developers can
do is properly use alt text on images. Thankfully, there is an ESLint
rule that will enforce these things for us.
I think it makes more sense to put static methods above the constructor
in classes. I would like to update the ESLint configuration to match
this, but it looks like the react/sort-comp rule does not support it
quite yet.
https://github.com/yannickcr/eslint-plugin-react/issues/128
I noticed that some newlines and indentation were a little inconsistent
in this file, so I decided to smooth things out a bit. This should help
people who decide to modify this document in the future. When
determining which is the "right" way to format these things, I decided
to use the style used by base readme as a guide.
I noticed a number of places in this document where code was being
referenced but it was not marked as such. Adding backticks will instruct
the markdown parser to format these bits as code, which should improve
the readability of this document.
isMounted is an anti-pattern [0], is not available when using ES6
classes, and is on its way to being officially deprecated.
eslint-plugin-react recently added the react/no-is-mounted rule in
3.12.0 that prevents its use.
[0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
Finishes #633
When there are static variables like `propTypes` and `defaultProps`, we shouldn't export them until we have actually set them onto the `Component`. This may change if the current ES7 proposal for static class properties gets accepts, and we update to support it.