From e6326281303ec03b8d6f09d50899e1fca92fabd8 Mon Sep 17 00:00:00 2001 From: Brian Di Palma Date: Thu, 23 Nov 2017 10:52:43 +0000 Subject: [PATCH] [Docs] improve readme Removed ESLint 1.x config information as it's probably used by very, very few people. Restructured config section to focus on quick set-up with defaults over more time consuming individual rule selection. No need to specify the plugin configuration as it works without it so it seems to be noise? --- README.md | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9084d6ad27..bf5a75a5d9 100644 --- a/README.md +++ b/README.md @@ -21,45 +21,50 @@ $ npm install eslint-plugin-react --save-dev # Configuration -Add `plugins` section and specify ESLint-plugin-React as a plugin. +Use [our preset](#recommended) to get reasonable defaults: ```json -{ - "plugins": [ - "react" + "extends": [ + "eslint:recommended", + "plugin:react/recommended" ] -} ``` -You can also specify some settings that will be shared across all the plugin rules. +You should also specify settings that will be shared across all the plugin rules. ```json5 { "settings": { "react": { - "createClass": "createReactClass", // Regex for Component Factory to use, default to "createReactClass" + "createClass": "createReactClass", // Regex for Component Factory to use, + // default to "createReactClass" "pragma": "React", // Pragma to use, default to "React" "version": "15.0", // React version, default to the latest React stable release "flowVersion": "0.53" // Flow version }, - "propWrapperFunctions": [ "forbidExtraProps" ] // The names of any functions used to wrap the propTypes object, such as `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped. + "propWrapperFunctions": [ "forbidExtraProps" ] // The names of any functions used to wrap the + // propTypes object, e.g. `forbidExtraProps`. + // If this isn't set, any propTypes wrapped in + // a function will be skipped. } } ``` -If it is not already the case you must also configure `ESLint` to support JSX. +If you do not use a preset you will need to specify individual rules and add extra configuration. -With ESLint 1.x.x: +Add "react" to the plugins section. ```json { - "ecmaFeatures": { - "jsx": true - } + "plugins": [ + "react" + ] } ``` -With ESLint 2.x.x or 3.x.x: +Enable JSX support. + +With ESLint 2+ ```json { @@ -71,7 +76,7 @@ With ESLint 2.x.x or 3.x.x: } ``` -Finally, enable all of the rules that you would like to use. Use [our preset](#recommended) to get reasonable defaults quickly, and/or choose your own: +Enable the rules that you would like to use. ```json "rules": {