From 5c3137d7364b65c9e3300682dd53a68fd595bda2 Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Sun, 13 Dec 2015 18:36:25 -0800 Subject: [PATCH 1/3] Cleaning up the react styleguide. Adding additional info in props. --- packages/eslint-config-airbnb/rules/react.js | 3 + react/README.md | 115 +++++++++++++++++-- 2 files changed, 109 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 758f4e65f4..7f69354521 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -21,6 +21,9 @@ module.exports = { // Validate props indentation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md 'react/jsx-indent-props': [2, 2], + // Prevent usage of .bind() and arrow functions in JSX props + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md + 'react/jsx-no-bind': 2, // Prevent duplicate props in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md 'react/jsx-no-duplicate-props': 0, diff --git a/react/README.md b/react/README.md index 48a50b8378..052949876c 100644 --- a/react/README.md +++ b/react/README.md @@ -56,10 +56,10 @@ ```javascript // bad - const reservationCard = require('./ReservationCard'); + import reservationCard from './ReservationCard'; // good - const ReservationCard = require('./ReservationCard'); + import ReservationCard from './ReservationCard'; // bad const ReservationItem = ; @@ -72,13 +72,13 @@ ```javascript // bad - const Footer = require('./Footer/Footer.jsx') + import Footer from './Footer/Footer.jsx'; // bad - const Footer = require('./Footer/index.jsx') + import Footer from './Footer/index.jsx'; // good - const Footer = require('./Footer') + import Footer from './Footer'; ``` ## Declaration @@ -186,6 +186,22 @@ /> ``` + - Omit the value of the prop when it is explicitly `true`. + + eslint rules: [`react/jsx-boolean-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md). + + ```javascript + // bad +