@@ -20,7 +20,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var singleLineJSX =
Hello
var Hello = React.createClass({
diff --git a/docs/rules/no-danger.md b/docs/rules/no-danger.md
index 3a9aa6f2fd..0e8c382afa 100644
--- a/docs/rules/no-danger.md
+++ b/docs/rules/no-danger.md
@@ -8,7 +8,7 @@ See https://facebook.github.io/react/tips/dangerously-set-inner-html.html
The following patterns are considered warnings:
-```js
+```jsx
var React = require('react');
var Hello =
;
@@ -16,7 +16,7 @@ var Hello =
;
The following patterns are not considered warnings:
-```js
+```jsx
var React = require('react');
var Hello =
Hello World
;
diff --git a/docs/rules/no-deprecated.md b/docs/rules/no-deprecated.md
index 333664a51a..2ca554168a 100644
--- a/docs/rules/no-deprecated.md
+++ b/docs/rules/no-deprecated.md
@@ -6,7 +6,7 @@ Several methods are deprecated between React versions. This rule will warn you i
The following patterns are considered warnings:
-```js
+```jsx
React.render(
, root);
React.unmountComponentAtNode(root);
@@ -20,7 +20,7 @@ React.renderToStaticMarkup(
);
The following patterns are not considered warnings:
-```js
+```jsx
ReactDOM.render(
, root);
// When [1, {"react": "0.13.0"}]
diff --git a/docs/rules/no-did-mount-set-state.md b/docs/rules/no-did-mount-set-state.md
index 7af9e6320e..ce6f78b9a8 100644
--- a/docs/rules/no-did-mount-set-state.md
+++ b/docs/rules/no-did-mount-set-state.md
@@ -8,7 +8,7 @@ This rule is aimed to forbid the use of `this.setState` in `componentDidMount` o
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.setState({
@@ -23,7 +23,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.onMount(function callback(newName) {
@@ -38,7 +38,7 @@ var Hello = React.createClass({
});
```
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.props.onMount();
@@ -63,7 +63,7 @@ By default this rule forbids any call to `this.setState` in `componentDidMount`
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.setState({
@@ -76,7 +76,7 @@ var Hello = React.createClass({
});
```
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.onMount(function callback(newName) {
diff --git a/docs/rules/no-did-update-set-state.md b/docs/rules/no-did-update-set-state.md
index 60d398e818..fb40e34637 100644
--- a/docs/rules/no-did-update-set-state.md
+++ b/docs/rules/no-did-update-set-state.md
@@ -6,7 +6,7 @@ Updating the state after a component update will trigger a second `render()` cal
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidUpdate: function() {
this.setState({
@@ -21,7 +21,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidUpdate: function() {
this.props.onUpdate();
@@ -32,7 +32,7 @@ var Hello = React.createClass({
});
```
-```js
+```jsx
var Hello = React.createClass({
componentDidUpdate: function() {
this.onUpdate(function callback(newName) {
@@ -61,7 +61,7 @@ By default this rule forbids any call to `this.setState` in `componentDidUpdate`
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidUpdate: function() {
this.setState({
@@ -74,7 +74,7 @@ var Hello = React.createClass({
});
```
-```js
+```jsx
var Hello = React.createClass({
componentDidUpdate: function() {
this.onUpdate(function callback(newName) {
diff --git a/docs/rules/no-direct-mutation-state.md b/docs/rules/no-direct-mutation-state.md
index f42d86c011..b260190fc9 100644
--- a/docs/rules/no-direct-mutation-state.md
+++ b/docs/rules/no-direct-mutation-state.md
@@ -9,7 +9,7 @@ This rule is aimed to forbid the use of mutating `this.state` directly.
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.state.name = this.props.name.toUpperCase();
@@ -23,7 +23,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
this.setState({
diff --git a/docs/rules/no-find-dom-node.md b/docs/rules/no-find-dom-node.md
index f981c00319..e962db0667 100644
--- a/docs/rules/no-find-dom-node.md
+++ b/docs/rules/no-find-dom-node.md
@@ -8,7 +8,7 @@ It is recommended to use callback refs instead. See [Dan Abramov comments and ex
The following patterns are considered warnings:
-```js
+```jsx
class MyComponent extends Component {
componentDidMount() {
findDOMNode(this).scrollIntoView();
@@ -21,7 +21,7 @@ class MyComponent extends Component {
The following patterns are not considered warnings:
-```js
+```jsx
class MyComponent extends Component {
componentDidMount() {
this.node.scrollIntoView();
diff --git a/docs/rules/no-is-mounted.md b/docs/rules/no-is-mounted.md
index 1fd3b4ee16..201ca82ca7 100644
--- a/docs/rules/no-is-mounted.md
+++ b/docs/rules/no-is-mounted.md
@@ -8,7 +8,7 @@
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
handleClick: function() {
setTimeout(function() {
@@ -25,7 +25,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello
;
diff --git a/docs/rules/no-multi-comp.md b/docs/rules/no-multi-comp.md
index 5108402759..6122dc602c 100644
--- a/docs/rules/no-multi-comp.md
+++ b/docs/rules/no-multi-comp.md
@@ -6,7 +6,7 @@ Declaring only one component per file improves readability and reusability of co
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello {this.props.name}
;
@@ -22,7 +22,7 @@ var HelloJohn = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = require('./components/Hello');
var HelloJohn = React.createClass({
@@ -46,7 +46,7 @@ When `true` the rule will ignore stateless components and will allow you to have
The following patterns are considered okay and do not cause warnings:
-```js
+```jsx
function Hello(props) {
return
Hello {props.name}
;
}
@@ -55,7 +55,7 @@ function HelloAgain(props) {
}
```
-```js
+```jsx
function Hello(props) {
return
Hello {props.name}
;
}
diff --git a/docs/rules/no-render-return-value.md b/docs/rules/no-render-return-value.md
index 0337962368..a0575c259c 100644
--- a/docs/rules/no-render-return-value.md
+++ b/docs/rules/no-render-return-value.md
@@ -10,14 +10,14 @@ This rule will warn you if you try to use the `ReactDOM.render()` return value.
The following pattern is considered a warning:
-```js
+```jsx
const inst = ReactDOM.render(
, document.body);
doSomethingWithInst(inst);
```
The following patterns are not considered warnings:
-```js
+```jsx
ReactDOM.render(
, document.body);
ReactDOM.render(
, document.body, doSomethingWithInst);
diff --git a/docs/rules/no-set-state.md b/docs/rules/no-set-state.md
index 7693ce5bc2..c30283a905 100644
--- a/docs/rules/no-set-state.md
+++ b/docs/rules/no-set-state.md
@@ -6,7 +6,7 @@ When using an architecture that separates your application state from your UI co
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
getInitialState: function() {
return {
@@ -26,7 +26,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello {this.props.name}
;
diff --git a/docs/rules/no-string-refs.md b/docs/rules/no-string-refs.md
index ebcd9c9189..1965bc7d3d 100644
--- a/docs/rules/no-string-refs.md
+++ b/docs/rules/no-string-refs.md
@@ -6,7 +6,7 @@ Currently, two ways are supported by React to refer to components. The first one
Invalid:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello, world.
;
@@ -14,7 +14,7 @@ var Hello = React.createClass({
});
```
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
var component = this.refs.hello;
@@ -28,7 +28,7 @@ var Hello = React.createClass({
Valid:
-```js
+```jsx
var Hello = React.createClass({
componentDidMount: function() {
var component = this.hello;
diff --git a/docs/rules/no-unknown-property.md b/docs/rules/no-unknown-property.md
index c4dcba6336..772898d78d 100644
--- a/docs/rules/no-unknown-property.md
+++ b/docs/rules/no-unknown-property.md
@@ -8,7 +8,7 @@ In JSX all DOM properties and attributes should be camelCased to be consistent w
The following patterns are considered warnings:
-```js
+```jsx
var React = require('react');
var Hello =
Hello World
;
@@ -16,7 +16,7 @@ var Hello =
Hello World
;
The following patterns are not considered warnings:
-```js
+```jsx
var React = require('react');
var Hello =
Hello World
;
diff --git a/docs/rules/prefer-es6-class.md b/docs/rules/prefer-es6-class.md
index 1c742d02aa..371272feeb 100644
--- a/docs/rules/prefer-es6-class.md
+++ b/docs/rules/prefer-es6-class.md
@@ -16,7 +16,7 @@ Will enforce ES6 classes for React Components. This is the default mode.
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello {this.props.name}
;
@@ -26,7 +26,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
class Hello extends React.Component {
render() {
return
Hello {this.props.name}
;
@@ -40,7 +40,7 @@ Will enforce ES5 classes for React Components
The following patterns are considered warnings:
-```js
+```jsx
class Hello extends React.Component {
render() {
return
Hello {this.props.name}
;
@@ -50,7 +50,7 @@ class Hello extends React.Component {
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello {this.props.name}
;
diff --git a/docs/rules/react-in-jsx-scope.md b/docs/rules/react-in-jsx-scope.md
index f5f2fec9b1..551661bf9c 100644
--- a/docs/rules/react-in-jsx-scope.md
+++ b/docs/rules/react-in-jsx-scope.md
@@ -9,11 +9,11 @@ If you are using the @jsx pragma this rule will check the designated variable an
The following patterns are considered warnings:
-```js
+```jsx
var Hello =
Hello {this.props.name}
;
```
-```js
+```jsx
/** @jsx Foo.bar */
var React = require('react');
@@ -22,19 +22,19 @@ var Hello =
Hello {this.props.name}
;
The following patterns are not considered warnings:
-```js
+```jsx
import React from 'react';
var Hello =
Hello {this.props.name}
;
```
-```js
+```jsx
var React = require('react');
var Hello =
Hello {this.props.name}
;
```
-```js
+```jsx
/** @jsx Foo.bar */
var Foo = require('foo');
diff --git a/docs/rules/require-default-props.md b/docs/rules/require-default-props.md
index 65e9256feb..91c5b276d1 100644
--- a/docs/rules/require-default-props.md
+++ b/docs/rules/require-default-props.md
@@ -8,7 +8,8 @@ The same also holds true for stateless functional components: default function p
To illustrate, consider the following example:
With `defaultProps`:
-```js
+
+```jsx
const HelloWorld = ({ name }) => (
Hello, {name.first} {name.last}!
);
@@ -30,7 +31,8 @@ ReactDOM.render(
, document.getElementById('app'));
```
Without `defaultProps`:
-```js
+
+```jsx
const HelloWorld = ({ name = 'John Doe' }) => (
Hello, {name.first} {name.last}!
);
@@ -51,7 +53,7 @@ ReactDOM.render(
, document.getElementById('app'));
The following patterns are considered warnings:
-```js
+```jsx
function MyStatelessComponent({ foo, bar }) {
return
{foo}{bar}
;
}
@@ -62,7 +64,7 @@ MyStatelessComponent.propTypes = {
};
```
-```js
+```jsx
var Greeting = React.createClass({
render: function() {
return
Hello {this.props.foo} {this.props.bar}
;
@@ -81,7 +83,7 @@ var Greeting = React.createClass({
});
```
-```js
+```jsx
class Greeting extends React.Component {
render() {
return (
@@ -100,7 +102,7 @@ Greeting.defaultProps = {
};
```
-```js
+```jsx
class Greeting extends React.Component {
render() {
return (
@@ -119,7 +121,7 @@ class Greeting extends React.Component {
}
```
-```js
+```jsx
type Props = {
foo: string,
bar?: string
@@ -132,7 +134,7 @@ function MyStatelessComponent(props: Props) {
The following patterns are not considered warnings:
-```js
+```jsx
function MyStatelessComponent({ foo, bar }) {
return
{foo}{bar}
;
}
@@ -143,7 +145,7 @@ MyStatelessComponent.propTypes = {
};
```
-```js
+```jsx
function MyStatelessComponent({ foo, bar }) {
return
{foo}{bar}
;
}
@@ -158,7 +160,7 @@ MyStatelessComponent.defaultProps = {
};
```
-```js
+```jsx
type Props = {
foo: string,
bar?: string
diff --git a/docs/rules/require-render-return.md b/docs/rules/require-render-return.md
index 5e25661b8c..cf744318b4 100644
--- a/docs/rules/require-render-return.md
+++ b/docs/rules/require-render-return.md
@@ -6,7 +6,7 @@ When writing the `render` method in a component it is easy to forget to return t
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render() {
Hello
;
@@ -22,7 +22,7 @@ class Hello extends React.Component {
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render() {
return
Hello
;
diff --git a/docs/rules/sort-comp.md b/docs/rules/sort-comp.md
index e592df4d8f..fc171e7e8d 100644
--- a/docs/rules/sort-comp.md
+++ b/docs/rules/sort-comp.md
@@ -15,7 +15,7 @@ The default configuration ensures that the following order must be followed:
The following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello
;
@@ -26,7 +26,7 @@ var Hello = React.createClass({
The following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
displayName : 'Hello',
render: function() {
@@ -109,7 +109,7 @@ For example, if you want to place your event handlers (`onClick`, `onSubmit`, et
With the above configuration, the following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
render: function() {
return
Hello
;
@@ -120,7 +120,7 @@ var Hello = React.createClass({
With the above configuration, the following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
onClick: function() {},
render: function() {
@@ -150,7 +150,7 @@ If you want to split your `render` method into smaller ones and keep them just b
With the above configuration, the following patterns are considered warnings:
-```js
+```jsx
var Hello = React.createClass({
renderButton: function() {},
onClick: function() {},
@@ -162,7 +162,7 @@ var Hello = React.createClass({
With the above configuration, the following patterns are not considered warnings:
-```js
+```jsx
var Hello = React.createClass({
onClick: function() {},
renderButton: function() {},
@@ -188,7 +188,7 @@ If you want to flow annotations to be at the top:
With the above configuration, the following patterns are considered warnings:
-```js
+```jsx
class Hello extends React.Component
{
onClick() { this._someElem = true; }
props: Props;
@@ -201,7 +201,7 @@ class Hello extends React.Component {
With the above configuration, the following patterns are not considered warnings:
-```js
+```jsx
type Props = {};
class Hello extends React.Component {
props: Props;
diff --git a/docs/rules/sort-prop-types.md b/docs/rules/sort-prop-types.md
index c665328e52..e569af8847 100644
--- a/docs/rules/sort-prop-types.md
+++ b/docs/rules/sort-prop-types.md
@@ -8,7 +8,7 @@ This rule checks all components and verifies that all propTypes declarations are
The following patterns are considered warnings:
-```js
+```jsx
var Component = React.createClass({
propTypes: {
z: React.PropTypes.number,
@@ -41,7 +41,7 @@ class Component extends React.Component {
The following patterns are considered okay and do not cause warnings:
-```js
+```jsx
var Component = React.createClass({
propTypes: {
a: React.PropTypes.number,