update to modern code style (#1738)

* mv create-react-app/index.js -> create-react-app/creteReactApp.js

* update to modern code style

* var -> cosnt

* set trailing-coma to es5 for prettier
This commit is contained in:
Valerii Sorokobatko
2017-03-07 21:46:10 +02:00
committed by Dan Abramov
parent 43873dc9b8
commit fe7b5c212b
66 changed files with 2011 additions and 1637 deletions

View File

@@ -7,36 +7,47 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { expect } from 'chai'
import initDOM from './initDOM'
import { expect } from 'chai';
import initDOM from './initDOM';
describe('Integration', () => {
describe('Environment variables', () => {
it('file env variables', async () => {
const doc = await initDOM('file-env-variables')
const doc = await initDOM('file-env-variables');
expect(doc.getElementById('feature-file-env-variables').textContent).to.equal('fromtheenvfile.')
})
expect(
doc.getElementById('feature-file-env-variables').textContent
).to.equal('fromtheenvfile.');
});
it('NODE_PATH', async () => {
const doc = await initDOM('node-path')
const doc = await initDOM('node-path');
expect(doc.getElementById('feature-node-path').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-node-path').childElementCount
).to.equal(4);
});
it('PUBLIC_URL', async () => {
const doc = await initDOM('public-url')
const doc = await initDOM('public-url');
const prefix = process.env.NODE_ENV === 'development' ? '' : 'http://www.example.org/spa';
expect(doc.getElementById('feature-public-url').textContent).to.equal(`${prefix}.`)
expect(doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href'))
.to.equal(`${prefix}/favicon.ico`)
})
const prefix = process.env.NODE_ENV === 'development'
? ''
: 'http://www.example.org/spa';
expect(doc.getElementById('feature-public-url').textContent).to.equal(
`${prefix}.`
);
expect(
doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href')
).to.equal(`${prefix}/favicon.ico`);
});
it('shell env variables', async () => {
const doc = await initDOM('shell-env-variables')
const doc = await initDOM('shell-env-variables');
expect(doc.getElementById('feature-shell-env-variables').textContent).to.equal('fromtheshell.')
})
})
})
expect(
doc.getElementById('feature-shell-env-variables').textContent
).to.equal('fromtheshell.');
});
});
});

View File

@@ -7,59 +7,72 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
const fs = require('fs')
const http = require('http')
const jsdom = require('jsdom')
const path = require('path')
const { expect } = require('chai')
const fs = require('fs');
const http = require('http');
const jsdom = require('jsdom');
const path = require('path');
const { expect } = require('chai');
let getMarkup
let resourceLoader
let getMarkup;
let resourceLoader;
if (process.env.E2E_FILE) {
const file = path.isAbsolute(process.env.E2E_FILE)
? process.env.E2E_FILE
: path.join(process.cwd(), process.env.E2E_FILE)
: path.join(process.cwd(), process.env.E2E_FILE);
const markup = fs.readFileSync(file, 'utf8')
getMarkup = () => markup
const markup = fs.readFileSync(file, 'utf8');
getMarkup = () => markup;
const pathPrefix = process.env.PUBLIC_URL.replace(/^https?:\/\/[^/]+\/?/, '')
const pathPrefix = process.env.PUBLIC_URL.replace(/^https?:\/\/[^/]+\/?/, '');
resourceLoader = (resource, callback) => callback(
null,
fs.readFileSync(path.join(path.dirname(file), resource.url.pathname.replace(pathPrefix, '')), 'utf8')
)
resourceLoader = (resource, callback) =>
callback(
null,
fs.readFileSync(
path.join(
path.dirname(file),
resource.url.pathname.replace(pathPrefix, '')
),
'utf8'
)
);
} else if (process.env.E2E_URL) {
getMarkup = () => new Promise(resolve => {
http.get(process.env.E2E_URL, (res) => {
let rawData = ''
res.on('data', chunk => rawData += chunk)
res.on('end', () => resolve(rawData))
})
})
http.get(process.env.E2E_URL, res => {
let rawData = '';
res.on('data', chunk => rawData += chunk);
res.on('end', () => resolve(rawData));
});
});
resourceLoader = (resource, callback) => resource.defaultFetch(callback)
resourceLoader = (resource, callback) => resource.defaultFetch(callback);
} else {
it.only('can run jsdom (at least one of "E2E_FILE" or "E2E_URL" environment variables must be provided)', () => {
expect(new Error('This isn\'t the error you are looking for.')).to.be.undefined()
})
it.only(
'can run jsdom (at least one of "E2E_FILE" or "E2E_URL" environment variables must be provided)',
() => {
expect(
new Error("This isn't the error you are looking for.")
).to.be.undefined();
}
);
}
export default feature => new Promise(async resolve => {
const markup = await getMarkup()
const host = process.env.E2E_URL || 'http://www.example.org/spa:3000'
const markup = await getMarkup();
const host = process.env.E2E_URL || 'http://www.example.org/spa:3000';
const doc = jsdom.jsdom(markup, {
features: {
FetchExternalResources: ['script', 'css'],
ProcessExternalResources: ['script'],
},
created: (_, win) => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true),
created: (_, win) =>
win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true),
deferClose: true,
resourceLoader,
url: `${host}#${feature}`,
virtualConsole: jsdom.createVirtualConsole().sendTo(console),
})
});
doc.close()
})
doc.close();
});

