Skip to content

Commit 3b27643

Browse files
committed
Formatted with better prettier settings
1 parent 8ecee6e commit 3b27643

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1367
-930
lines changed

asyncValidation/devServer.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
var path = require('path');
2-
var express = require('express');
3-
var webpack = require('webpack');
4-
var config = require('./webpack.config.dev');
1+
var path = require('path')
2+
var express = require('express')
3+
var webpack = require('webpack')
4+
var config = require('./webpack.config.dev')
55

6-
var app = express();
7-
var compiler = webpack(config);
6+
var app = express()
7+
var compiler = webpack(config)
88

9-
app.use(require('webpack-dev-middleware')(compiler, {
10-
noInfo: true,
11-
publicPath: config.output.publicPath
12-
}));
9+
app.use(
10+
require('webpack-dev-middleware')(compiler, {
11+
noInfo: true,
12+
publicPath: config.output.publicPath,
13+
})
14+
)
1315

14-
app.use(require('webpack-hot-middleware')(compiler));
16+
app.use(require('webpack-hot-middleware')(compiler))
1517

1618
app.get('*', function(req, res) {
17-
res.sendFile(path.join(__dirname, 'index.html'));
18-
});
19+
res.sendFile(path.join(__dirname, 'index.html'))
20+
})
1921

2022
app.listen(3030, 'localhost', function(err) {
2123
if (err) {
22-
console.log(err);
23-
return;
24+
console.log(err)
25+
return
2426
}
2527

26-
console.log('Listening at http://localhost:3030');
27-
});
28+
console.log('Listening at http://localhost:3030')
29+
})
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
11
import React from 'react'
2-
import { Field, reduxForm } from 'redux-form'
2+
import {Field, reduxForm} from 'redux-form'
33
import validate from './validate'
44
import asyncValidate from './asyncValidate'
55

