Skip to content

Commit 17c8b89

Browse files
authored
Merge pull request #51 from nfl/chore/addPrettier
chore(Upgrade eslint, add prettier): Upgrade eslint packages, add prettier, run prettier
2 parents b187381 + e46925e commit 17c8b89

33 files changed

+1155
-792
lines changed

.eslintrc

+14
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@
66
],
77
"plugins": [
88
"import",
9+
"prettier",
910
"react"
1011
],
12+
"rules": {
13+
"prettier/prettier": ["error", {
14+
"printWidth": 80,
15+
"tabWidth": 4,
16+
"singleQuote": false,
17+
"trailingComma": "none",
18+
"bracketSpacing": false,
19+
"semi": true,
20+
"useTabs": false,
21+
"parser": "babylon",
22+
"jsxBracketSameLine": false
23+
}]
24+
},
1125
"env": {
1226
"browser": true,
1327
"mocha": true

examples/apps/infinite-scrolling/app.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class App extends Component {
1616
state = {
1717
page: 1,
1818
size: [728, 90]
19-
}
20-
time = 0
19+
};
20+
time = 0;
2121
componentDidMount() {
2222
window.addEventListener("scroll", this.onScroll);
2323
window.addEventListener("resize", this.onScroll);
@@ -47,7 +47,7 @@ class App extends Component {
4747
page: ++this.state.page
4848
});
4949
}
50-
})
50+
});
5151
startTimer() {
5252
this.stopTimer();
5353
this.timer = setInterval(() => {
@@ -68,7 +68,7 @@ class App extends Component {
6868
const targeting = {
6969
test: "infinitescroll"
7070
};
71-
while (contentCnt < page * 3) { // eslint-disable-line no-unmodified-loop-condition
71+
while (contentCnt < page * 3) {
7272
contents.push(
7373
<Content
7474
index={contentCnt % 3}
@@ -92,9 +92,7 @@ class App extends Component {
9292
targeting={targeting}
9393
/>
9494
</div>
95-
<div style={styles.main}>
96-
{contents}
97-
</div>
95+
<div style={styles.main}>{contents}</div>
9896
</div>
9997
);
10098
}

examples/apps/infinite-scrolling/content.js

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/apps/infinite-scrolling/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import App from "./app";
44

5-
ReactDOM.render((
6-
<App />
7-
), document.getElementById("example"));
5+
ReactDOM.render(<App />, document.getElementById("example"));

examples/apps/interstitial/app.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@ import styles from "./styles";
66
class App extends Component {
77
state = {
88
adUnitPath: "/4595/nfl.test.open/page/A"
9-
}
9+
};
1010

1111
onClick = () => {
1212
this.setState({
13-
adUnitPath: this.state.adUnitPath.indexOf("B") > -1 ? "/4595/nfl.test.open/page/A" : "/4595/nfl.test.open/page/B"
13+
adUnitPath:
14+
this.state.adUnitPath.indexOf("B") > -1
15+
? "/4595/nfl.test.open/page/A"
16+
: "/4595/nfl.test.open/page/B"
1417
});
15-
}
18+
};
1619

1720
render() {
1821
const {adUnitPath} = this.state;
1922
return (
2023
<div>
21-
<button
22-
style={styles.button}
23-
onClick={this.onClick}
24-
>
24+
<button style={styles.button} onClick={this.onClick}>
2525
Change ad unit path (navigate to different page)
2626
</button>
27-
<Gpt
28-
adUnitPath={adUnitPath}
29-
outOfPage={true}
30-
/>
27+
<Gpt adUnitPath={adUnitPath} outOfPage={true} />
3128
</div>
3229
);
3330
}

examples/apps/interstitial/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import App from "./app";
44

5-
ReactDOM.render((
6-
<App />
7-
), document.getElementById("example"));
5+
ReactDOM.render(<App />, document.getElementById("example"));

examples/apps/lazy-render/app.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ Gpt.configure({viewableThreshold: 0});
1010
class App extends Component {
1111
onClick = () => {
1212
Gpt.render();
13-
}
13+
};
1414
render() {
1515
return (
1616
<div>
17-
<button
18-
style={styles.button}
19-
onClick={this.onClick}
20-
>
17+
<button style={styles.button} onClick={this.onClick}>
2118
Re-render
2219
</button>
2320
<div style={styles.hWrap}>

examples/apps/lazy-render/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import App from "./app";
44

5-
ReactDOM.render((
6-
<App />
7-
), document.getElementById("example"));
5+
ReactDOM.render(<App />, document.getElementById("example"));

examples/apps/log.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ GPT.on(Events.SLOT_RENDER_ENDED, event => {
1111
}, {});
1212

1313
if (!event.isEmpty && event.size) {
14-
console.log(`ad creative '${event.creativeId}' is rendered to slot '${divId}' of size '${event.size[0]}x${event.size[1]}'`, event, targeting);
14+
console.log(
15+
`ad creative '${event.creativeId}' is rendered to slot '${divId}' of size '${event
16+
.size[0]}x${event.size[1]}'`,
17+
event,
18+
targeting
19+
);
1520
} else {
16-
console.log(`ad rendered but empty, div id is ${divId}`, event, targeting);
21+
console.log(
22+
`ad rendered but empty, div id is ${divId}`,
23+
event,
24+
targeting
25+
);
1726
}
1827
});
1928

examples/apps/responsive/app.js

+26-31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable indent */
12
import React, {Component} from "react";
23
import Radium from "radium";
34
import {Bling as Gpt} from "react-gpt"; // eslint-disable-line import/no-unresolved
@@ -19,17 +20,20 @@ class App extends Component {
1920
{viewport: [1050, 200], slot: [1024, 120]}
2021
],
2122
style: styles.adBorder
22-
}
23+
};
2324

24-
onClick = (params) => {
25+
onClick = params => {
2526
if (params === "refresh") {
2627
Gpt.refresh();
2728
return;
2829
}
2930
let newState;
3031
if (params === "adUnitPath") {
3132
newState = {
32-
adUnitPath: this.state.adUnitPath === "/4595/nfl.test.open" ? "/4595/nfl.test.open/new" : "/4595/nfl.test.open"
33+
adUnitPath:
34+
this.state.adUnitPath === "/4595/nfl.test.open"
35+
? "/4595/nfl.test.open/new"
36+
: "/4595/nfl.test.open"
3337
};
3438
} else if (params === "targeting") {
3539
newState = {
@@ -40,47 +44,38 @@ class App extends Component {
4044
};
4145
} else if (params === "size") {
4246
newState = {
43-
sizeMapping: (this.state.sizeMapping[1].slot[1] === 50) ? [
44-
{viewport: [0, 0], slot: [1, 1]},
45-
{viewport: [340, 0], slot: [300, 250]},
46-
{viewport: [750, 200], slot: [728, 90]},
47-
{viewport: [1050, 200], slot: [1024, 120]}
48-
] : [
49-
{viewport: [0, 0], slot: [1, 1]},
50-
{viewport: [340, 0], slot: [320, 50]},
51-
{viewport: [750, 200], slot: [728, 90]},
52-
{viewport: [1050, 200], slot: [1024, 120]}
53-
]
47+
sizeMapping:
48+
this.state.sizeMapping[1].slot[1] === 50
49+
? [
50+
{viewport: [0, 0], slot: [1, 1]},
51+
{viewport: [340, 0], slot: [300, 250]},
52+
{viewport: [750, 200], slot: [728, 90]},
53+
{viewport: [1050, 200], slot: [1024, 120]}
54+
]
55+
: [
56+
{viewport: [0, 0], slot: [1, 1]},
57+
{viewport: [340, 0], slot: [320, 50]},
58+
{viewport: [750, 200], slot: [728, 90]},
59+
{viewport: [1050, 200], slot: [1024, 120]}
60+
]
5461
};
5562
}
5663
this.setState(newState);
57-
}
64+
};
5865

5966
render() {
6067
return (
6168
<div>
62-
<Button
63-
params="refresh"
64-
onClick={this.onClick}
65-
>
69+
<Button params="refresh" onClick={this.onClick}>
6670
Refresh
6771
</Button>
68-
<Button
69-
params="adUnitPath"
70-
onClick={this.onClick}
71-
>
72+
<Button params="adUnitPath" onClick={this.onClick}>
7273
Change adUnitPath
7374
</Button>
74-
<Button
75-
params="targeting"
76-
onClick={this.onClick}
77-
>
75+
<Button params="targeting" onClick={this.onClick}>
7876
Change targeting
7977
</Button>
80-
<Button
81-
params="size"
82-
onClick={this.onClick}
83-
>
78+
<Button params="size" onClick={this.onClick}>
8479
Change size mapping
8580
</Button>
8681
<div style={styles.lb}>

examples/apps/responsive/button.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ export default class Button extends Component {
66
static propTypes = {
77
children: PropTypes.node,
88
onClick: PropTypes.func.isRequired,
9-
params: PropTypes.oneOfType([
10-
PropTypes.string,
11-
PropTypes.object
12-
]).isRequired
13-
}
9+
params: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
10+
.isRequired
11+
};
1412
onClick = () => {
1513
this.props.onClick(this.props.params);
16-
}
14+
};
1715
render() {
1816
return (
19-
<button
20-
style={styles.button}
21-
onClick={this.onClick}
22-
>
17+
<button style={styles.button} onClick={this.onClick}>
2318
{this.props.children}
2419
</button>
2520
);

examples/apps/responsive/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import App from "./app";
44

5-
ReactDOM.render((
6-
<App />
7-
), document.getElementById("example"));
5+
ReactDOM.render(<App />, document.getElementById("example"));

examples/apps/routing/app.js

+29-16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class App extends Component {
1616
location: PropTypes.object,
1717
history: PropTypes.object,
1818
children: PropTypes.node
19-
}
19+
};
2020

2121
createHref(path) {
2222
return `${window.location.origin}${window.location.pathname}#${path}`;
@@ -33,9 +33,19 @@ class App extends Component {
3333
return (
3434
<div>
3535
<ul>
36-
<li><a href={this.createHref("/Travel/Europe")}>Home</a></li>
37-
<li><a href={this.createHref("/Travel/Europe/France")}>France</a></li>
38-
<li><a href={this.createHref("/Travel/Europe/Spain")}>Spain</a></li>
36+
<li>
37+
<a href={this.createHref("/Travel/Europe")}>Home</a>
38+
</li>
39+
<li>
40+
<a href={this.createHref("/Travel/Europe/France")}>
41+
France
42+
</a>
43+
</li>
44+
<li>
45+
<a href={this.createHref("/Travel/Europe/Spain")}>
46+
Spain
47+
</a>
48+
</li>
3949
</ul>
4050
<div style={styles.topAd}>
4151
<Gpt
@@ -51,19 +61,14 @@ class App extends Component {
5161
}
5262

5363
class AppContainer extends Component {
54-
routes = { // eslint-disable-line react/sort-comp
55-
"/Travel/Europe": {component: Home},
56-
"/Travel/Europe/France": {component: Page, params: {id: "France"}},
57-
"/Travel/Europe/Spain": {component: Page, params: {id: "Spain"}}
58-
}
59-
6064
state = {
6165
routeComponent: this.routes["/Travel/Europe"].component
62-
}
66+
};
6367

6468
componentWillMount() {
6569
this.unlisten = this.history.listen(location => {
66-
const route = this.routes[location.pathname] || this.routes["/Travel/Europe"];
70+
const route =
71+
this.routes[location.pathname] || this.routes["/Travel/Europe"];
6772
const {component: routeComponent, params} = route;
6873
this.setState({routeComponent, location, params});
6974
});
@@ -74,13 +79,21 @@ class AppContainer extends Component {
7479
this.unlisten();
7580
}
7681

77-
history = createHistory()
82+
history = createHistory();
83+
84+
routes = {
85+
// eslint-disable-line react/sort-comp
86+
"/Travel/Europe": {component: Home},
87+
"/Travel/Europe/France": {component: Page, params: {id: "France"}},
88+
"/Travel/Europe/Spain": {component: Page, params: {id: "Spain"}}
89+
};
7890

7991
render() {
8092
return (
81-
<App history={this.history}
82-
location={this.state.location}
83-
params={this.state.params}
93+
<App
94+
history={this.history}
95+
location={this.state.location}
96+
params={this.state.params}
8497
>
8598
{React.createElement(this.state.routeComponent)}
8699
</App>

0 commit comments

Comments
 (0)