View File

@@ -7,99 +7,129 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { expect } from 'chai'
import initDOM from './initDOM'
import { expect } from 'chai';
import initDOM from './initDOM';
describe('Integration', () => {
describe('Language syntax', () => {
it('array destructuring', async () => {
const doc = await initDOM('array-destructuring')
const doc = await initDOM('array-destructuring');
expect(doc.getElementById('feature-array-destructuring').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-array-destructuring').childElementCount
).to.equal(4);
});
it('array spread', async () => {
const doc = await initDOM('array-spread')
const doc = await initDOM('array-spread');
expect(doc.getElementById('feature-array-spread').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-array-spread').childElementCount
).to.equal(4);
});
it('async/await', async () => {
const doc = await initDOM('async-await')
const doc = await initDOM('async-await');
expect(doc.getElementById('feature-async-await').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-async-await').childElementCount
).to.equal(4);
});
it('class properties', async () => {
const doc = await initDOM('class-properties')
const doc = await initDOM('class-properties');
expect(doc.getElementById('feature-class-properties').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-class-properties').childElementCount
).to.equal(4);
});
it('computed properties', async () => {
const doc = await initDOM('computed-properties')
const doc = await initDOM('computed-properties');
expect(doc.getElementById('feature-computed-properties').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-computed-properties').childElementCount
).to.equal(4);
});
it('custom interpolation', async () => {
const doc = await initDOM('custom-interpolation')
const doc = await initDOM('custom-interpolation');
expect(doc.getElementById('feature-custom-interpolation').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-custom-interpolation').childElementCount
).to.equal(4);
});
it('default parameters', async () => {
const doc = await initDOM('default-parameters')
const doc = await initDOM('default-parameters');
expect(doc.getElementById('feature-default-parameters').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-default-parameters').childElementCount
).to.equal(4);
});
it('destructuring and await', async () => {
const doc = await initDOM('destructuring-and-await')
const doc = await initDOM('destructuring-and-await');
expect(doc.getElementById('feature-destructuring-and-await').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-destructuring-and-await').childElementCount
).to.equal(4);
});
it('generators', async () => {
const doc = await initDOM('generators')
const doc = await initDOM('generators');
expect(doc.getElementById('feature-generators').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-generators').childElementCount
).to.equal(4);
});
it('object destructuring', async () => {
const doc = await initDOM('object-destructuring')
const doc = await initDOM('object-destructuring');
expect(doc.getElementById('feature-object-destructuring').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-object-destructuring').childElementCount
).to.equal(4);
});
it('object spread', async () => {
const doc = await initDOM('object-spread')
const doc = await initDOM('object-spread');
expect(doc.getElementById('feature-object-spread').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-object-spread').childElementCount
).to.equal(4);
});
it('promises', async () => {
const doc = await initDOM('promises')
const doc = await initDOM('promises');
expect(doc.getElementById('feature-promises').childElementCount).to.equal(4)
})
expect(doc.getElementById('feature-promises').childElementCount).to.equal(
4
);
});
it('rest + default', async () => {
const doc = await initDOM('rest-and-default')
const doc = await initDOM('rest-and-default');
expect(doc.getElementById('feature-rest-and-default').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-rest-and-default').childElementCount
).to.equal(4);
});
it('rest parameters', async () => {
const doc = await initDOM('rest-parameters')
const doc = await initDOM('rest-parameters');
expect(doc.getElementById('feature-rest-parameters').childElementCount).to.equal(4)
})
expect(
doc.getElementById('feature-rest-parameters').childElementCount
).to.equal(4);
});
it('template interpolation', async () => {
const doc = await initDOM('template-interpolation')
const doc = await initDOM('template-interpolation');
expect(doc.getElementById('feature-template-interpolation').childElementCount).to.equal(4)
})
})
})
expect(
doc.getElementById('feature-template-interpolation').childElementCount
).to.equal(4);
});
});
});

