Skip to content

Commit c00e275

Browse files
committed
Improve syntax highlighting of code snippets
Using the jsx tag on the fenced code blocks will instruct GitHub to use JSX syntax highlighting, which will usually be better.
1 parent e332b08 commit c00e275

36 files changed

+141
-139
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Add `plugins` section and specify ESLint-plugin-React as a plugin.
3333

3434
You can also specify some settings that will be shared across all the plugin rules.
3535

36-
```js
36+
```json
3737
{
3838
"settings": {
3939
"react": {
@@ -152,7 +152,7 @@ This plugin exports a `recommended` configuration that enforce React good practi
152152

153153
To enable this configuration use the `extends` property in your `.eslintrc` config file:
154154

155-
```js
155+
```json
156156
{
157157
"extends": ["eslint:recommended", "plugin:react/recommended"]
158158
}
@@ -182,7 +182,7 @@ The rules enabled in this configuration are:
182182
This plugin also exports an `all` configuration that includes every available rule.
183183
This pairs well with the `eslint:all` rule.
184184

185-
```js
185+
```json
186186
{
187187
"plugins": [
188188
"react"

docs/rules/display-name.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DisplayName allows you to name your component. This name is used by React in deb
66

77
The following patterns are considered warnings:
88

9-
```js
9+
```jsx
1010
var Hello = React.createClass({
1111
render: function() {
1212
return <div>Hello {this.props.name}</div>;
@@ -16,7 +16,7 @@ var Hello = React.createClass({
1616

1717
The following patterns are not considered warnings:
1818

19-
```js
19+
```jsx
2020
var Hello = React.createClass({
2121
displayName: 'Hello',
2222
render: function() {
@@ -39,7 +39,7 @@ When `true` the rule will ignore the name set by the transpiler and require a `d
3939

4040
The following patterns are considered okay and do not cause warnings:
4141

42-
```js
42+
```jsx
4343
var Hello = React.createClass({
4444
displayName: 'Hello',
4545

@@ -50,7 +50,7 @@ var Hello = React.createClass({
5050
module.exports = Hello;
5151
```
5252

53-
```js
53+
```jsx
5454
export default class Hello extends React.Component {
5555
render() {
5656
return <div>Hello {this.props.name}</div>;
@@ -59,7 +59,7 @@ export default class Hello extends React.Component {
5959
Hello.displayName = 'Hello';
6060
```
6161

62-
```js
62+
```jsx
6363
export default function Hello({ name }) {
6464
return <div>Hello {name}</div>;
6565
}
@@ -68,7 +68,7 @@ Hello.displayName = 'Hello';
6868

6969
The following patterns will cause warnings:
7070

71-
```js
71+
```jsx
7272
var Hello = React.createClass({
7373
render: function() {
7474
return <div>Hello {this.props.name}</div>;
@@ -77,31 +77,31 @@ var Hello = React.createClass({
7777
module.exports = Hello;
7878
```
7979

80-
```js
80+
```jsx
8181
export default class Hello extends React.Component {
8282
render() {
8383
return <div>Hello {this.props.name}</div>;
8484
}
8585
}
8686
```
8787

88-
```js
88+
```jsx
8989
module.exports = React.createClass({
9090
render: function() {
9191
return <div>Hello {this.props.name}</div>;
9292
}
9393
});
9494
```
9595

96-
```js
96+
```jsx
9797
export default class extends React.Component {
9898
render() {
9999
return <div>Hello {this.props.name}</div>;
100100
}
101101
}
102102
```
103103

104-
```js
104+
```jsx
105105
function HelloComponent() {
106106
return React.createClass({
107107
render: function() {

docs/rules/forbid-prop-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This rule is off by default.
99

1010
The following patterns are considered warnings:
1111

12-
```js
12+
```jsx
1313
var Component = React.createClass({
1414
propTypes: {
1515
a: React.PropTypes.any,

docs/rules/jsx-boolean-value.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ This rule takes one argument. If it is `"always"` then it warns whenever an attr
1010

1111
The following patterns are considered warnings when configured `"never"`:
1212

13-
```js
13+
```jsx
1414
var Hello = <Hello personal={true} />;
1515
```
1616

1717
The following patterns are not considered warnings when configured `"never"`:
1818

19-
```js
19+
```jsx
2020
var Hello = <Hello personal />;
2121
```
2222

2323
The following patterns are considered warnings when configured `"always"`:
2424

25-
```js
25+
```jsx
2626
var Hello = <Hello personal />;
2727
```
2828

2929
The following patterns are not considered warnings when configured `"always"`:
3030

31-
```js
31+
```jsx
3232
var Hello = <Hello personal={true} />;
3333
```
3434

docs/rules/jsx-curly-spacing.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ Depending on your coding conventions, you can choose either option by specifying
2727

2828
When `"never"` is set, the following patterns are considered warnings:
2929

30-
```js
30+
```jsx
3131
<Hello name={ firstname } />;
3232
<Hello name={ firstname} />;
3333
<Hello name={firstname } />;
3434
```
3535

3636
The following patterns are not warnings:
3737

38-
```js
38+
```jsx
3939
<Hello name={firstname} />;
4040
<Hello name={{ firstname: 'John', lastname: 'Doe' }} />;
4141
<Hello name={
@@ -47,15 +47,15 @@ The following patterns are not warnings:
4747

4848
When `"always"` is used, the following patterns are considered warnings:
4949

50-
```js
50+
```jsx
5151
<Hello name={firstname} />;
5252
<Hello name={ firstname} />;
5353
<Hello name={firstname } />;
5454
```
5555

5656
The following patterns are not warnings:
5757

58-
```js
58+
```jsx
5959
<Hello name={ firstname } />;
6060
<Hello name={ {firstname: 'John', lastname: 'Doe'} } />;
6161
<Hello name={
@@ -73,7 +73,7 @@ By default, braces spanning multiple lines are allowed with either setting. If y
7373

7474
When `"never"` is used and `allowMultiline` is `false`, the following patterns are considered warnings:
7575

76-
```js
76+
```jsx
7777
<Hello name={ firstname } />;
7878
<Hello name={ firstname} />;
7979
<Hello name={firstname } />;
@@ -84,14 +84,14 @@ When `"never"` is used and `allowMultiline` is `false`, the following patterns a
8484

8585
The following patterns are not warnings:
8686

87-
```js
87+
```jsx
8888
<Hello name={firstname} />;
8989
<Hello name={{ firstname: 'John', lastname: 'Doe' }} />;
9090
```
9191

9292
When `"always"` is used and `allowMultiline` is `false`, the following patterns are considered warnings:
9393

94-
```js
94+
```jsx
9595
<Hello name={firstname} />;
9696
<Hello name={ firstname} />;
9797
<Hello name={firstname } />;
@@ -102,7 +102,7 @@ When `"always"` is used and `allowMultiline` is `false`, the following patterns
102102

103103
The following patterns are not warnings:
104104

105-
```js
105+
```jsx
106106
<Hello name={ firstname } />;
107107
<Hello name={ {firstname: 'John', lastname: 'Doe'} } />;
108108
```
@@ -123,13 +123,13 @@ All spacing options accept either the string `"always"` or the string `"never"`.
123123

124124
When `"always"` is used but `objectLiterals` is `"never"`, the following pattern is not considered a warning:
125125

126-
```js
126+
```jsx
127127
<App blah={ 3 } foo={{ bar: true, baz: true }} />;
128128
```
129129

130130
When `"never"` is used and `objectLiterals` is `"always"`, the following pattern is not considered a warning:
131131

132-
```js
132+
```jsx
133133
<App blah={3} foo={ {bar: true, baz: true} } />;
134134
```
135135

docs/rules/jsx-equals-spacing.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Depending on your coding conventions, you can choose either option by specifying
2525

2626
When `"never"` is set, the following patterns are considered warnings:
2727

28-
```js
28+
```jsx
2929
<Hello name = {firstname} />;
3030
<Hello name ={firstname} />;
3131
<Hello name= {firstname} />;
3232
```
3333

3434
The following patterns are not warnings:
3535

36-
```js
36+
```jsx
3737
<Hello name={firstname} />;
3838
<Hello name />;
3939
<Hello {...props} />;
@@ -43,15 +43,15 @@ The following patterns are not warnings:
4343

4444
When `"always"` is used, the following patterns are considered warnings:
4545

46-
```js
46+
```jsx
4747
<Hello name={firstname} />;
4848
<Hello name ={firstname} />;
4949
<Hello name= {firstname} />;
5050
```
5151

5252
The following patterns are not warnings:
5353

54-
```js
54+
```jsx
5555
<Hello name = {firstname} />;
5656
<Hello name />;
5757
<Hello {...props} />;

docs/rules/jsx-handler-names.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ Ensures that any component or prop methods used to handle events are correctly p
66

77
The following patterns are considered warnings:
88

9-
```js
9+
```jsx
1010
<MyComponent handleChange={this.handleChange} />
1111
```
1212

13-
```js
13+
```jsx
1414
<MyComponent onChange={this.componentChanged} />
1515
```
1616

1717
The following patterns are not considered warnings:
1818

19-
```js
19+
```jsx
2020
<MyComponent onChange={this.handleChange} />
2121
```
2222

23-
```js
23+
```jsx
2424
<MyComponent onChange={this.props.onFoo} />
2525
```
2626

@@ -40,4 +40,4 @@ The following patterns are not considered warnings:
4040

4141
## When Not To Use It
4242

43-
If you are not using JSX, or if you don't want to enforce specific naming conventions for event handlers.
43+
If you are not using JSX, or if you don't want to enforce specific naming conventions for event handlers.

docs/rules/jsx-no-bind.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ A `bind` call or [arrow function](https://developer.mozilla.org/en-US/docs/Web/J
66

77
The following patterns are considered warnings:
88

9-
```js
9+
```jsx
1010
<div onClick={this._handleClick.bind(this)}></div>
1111
```
12-
```js
12+
```jsx
1313
<div onClick={() => console.log('Hello!'))}></div>
1414
```
1515

1616
The following patterns are not considered warnings:
17-
```js
17+
```jsx
1818
<div onClick={this._handleClick}></div>
1919
```
2020

@@ -59,7 +59,7 @@ When `true` the following is not considered a warning:
5959

6060
A common use case of `bind` in render is when rendering a list, to have a separate callback per list item:
6161

62-
```js
62+
```jsx
6363
var List = React.createClass({
6464
render() {
6565
return (
@@ -77,7 +77,7 @@ var List = React.createClass({
7777

7878
Rather than doing it this way, pull the repeated section into its own component:
7979

80-
```js
80+
```jsx
8181
var List = React.createClass({
8282
render() {
8383
return (
@@ -110,7 +110,7 @@ This will speed up rendering, as it avoids the need to create new functions (thr
110110

111111
Unfortunately [React ES6 classes](https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#es6-classes) do not autobind their methods like components created with the older `React.createClass` syntax. There are several approaches to binding methods for ES6 classes. A basic approach is to just manually bind the methods in the constructor:
112112

113-
```js
113+
```jsx
114114
class Foo extends React.Component {
115115
constructor() {
116116
super();

docs/rules/jsx-no-comment-textnodes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ injected as a text node in JSX statements.
77

88
The following patterns are considered warnings:
99

10-
```js
10+
```jsx
1111
var Hello = React.createClass({
1212
render: function() {
1313
return (
@@ -29,7 +29,7 @@ var Hello = React.createClass({
2929

3030
The following patterns are not considered warnings:
3131

32-
```js
32+
```jsx
3333
var Hello = React.createClass({
3434
displayName: 'Hello',
3535
render: function() {
@@ -57,7 +57,7 @@ var Hello = React.createClass({
5757
It's possible you may want to legitimately output comment start characters (`//` or `/*`)
5858
in a JSX text node. In which case, you can do the following:
5959

60-
```js
60+
```jsx
6161
var Hello = React.createClass({
6262
render: function() {
6363
return (

0 commit comments

Comments
 (0)