Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit d601eaf

Browse files
committed
Run Prettier over all code
1 parent 5487243 commit d601eaf

File tree

14 files changed

+73
-72
lines changed

14 files changed

+73
-72
lines changed

examples/dynamic/app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ app.engine('js', reactViews.createEngine());
88

99
app.use(express.static(__dirname + '/public'));
1010

11-
app.get('/', function (req, res) {
11+
app.get('/', function(req, res) {
1212
var initialState = {
1313
items: [
1414
'document your code',
1515
'drop the kids off at the pool',
16-
'</script><script>alert(666)</script>'
16+
'</script><script>alert(666)</script>',
1717
],
18-
text: ''
18+
text: '',
1919
};
20-
res.render('Html', { data: initialState });
20+
res.render('Html', {data: initialState});
2121
});
2222

2323
var port = process.env.PORT || 3000;
24-
app.listen(port, function () {
24+
app.listen(port, function() {
2525
console.log('Dynamic react example listening on port ' + port);
2626
});

examples/dynamic/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"author": "Chris Johnson <[email protected]>",
66
"private": true,
77
"scripts": {
8-
"start": "browserify -t [ babelify --presets [ es2015 react ] --standalone main views/main.js -o public/main.js ] && node app.js"
8+
"start":
9+
"browserify -t [ babelify --presets [ es2015 react ] --standalone main views/main.js -o public/main.js ] && node app.js"
910
},
1011
"dependencies": {
1112
"babel-preset-es2015": "^6.24.1",

examples/dynamic/views/Content.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ class TodoApp extends React.Component {
3333
<TodoList items={this.state.items} />
3434
<form className="form-inline" onSubmit={this.handleSubmit}>
3535
<div className="form-group">
36-
<input type="text" className="form-control" placeholder="Write task" onChange={this.onChange} value={this.state.text} />
36+
<input
37+
type="text"
38+
className="form-control"
39+
placeholder="Write task"
40+
onChange={this.onChange}
41+
value={this.state.text}
42+
/>
3743
&nbsp;
3844
</div>
39-
<button className="btn btn-primary">{'Add #' + (this.state.items.length + 1)}</button>
45+
<button className="btn btn-primary">
46+
{'Add #' + (this.state.items.length + 1)}
47+
</button>
4048
</form>
4149
</div>
4250
);

examples/dynamic/views/Html.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ var ReactDOMServer = require('react-dom/server');
33
var Content = require('./Content');
44

55
class Html extends React.Component {
6-
76
render() {
87
var data = this.props.data;
98

109
// render the content as a dynamic react component
11-
var contentHtml = ReactDOMServer.renderToString(<Content {...data}/>);
10+
var contentHtml = ReactDOMServer.renderToString(<Content {...data} />);
1211

1312
/**
1413
* re-render the content as json,
@@ -48,25 +47,27 @@ class Html extends React.Component {
4847
* If avoidance is impossible,
4948
* know what you are doing and good luck.
5049
*/
51-
var initScript = 'main(' + JSON.stringify(data).replace(/script/g, 'scr"+"ipt') + ')';
50+
var initScript =
51+
'main(' + JSON.stringify(data).replace(/script/g, 'scr"+"ipt') + ')';
5252

5353
return (
5454
<html lang="en">
5555
<head>
56-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
57-
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
56+
<meta name="viewport" content="width=device-width, initial-scale=1" />
57+
<link
58+
rel="stylesheet"
59+
href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"
60+
/>
5861
</head>
5962
<body>
60-
<div id="content" dangerouslySetInnerHTML={{__html: contentHtml}}/>
63+
<div id="content" dangerouslySetInnerHTML={{__html: contentHtml}} />
6164

62-
<script src="/main.js"></script>
65+
<script src="/main.js" />
6366
<script dangerouslySetInnerHTML={{__html: initScript}} />
64-
6567
</body>
6668
</html>
6769
);
6870
}
69-
7071
}
7172

7273
module.exports = Html;

examples/dynamic/views/main.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ var React = require('react');
22
var ReactDOM = require('react-dom');
33
var Content = require('./Content');
44

5-
module.exports = function (data, containerId) {
5+
module.exports = function(data, containerId) {
66
var container = document.getElementById(containerId || 'content');
7-
ReactDOM.render(
8-
<Content {...data} />,
9-
container
10-
);
7+
ReactDOM.render(<Content {...data} />, container);
118
};

examples/simple/app.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Module dependencies.
43
*/
@@ -9,7 +8,7 @@ var user = require('./routes/user');
98
var http = require('http');
109
var path = require('path');
1110
var errorHandler = require('errorhandler');
12-
var logger = require('morgan')
11+
var logger = require('morgan');
1312

1413
// This should refer to the local React and gets installed via `npm install` in
1514
// the example.
@@ -36,6 +35,6 @@ app.locals.qaz = 'qut';
3635
app.get('/', routes.index);
3736
app.get('/users', user.list);
3837

39-
http.createServer(app).listen(app.get('port'), function(){
38+
http.createServer(app).listen(app.get('port'), function() {
4039
console.log('Express server listening on port ' + app.get('port'));
4140
});

examples/simple/routes/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
/*
32
* GET home page.
43
*/
54

6-
exports.index = function(req, res){
7-
res.render('index', { title: 'Express', foo: {bar:'baz'} });
5+
exports.index = function(req, res) {
6+
res.render('index', {title: 'Express', foo: {bar: 'baz'}});
87
};

examples/simple/routes/user.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
/*
32
* GET users listing.
43
*/
54

6-
exports.list = function(req, res){
7-
res.send("respond with a resource");
8-
};
5+
exports.list = function(req, res) {
6+
res.send('respond with a resource');
7+
};

index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ var DEFAULT_OPTIONS = {
1818
beautify: false,
1919
transformViews: true,
2020
babel: {
21-
presets: [
22-
'react',
23-
'es2015',
24-
],
21+
presets: ['react', 'es2015'],
2522
},
2623
};
2724

@@ -35,14 +32,15 @@ function createEngine(engineOptions) {
3532
// Defer babel registration until the first request so we can grab the view path.
3633
if (!moduleDetectRegEx) {
3734
// Path could contain regexp characters so escape it first.
38-
// options.settings.views could be a single string or an array
35+
// options.settings.views could be a single string or an array
3936
moduleDetectRegEx = new RegExp(
40-
[].concat(options.settings.views)
41-
.map(viewPath => '^' + _escaperegexp(viewPath))
42-
.join('|')
43-
);
37+
[]
38+
.concat(options.settings.views)
39+
.map(viewPath => '^' + _escaperegexp(viewPath))
40+
.join('|')
41+
);
4442
}
45-
43+
4644
if (engineOptions.transformViews && !registered) {
4745
// Passing a RegExp to Babel results in an issue on Windows so we'll just
4846
// pass the view path.

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"name": "express-react-views",
33
"version": "0.10.4",
4-
"description": "This is an Express view engine which renders React components on server. It renders static markup and *does not* support mounting those views on the client.",
5-
"keywords": [
6-
"express",
7-
"view engine",
8-
"react"
9-
],
4+
"description":
5+
"This is an Express view engine which renders React components on server. It renders static markup and *does not* support mounting those views on the client.",
6+
"keywords": ["express", "view engine", "react"],
107
"main": "index.js",
118
"scripts": {
129
"lint": "eslint .",

0 commit comments

Comments
 (0)