View File

@@ -7,46 +7,57 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { expect } from 'chai'
import initDOM from './initDOM'
import { expect } from 'chai';
import initDOM from './initDOM';
describe('Integration', () => {
describe('Webpack plugins', () => {
it('css inclusion', async () => {
const doc = await initDOM('css-inclusion')
const doc = await initDOM('css-inclusion');
expect(doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, ''))
.to.match(/#feature-css-inclusion\{background:.+;color:.+}/)
})
expect(
doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, '')
).to.match(/#feature-css-inclusion\{background:.+;color:.+}/);
});
it('image inclusion', async () => {
const doc = await initDOM('image-inclusion')
const doc = await initDOM('image-inclusion');
expect(doc.getElementById('feature-image-inclusion').src).to.match(/^data:image\/jpeg;base64.+==$/)
})
expect(doc.getElementById('feature-image-inclusion').src).to.match(
/^data:image\/jpeg;base64.+==$/
);
});
it('no ext inclusion', async () => {
const doc = await initDOM('no-ext-inclusion')
const doc = await initDOM('no-ext-inclusion');
expect(doc.getElementById('feature-no-ext-inclusion').href).to.match(/\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/)
})
expect(doc.getElementById('feature-no-ext-inclusion').href).to.match(
/\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/
);
});
it('json inclusion', async () => {
const doc = await initDOM('json-inclusion')
const doc = await initDOM('json-inclusion');
expect(doc.getElementById('feature-json-inclusion').textContent).to.equal('This is an abstract.')
})
expect(doc.getElementById('feature-json-inclusion').textContent).to.equal(
'This is an abstract.'
);
});
it('svg inclusion', async () => {
const doc = await initDOM('svg-inclusion')
const doc = await initDOM('svg-inclusion');
expect(doc.getElementById('feature-svg-inclusion').src).to.match(/\/static\/media\/logo\..+\.svg$/)
})
expect(doc.getElementById('feature-svg-inclusion').src).to.match(
/\/static\/media\/logo\..+\.svg$/
);
});
it('unknown ext inclusion', async () => {
const doc = await initDOM('unknown-ext-inclusion')
const doc = await initDOM('unknown-ext-inclusion');
expect(doc.getElementById('feature-unknown-ext-inclusion').href).to.match(/\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/)
})
})
})
expect(doc.getElementById('feature-unknown-ext-inclusion').href).to.match(
/\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/
);
});
});
});

View File

