You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-62
Original file line number
Diff line number
Diff line change
@@ -68,61 +68,67 @@ With ESLint 2.x.x:
68
68
}
69
69
```
70
70
71
-
Finally, enable all of the rules that you would like to use.
71
+
Finally, enable all of the rules that you would like to use. Use [our preset](#user-content-recommended-configuration) to get reasonable defaults quickly, and/or choose your own:
72
72
73
-
The plugin has a [recommended configuration](#user-content-recommended-configuration) that enforces React good practices.
73
+
```json
74
+
"rules": {
75
+
"react/jsx-uses-react": "error",
76
+
"react/jsx-uses-vars": "error",
77
+
}
78
+
```
74
79
75
80
# List of supported rules
76
81
77
-
*[display-name](docs/rules/display-name.md): Prevent missing `displayName` in a React component definition
78
-
*[forbid-prop-types](docs/rules/forbid-prop-types.md): Forbid certain propTypes
79
-
*[no-danger](docs/rules/no-danger.md): Prevent usage of dangerous JSX properties
80
-
*[no-deprecated](docs/rules/no-deprecated.md): Prevent usage of deprecated methods
81
-
*[no-did-mount-set-state](docs/rules/no-did-mount-set-state.md): Prevent usage of `setState` in `componentDidMount`
82
-
*[no-did-update-set-state](docs/rules/no-did-update-set-state.md): Prevent usage of `setState` in `componentDidUpdate`
83
-
*[no-direct-mutation-state](docs/rules/no-direct-mutation-state.md): Prevent direct mutation of `this.state`
84
-
*[no-is-mounted](docs/rules/no-is-mounted.md): Prevent usage of `isMounted`
85
-
*[no-multi-comp](docs/rules/no-multi-comp.md): Prevent multiple component definition per file
86
-
*[no-render-return-value](docs/rules/no-render-return-value.md): Prevent usage of the return value of `React.render`
87
-
*[no-set-state](docs/rules/no-set-state.md): Prevent usage of `setState`
88
-
*[no-string-refs](docs/rules/no-string-refs.md): Prevent using string references in `ref` attribute.
89
-
*[no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property (fixable)
90
-
*[prefer-es6-class](docs/rules/prefer-es6-class.md): Enforce ES5 or ES6 class for React Components
91
-
*[prefer-stateless-function](docs/rules/prefer-stateless-function.md): Enforce stateless React Components to be written as a pure function
92
-
*[prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition
93
-
*[react-in-jsx-scope](docs/rules/react-in-jsx-scope.md): Prevent missing `React` when using JSX
94
-
*[require-extension](docs/rules/require-extension.md): Restrict file extensions that may be required
95
-
*[require-optimization](docs/rules/require-optimization.md): Enforce React components to have a shouldComponentUpdate method
96
-
*[require-render-return](docs/rules/require-render-return.md): Enforce ES5 or ES6 class for returning value in render function
97
-
*[self-closing-comp](docs/rules/self-closing-comp.md): Prevent extra closing tags for components without children
98
-
*[sort-comp](docs/rules/sort-comp.md): Enforce component methods order
When `"always"` is used and `alternative` is `true`, the following pattern is not warnings:
120
+
*`objectLiterals`: This controls different spacing requirements when the value inside the jsx curly braces is an object literal.
121
+
122
+
All spacing options accept either the string `"always"` or the string `"never"`. Note that the default value for all "spacing" options matches the first "always"/"never" option provided.
123
+
124
+
When `"always"` is used but `objectLiterals` is `"never"`, the following pattern is not considered a warning:
119
125
120
126
```js
121
-
<App foo={{ bar:true, baz:true }} />;
127
+
<App blah={ 3 } foo={{ bar:true, baz:true }} />;
122
128
```
123
129
124
-
When `"always"` is used and `alternative` is `true`, the following pattern is considered warnings:
130
+
When `"never"` is used and `objectLiterals` is `"always"`, the following pattern is not considered a warning:
125
131
126
132
```js
127
-
<App foo={ {bar:true, baz:true} } />;
133
+
<App blah={3} foo={ {bar:true, baz:true} } />;
128
134
```
129
135
136
+
Please note that spacing of the object literal curly braces themselves is controlled by the built-in [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing) rule.
137
+
130
138
## When Not To Use It
131
139
132
140
You can turn this rule off if you are not concerned with the consistency around the spacing inside of JSX attributes.
0 commit comments