6-
const renderField = ({ input, label, type, meta: { asyncValidating, touched, error } }) => (
6+
const renderField = ({
7+
input,
8+
label,
9+
type,
10+
meta: {asyncValidating, touched, error},
11+
}) => (
712
<div>
813
<label>{label}</label>
914
<div className={asyncValidating ? 'async-validating' : ''}>
10-
<input {...input} type={type} placeholder={label}/>
15+
<input {...input} type={type} placeholder={label} />
1116
{touched && error && <span>{error}</span>}
1217
</div>
1318
</div>
1419
)
1520

16-
const AsyncValidationForm = (props) => {
17-
const { handleSubmit, pristine, reset, submitting } = props
21+
const AsyncValidationForm = props => {
22+
const {handleSubmit, pristine, reset, submitting} = props
1823
return (
1924
<form onSubmit={handleSubmit}>
20-
<Field name="username" type="text" component={renderField} label="Username"/>
21-
<Field name="password" type="password" component={renderField} label="Password"/>
25+
<Field
26+
name="username"
27+
type="text"
28+
component={renderField}
29+
label="Username"
30+
/>
31+
<Field
32+
name="password"
33+
type="password"
34+
component={renderField}
35+
label="Password"
36+
/>
2237
<div>
2338
<button type="submit" disabled={submitting}>Sign Up</button>
24-
<button type="button" disabled={pristine || submitting} onClick={reset}>Clear Values</button>
39+
<button type="button" disabled={pristine || submitting} onClick={reset}>
40+
Clear Values
41+
</button>
2542
</div>
2643
</form>
2744
)
@@ -31,5 +48,5 @@ export default reduxForm({
3148
form: 'asyncValidation', // a unique identifier for this form
3249
validate,
3350
asyncValidate,
34-
asyncBlurFields: [ 'username' ]
51+
asyncBlurFields: ['username'],
3552
})(AsyncValidationForm)

asyncValidation/src/asyncValidate.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
22

3-
const asyncValidate = (values/*, dispatch */) => {
4-
return sleep(1000) // simulate server latency
5-
.then(() => {
6-
if ([ 'john', 'paul', 'george', 'ringo' ].includes(values.username)) {
7-
throw { username: 'That username is taken' }
8-
}
9-
})
3+
const asyncValidate = (values /*, dispatch */) => {
4+
return sleep(1000).then(() => {
5+
// simulate server latency
6+
if (['john', 'paul', 'george', 'ringo'].includes(values.username)) {
7+
throw {username: 'That username is taken'}
8+
}
9+
})
1010
}
1111

1212
export default asyncValidate
13-

asyncValidation/src/index.js

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
3-
import { Provider } from 'react-redux'
4-
import { createStore, combineReducers } from 'redux'
5-
import { reducer as reduxFormReducer } from 'redux-form'
6-
import { App, Code, Markdown, Values, generateExampleBreadcrumbs } from 'redux-form-website-template'
3+
import {Provider} from 'react-redux'
4+
import {createStore, combineReducers} from 'redux'
5+
import {reducer as reduxFormReducer} from 'redux-form'
6+
import {
7+
App,
8+
Code,
9+
Markdown,
10+
Values,
11+
generateExampleBreadcrumbs,
12+
} from 'redux-form-website-template'
713

814
const dest = document.getElementById('content')
915
const reducer = combineReducers({
10-
form: reduxFormReducer // mounted under "form"
16+
form: reduxFormReducer, // mounted under "form"
1117
})
12-
const store =
13-
(window.devToolsExtension ? window.devToolsExtension()(createStore) : createStore)(reducer)
18+
const store = (window.devToolsExtension
19+
? window.devToolsExtension()(createStore)
20+
: createStore)(reducer)
1421

1522
const showResults = values =>
1623
new Promise(resolve => {
17-
setTimeout(() => { // simulate server latency
24+
setTimeout(() => {
25+
// simulate server latency
1826
window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`)
1927
resolve()
2028
}, 500)
@@ -35,37 +43,44 @@ let render = () => {
3543
*/
3644
version="6.6.3"
3745
path="/examples/asyncValidation"
38-
breadcrumbs={generateExampleBreadcrumbs('asyncValidation', 'Async Validation Example', '6.6.3')}>
39-
40-
<Markdown content={readme}/>
41-
42-
<div style={{ textAlign: 'center' }}>
43-
<a href="https://codesandbox.io/s/nKlYo387"
46+
breadcrumbs={generateExampleBreadcrumbs(
47+
'asyncValidation',
48+
'Async Validation Example',
49+
'6.6.3'
50+
)}
51+
>
52+
53+
<Markdown content={readme} />
54+
55+
<div style={{textAlign: 'center'}}>
56+
<a
57+
href="https://codesandbox.io/s/nKlYo387"
4458
target="_blank"
45-
style={{ fontSize: '1.5em' }}>
46-
<i className="fa fa-codepen"/> Open in Sandbox
59+
style={{fontSize: '1.5em'}}
60+
>
61+
<i className="fa fa-codepen" /> Open in Sandbox
4762
</a>
4863
</div>
4964

5065
<h2>Form</h2>
5166

52-
<AsyncValidationForm onSubmit={showResults}/>
67+
<AsyncValidationForm onSubmit={showResults} />
5368

54-
<Values form="asyncValidation"/>
69+
<Values form="asyncValidation" />
5570

5671
<h2>Code</h2>
5772

5873
<h4>validate.js</h4>
5974

60-
<Code source={rawValidate}/>
75+
<Code source={rawValidate} />
6176

6277
<h4>asyncValidate.js</h4>
6378

64-
<Code source={rawAsyncValidate}/>
79+
<Code source={rawAsyncValidate} />
6580

6681
<h4>AsyncValidationForm.js</h4>
6782

68-
<Code source={raw}/>
83+
<Code source={raw} />
6984

7085
</App>
7186
</Provider>,
@@ -77,12 +92,9 @@ if (module.hot) {
7792
// Support hot reloading of components
7893
// and display an overlay for runtime errors
7994
const renderApp = render
80-
const renderError = (error) => {
95+
const renderError = error => {
8196
const RedBox = require('redbox-react')
82-
ReactDOM.render(
83-
<RedBox error={error} className="redbox"/>,
84-
dest
85-
)
97+
ReactDOM.render(<RedBox error={error} className="redbox" />, dest)
8698
}
8799
render = () => {
88100
try {

asyncValidation/src/reducer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { combineReducers } from 'redux'
2-
import { reducer as formReducer } from 'redux-form'
1+
import {combineReducers} from 'redux'
2+
import {reducer as formReducer} from 'redux-form'
33
import validate from './validate'
44

55
const reducer = combineReducers({
66
form: formReducer.validation({
7-
asyncValidation: validate // "asyncValidation" is the form name given to reduxForm() decorator
8-
})
7+
asyncValidation: validate, // "asyncValidation" is the form name given to reduxForm() decorator
8+
}),
99
})
1010

1111
export default reducer

asyncValidation/src/validate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ const validate = values => {
1010
}
1111

1212
export default validate
13-

fieldArrays/devServer.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
var path = require('path');
2-
var express = require('express');
3-
var webpack = require('webpack');
4-
var config = require('./webpack.config.dev');
1+
var path = require('path')
2+
var express = require('express')
3+
var webpack = require('webpack')
4+
var config = require('./webpack.config.dev')
55

6-
var app = express();
7-
var compiler = webpack(config);
6+
var app = express()
7+
var compiler = webpack(config)
88

9-
app.use(require('webpack-dev-middleware')(compiler, {
10-
noInfo: true,
11-
publicPath: config.output.publicPath
12-
}));
9+
app.use(
10+
require('webpack-dev-middleware')(compiler, {
11+
noInfo: true,
12+
publicPath: config.output.publicPath,
13+
})
14+
)
1315

14-
app.use(require('webpack-hot-middleware')(compiler));
16+
app.use(require('webpack-hot-middleware')(compiler))
1517

1618
app.get('*', function(req, res) {
17-
res.sendFile(path.join(__dirname, 'index.html'));
18-
});
19+
res.sendFile(path.join(__dirname, 'index.html'))
20+
})
1921

2022
app.listen(3030, 'localhost', function(err) {
2123
if (err) {
22-
console.log(err);
23-
return;
24+
console.log(err)
25+
return
2426
}
2527

26-
console.log('Listening at http://localhost:3030');
27-
});
28+
console.log('Listening at http://localhost:3030')
29+
})

0 commit comments

Comments
 (0)