@@ -11,8 +11,8 @@ import React, { Component, PropTypes, createElement } from 'react';
class BuiltEmitter extends Component {
static propTypes = {
feature: PropTypes.func.isRequired
}
feature: PropTypes.func.isRequired,
};
componentDidMount() {
const { feature } = this.props;
@@ -31,12 +31,12 @@ class BuiltEmitter extends Component {
render() {
const {
props: { feature },
handleReady
handleReady,
} = this;
return (
<div>
{createElement(feature, {
onReady: handleReady
onReady: handleReady,
})}
</div>
);
@@ -56,81 +56,113 @@ class App extends Component {
const feature = location.hash.slice(1);
switch (feature) {
case 'array-destructuring':
import('./features/syntax/ArrayDestructuring').then(f => this.setFeature(f.default));
import(
'./features/syntax/ArrayDestructuring'
).then(f => this.setFeature(f.default));
break;
case 'array-spread':
import('./features/syntax/ArraySpread').then(f => this.setFeature(f.default));
import('./features/syntax/ArraySpread').then(f =>
this.setFeature(f.default));
break;
case 'async-await':
import('./features/syntax/AsyncAwait').then(f => this.setFeature(f.default));
import('./features/syntax/AsyncAwait').then(f =>
this.setFeature(f.default));
break;
case 'class-properties':
import('./features/syntax/ClassProperties').then(f => this.setFeature(f.default));
import('./features/syntax/ClassProperties').then(f =>
this.setFeature(f.default));
break;
case 'computed-properties':
import('./features/syntax/ComputedProperties').then(f => this.setFeature(f.default));
import(
'./features/syntax/ComputedProperties'
).then(f => this.setFeature(f.default));
break;
case 'css-inclusion':
import('./features/webpack/CssInclusion').then(f => this.setFeature(f.default));
import('./features/webpack/CssInclusion').then(f =>
this.setFeature(f.default));
break;
case 'custom-interpolation':
import('./features/syntax/CustomInterpolation').then(f => this.setFeature(f.default));
import(
'./features/syntax/CustomInterpolation'
).then(f => this.setFeature(f.default));
break;
case 'default-parameters':
import('./features/syntax/DefaultParameters').then(f => this.setFeature(f.default));
import('./features/syntax/DefaultParameters').then(f =>
this.setFeature(f.default));
break;
case 'destructuring-and-await':
import('./features/syntax/DestructuringAndAwait').then(f => this.setFeature(f.default));
import(
'./features/syntax/DestructuringAndAwait'
).then(f => this.setFeature(f.default));
break;
case 'file-env-variables':
import('./features/env/FileEnvVariables').then(f => this.setFeature(f.default));
import('./features/env/FileEnvVariables').then(f =>
this.setFeature(f.default));
break;
case 'generators':
import('./features/syntax/Generators').then(f => this.setFeature(f.default));
import('./features/syntax/Generators').then(f =>
this.setFeature(f.default));
break;
case 'image-inclusion':
import('./features/webpack/ImageInclusion').then(f => this.setFeature(f.default));
import('./features/webpack/ImageInclusion').then(f =>
this.setFeature(f.default));
break;
case 'json-inclusion':
import('./features/webpack/JsonInclusion').then(f => this.setFeature(f.default));
import('./features/webpack/JsonInclusion').then(f =>
this.setFeature(f.default));
break;
case 'node-path':
import('./features/env/NodePath').then(f => this.setFeature(f.default));
break;
case 'no-ext-inclusion':
import('./features/webpack/NoExtInclusion').then(f => this.setFeature(f.default));
import('./features/webpack/NoExtInclusion').then(f =>
this.setFeature(f.default));
break;
case 'object-destructuring':
import('./features/syntax/ObjectDestructuring').then(f => this.setFeature(f.default));
import(
'./features/syntax/ObjectDestructuring'
).then(f => this.setFeature(f.default));
break;
case 'object-spread':
import('./features/syntax/ObjectSpread').then(f => this.setFeature(f.default));
import('./features/syntax/ObjectSpread').then(f =>
this.setFeature(f.default));
break;
case 'promises':
import('./features/syntax/Promises').then(f => this.setFeature(f.default));
import('./features/syntax/Promises').then(f =>
this.setFeature(f.default));
break;
case 'public-url':
import('./features/env/PublicUrl').then(f => this.setFeature(f.default));
import('./features/env/PublicUrl').then(f =>
this.setFeature(f.default));
break;
case 'rest-and-default':
import('./features/syntax/RestAndDefault').then(f => this.setFeature(f.default));
import('./features/syntax/RestAndDefault').then(f =>
this.setFeature(f.default));
break;
case 'rest-parameters':
import('./features/syntax/RestParameters').then(f => this.setFeature(f.default));
import('./features/syntax/RestParameters').then(f =>
this.setFeature(f.default));
break;
case 'shell-env-variables':
import('./features/env/ShellEnvVariables').then(f => this.setFeature(f.default));
import('./features/env/ShellEnvVariables').then(f =>
this.setFeature(f.default));
break;
case 'svg-inclusion':
import('./features/webpack/SvgInclusion').then(f => this.setFeature(f.default));
import('./features/webpack/SvgInclusion').then(f =>
this.setFeature(f.default));
break;
case 'template-interpolation':
import('./features/syntax/TemplateInterpolation').then(f => this.setFeature(f.default));
import(
'./features/syntax/TemplateInterpolation'
).then(f => this.setFeature(f.default));
break;
case 'unknown-ext-inclusion':
import('./features/webpack/UnknownExtInclusion').then(f => this.setFeature(f.default));
import(
'./features/webpack/UnknownExtInclusion'
).then(f => this.setFeature(f.default));
break;
default: throw new Error(`Missing feature "${feature}"`);
default:
throw new Error(`Missing feature "${feature}"`);
}
}

View File

@@ -11,5 +11,5 @@ export default () => [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
]
{ id: 4, name: '4' },
];

View File

@@ -7,8 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import React from 'react';
export default () => (
<span id="feature-file-env-variables">{process.env.REACT_APP_FILE_ENV_MESSAGE}.</span>
)
<span id="feature-file-env-variables">
{process.env.REACT_APP_FILE_ENV_MESSAGE}.
</span>
);

View File

@@ -7,13 +7,13 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import load from 'absoluteLoad'
import React, { Component, PropTypes } from 'react';
import load from 'absoluteLoad';
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -32,9 +32,7 @@ export default class extends Component {
render() {
return (
<div id="feature-node-path">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,8 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import React from 'react';
export default () => (
<span id="feature-public-url">{process.env.PUBLIC_URL}.</span>
)
);

View File

@@ -7,8 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import React from 'react';
export default () => (
<span id="feature-shell-env-variables">{process.env.REACT_APP_SHELL_ENV_MESSAGE}.</span>
)
<span id="feature-shell-env-variables">
{process.env.REACT_APP_SHELL_ENV_MESSAGE}.
</span>
);

View File

@@ -7,21 +7,16 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load() {
return [
[1, '1'],
[2, '2'],
[3, '3'],
[4, '4']
];
return [[1, '1'], [2, '2'], [3, '3'], [4, '4']];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -42,7 +37,7 @@ export default class extends Component {
<div id="feature-array-destructuring">
{this.state.users.map(user => {
const [id, name] = user;
return <div key={id}>{name}</div>
return <div key={id}>{name}</div>;
})}
</div>
);

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load(users) {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
...users
...users,
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-array-spread">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
async function load() {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
{ id: 4, name: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-async-await">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,30 +7,28 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
users = [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
{ id: 4, name: '4' },
];
componentDidMount() {
this.props.onReady()
this.props.onReady();
}
render() {
return (
<div id="feature-class-properties">
{this.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load(prefix) {
return [
{ id: 1, [prefix + 'name']: '1' },
{ id: 2, [prefix + 'name']: '2' },
{ id: 3, [prefix + 'name']: '3' },
{ id: 4, [prefix + 'name']: '4' }
{ id: 1, [`${prefix} name`]: '1' },
{ id: 2, [`${prefix} name`]: '2' },
{ id: 3, [`${prefix} name`]: '3' },
{ id: 4, [`${prefix} name`]: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);

View File

@@ -7,26 +7,28 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
const styled = ([style]) => style.trim()
.split(/\s*;\s*/)
.map(rule => rule.split(/\s*:\s*/))
.reduce((rules, rule) => ({ ...rules, [rule[0]]: rule[1] }), {});
const styled = ([style]) =>
style
.trim()
.split(/\s*;\s*/)
.map(rule => rule.split(/\s*:\s*/))
.reduce((rules, rule) => ({ ...rules, [rule[0]]: rule[1] }), {});
function load() {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
{ id: 4, name: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load(id = 0) {
return [
{ id: id + 1, name: '1' },
{ id: id + 2, name: '2' },
{ id: id + 3, name: '3' },
{ id: id + 4, name: '4' }
{ id: id + 4, name: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-default-parameters">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,23 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
async function load() {
return { users: [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
] };
return {
users: [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' },
],
};
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +42,7 @@ export default class extends Component {
render() {
return (
<div id="feature-destructuring-and-await">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,9 +7,9 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function * load(limit) {
function* load(limit) {
let i = 1;
while (i <= limit) {
yield { id: i, name: i };
@@ -19,8 +19,8 @@ function * load(limit) {
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -42,9 +42,7 @@ export default class extends Component {
render() {
return (
<div id="feature-generators">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load() {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
{ id: 4, name: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -42,7 +42,7 @@ export default class extends Component {
<div id="feature-object-destructuring">
{this.state.users.map(user => {
const { id, name } = user;
return <div key={id}>{name}</div>
return <div key={id}>{name}</div>;
})}
</div>
);

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load(baseUser) {
return [
{ id: 1, name: '1', ...baseUser },
{ id: 2, name: '2', ...baseUser },
{ id: 3, name: '3', ...baseUser },
{ id: 4, name: '4', ...baseUser }
{ id: 4, name: '4', ...baseUser },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load() {
return Promise.resolve([
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' }
{ id: 4, name: '4' },
]);
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -41,9 +41,7 @@ export default class extends Component {
render() {
return (
<div id="feature-promises">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) {
return [
{ id: id + 1, name: '1' },
{ id: id + 2, name: '2' },
{ id: id + 3, name: '3' },
rest.user
rest.user,
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-rest-and-default">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load({ id = 0, ...rest }) {
return [
{ id: id + 1, name: '1' },
{ id: id + 2, name: '2' },
{ id: id + 3, name: '3' },
rest.user
rest.user,
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-rest-parameters">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,21 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component, PropTypes } from 'react'
import React, { Component, PropTypes } from 'react';
function load(name) {
return [
{ id: 1, name: `${name}1` },
{ id: 2, name: `${name}2` },
{ id: 3, name: `${name}3` },
{ id: 4, name: `${name}4` }
{ id: 4, name: `${name}4` },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired
}
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
@@ -40,9 +40,7 @@ export default class extends Component {
render() {
return (
<div id="feature-template-interpolation">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}

View File

@@ -7,9 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import './assets/style.css'
import React from 'react';
import './assets/style.css';
export default () => (
<p id="feature-css-inclusion">We love useless text.</p>
)
export default () => <p id="feature-css-inclusion">We love useless text.</p>;

View File

@@ -7,9 +7,9 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import tiniestCat from './assets/tiniest-cat.jpg'
import React from 'react';
import tiniestCat from './assets/tiniest-cat.jpg';
export default () => (
<img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" />
)
);

View File

@@ -7,9 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import { abstract } from './assets/abstract.json'
import React from 'react';
import { abstract } from './assets/abstract.json';
export default () => (
<summary id="feature-json-inclusion">{abstract}</summary>
)
export default () => <summary id="feature-json-inclusion">{abstract}</summary>;

View File

@@ -7,13 +7,13 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import aFileWithoutExt from './assets/aFileWithoutExt'
import React from 'react';
import aFileWithoutExt from './assets/aFileWithoutExt';
const text = aFileWithoutExt.includes('base64')
? atob(aFileWithoutExt.split('base64,')[1]).trim()
: aFileWithoutExt
: aFileWithoutExt;
export default () => (
<a id="feature-no-ext-inclusion" href={text}>aFileWithoutExt</a>
)
);

View File

@@ -7,9 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import logo from './assets/logo.svg'
import React from 'react';
import logo from './assets/logo.svg';
export default () => (
<img id="feature-svg-inclusion" src={logo} alt="logo" />
)
export default () => <img id="feature-svg-inclusion" src={logo} alt="logo" />;

View File

@@ -7,13 +7,13 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react'
import aFileWithExtUnknown from './assets/aFileWithExt.unknown'
import React from 'react';
import aFileWithExtUnknown from './assets/aFileWithExt.unknown';
const text = aFileWithExtUnknown.includes('base64')
? atob(aFileWithExtUnknown.split('base64,')[1]).trim()
: aFileWithExtUnknown
: aFileWithExtUnknown;
export default () => (
<a id="feature-unknown-ext-inclusion" href={text}>aFileWithExtUnknown</a>
)
);

View File

@@ -11,7 +11,4 @@ import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root')
);
ReactDOM.render(<App />, document.getElementById('root'));

View File

@@ -7,4 +7,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
module.exports = function() { return `haha` }
module.exports = function() {
return `haha`;
};