Skip to content

Commit bef754d

Browse files
committed
prettier
1 parent 48144f3 commit bef754d

12 files changed

+69
-95
lines changed

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*.json
22
*.yml
3+
dist
4+
flow-typed

.prettierrc

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2+
"arrowParens": "avoid",
3+
"printWidth": 100,
4+
"jsxBracketSameLine": false,
25
"semi": true,
36
"singleQuote": true,
4-
"trailingComma": "es5",
5-
"printWidth": 100
7+
"tabWidth": 2,
8+
"trailingComma": "es5"
69
}

appveyor.yml

-27
This file was deleted.

benchmarks/run-headless.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const tracing = process.argv.some(arg => arg.indexOf('tracing') > -1);
66

77
if (tracing) {
88
console.log(
9-
'\nTracing enabled. (note that this might impact benchmark results, we recommend leaving this turned off unless you need a trace)'
9+
'\nTracing enabled. (note that this might impact benchmark results, we recommend leaving this turned off unless you need a trace)',
1010
);
1111
}
1212

@@ -18,7 +18,7 @@ if (tracing) {
1818
await page.goto(`file://${path.join(__dirname, './dist/index.html')}`);
1919

2020
console.log(
21-
'Running benchmarks... (this may take a minute or two; do not use your machine while these are running!)'
21+
'Running benchmarks... (this may take a minute or two; do not use your machine while these are running!)',
2222
);
2323
for (var i = 0; i < tests.length; i++) {
2424
const test = tests[i];

benchmarks/src/impl.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ type ComponentsType = {
88
Box: Component,
99
Dot: Component,
1010
Provider: Component,
11-
View: Component
11+
View: Component,
1212
};
1313

1414
type ImplementationType = {
1515
components: ComponentsType,
1616
name: string,
17-
version: string
17+
version: string,
1818
};
1919

2020
const toImplementations = (context: Object): Array<ImplementationType> =>

benchmarks/src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const createTestBlock = fn => {
2121
Provider,
2222
benchmarkType,
2323
version,
24-
name
24+
name,
2525
};
2626
return testSetups;
2727
}, {});
@@ -33,14 +33,14 @@ const tests = {
3333
Component: Tree,
3434
getComponentProps: () => ({ breadth: 2, components, depth: 7, id: 0, wrap: 1 }),
3535
Provider: components.Provider,
36-
sampleCount: 500
36+
sampleCount: 500,
3737
})),
3838
'Mount wide tree': createTestBlock(components => ({
3939
benchmarkType: 'mount',
4040
Component: Tree,
4141
getComponentProps: () => ({ breadth: 6, components, depth: 3, id: 0, wrap: 2 }),
4242
Provider: components.Provider,
43-
sampleCount: 500
43+
sampleCount: 500,
4444
})),
4545
'Update dynamic styles': createTestBlock(components => ({
4646
benchmarkType: 'update',
@@ -49,8 +49,8 @@ const tests = {
4949
return { components, s: 200, renderCount: cycle, x: 0, y: 0 };
5050
},
5151
Provider: components.Provider,
52-
sampleCount: 1000
53-
}))
52+
sampleCount: 1000,
53+
})),
5454
};
5555

5656
ReactDOM.render(<App tests={tests} />, document.querySelector('.root'));

benchmarks/webpack.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @flow
2-
const webpack = require('webpack')
3-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
4-
const path = require('path')
2+
const webpack = require('webpack');
3+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
4+
const path = require('path');
55

6-
const appDirectory = path.resolve(__dirname)
6+
const appDirectory = path.resolve(__dirname);
77

88
module.exports = {
99
mode: 'production',
@@ -51,4 +51,4 @@ module.exports = {
5151
'styled-components': path.resolve('../src'),
5252
},
5353
},
54-
}
54+
};

example/devServer.js

+32-34
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
1-
const path = require('path')
2-
const exec = require('child_process').exec
3-
const Express = require('express')
4-
const watch = require('node-watch')
1+
const path = require('path');
2+
const exec = require('child_process').exec;
3+
const Express = require('express');
4+
const watch = require('node-watch');
55

6-
import fs from 'fs'
7-
import React from 'react'
8-
import { renderToString } from 'react-dom/server'
9-
import { ServerStyleSheet } from '..'
10-
import getExample from './example'
6+
import fs from 'fs';
7+
import React from 'react';
8+
import { renderToString } from 'react-dom/server';
9+
import { ServerStyleSheet } from '..';
10+
import getExample from './example';
1111

12-
const HTML = fs.readFileSync(__dirname + '/index.html').toString()
12+
const HTML = fs.readFileSync(__dirname + '/index.html').toString();
1313

14-
const srcPath = __dirname.split('/example')[0] + '/src'
14+
const srcPath = __dirname.split('/example')[0] + '/src';
1515

1616
const hotBuild = () =>
1717
exec('npm run build:dist', (err, stdout, stderr) => {
18-
if (err) throw err
18+
if (err) throw err;
1919
if (stdout) {
20-
console.log(`npm run build:dist --- ${stdout}`)
20+
console.log(`npm run build:dist --- ${stdout}`);
2121
}
2222
if (stderr) {
23-
console.log(`npm run build:dist --- ${stderr}`)
23+
console.log(`npm run build:dist --- ${stderr}`);
2424
}
25-
})
25+
});
2626

2727
watch(srcPath, filename => {
28-
console.log(`${filename} file has changed`)
29-
hotBuild()
30-
})
28+
console.log(`${filename} file has changed`);
29+
hotBuild();
30+
});
3131

32-
const app = new Express()
32+
const app = new Express();
3333

34-
app.use(Express.static(__dirname))
35-
app.use(Express.static('dist'))
34+
app.use(Express.static(__dirname));
35+
app.use(Express.static('dist'));
3636

3737
app.get('/with-perf.html', (req, res) => {
38-
res.sendFile(path.join(__dirname, 'with-perf.html'))
39-
})
38+
res.sendFile(path.join(__dirname, 'with-perf.html'));
39+
});
4040

4141
app.get('/ssr.html', (req, res) => {
42-
const Example = getExample()
42+
const Example = getExample();
4343

44-
const sheet = new ServerStyleSheet()
45-
const html = renderToString(sheet.collectStyles(<Example />))
46-
const css = sheet.getStyleTags()
47-
res.send(
48-
HTML.replace(/<!-- SSR:HTML -->/, html).replace(/<!-- SSR:CSS -->/, css)
49-
)
50-
})
44+
const sheet = new ServerStyleSheet();
45+
const html = renderToString(sheet.collectStyles(<Example />));
46+
const css = sheet.getStyleTags();
47+
res.send(HTML.replace(/<!-- SSR:HTML -->/, html).replace(/<!-- SSR:CSS -->/, css));
48+
});
5149

5250
app.get('/', (req, res) => {
53-
res.sendFile(path.join(__dirname, 'index.html'))
54-
})
51+
res.sendFile(path.join(__dirname, 'index.html'));
52+
});
5553

56-
export default app
54+
export default app;

example/example.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react'
2-
import styled, { createGlobalStyle, keyframes } from '..'
1+
import React from 'react';
2+
import styled, { createGlobalStyle, keyframes } from '..';
33

44
export default () => {
55
const GlobalStyle = createGlobalStyle`
66
body {
77
font-family: sans-serif;
88
}
9-
`
9+
`;
1010

1111
// Create a <Title> react component that renders an <h1> which is
1212
// centered, palevioletred and sized at 1.5em
@@ -15,14 +15,14 @@ export default () => {
1515
text-align: center;
1616
color: palevioletred;
1717
animation: ${keyframes`from { opacity: 0; }`} 1s both;
18-
`
18+
`;
1919

2020
// Create a <Wrapper> react component that renders a <section> with
2121
// some padding and a papayawhip background
2222
const Wrapper = styled.section`
2323
padding: 4em;
2424
background: papayawhip;
25-
`
25+
`;
2626

2727
return class Example extends React.Component {
2828
render() {
@@ -31,7 +31,7 @@ export default () => {
3131
<GlobalStyle />
3232
<Title>Hello World, this is my first styled component!</Title>
3333
</Wrapper>
34-
)
34+
);
3535
}
36-
}
37-
}
36+
};
37+
};

example/startServer.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import app from './devServer'
1+
import app from './devServer';
22

3-
const port = 3000
3+
const port = 3000;
44

55
app.listen(port, error => {
66
/* eslint-disable no-console */
77
if (error) {
8-
console.error(error)
8+
console.error(error);
99
} else {
10-
console.info(
11-
'🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.',
12-
port,
13-
port
14-
)
10+
console.info('🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.', port, port);
1511
}
1612
/* eslint-enable no-console */
17-
})
13+
});

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"flow:watch": "flow-watch",
2828
"format": "eslint ./**/*.js --fix",
2929
"lint": "eslint src",
30+
"prettier": "prettier */**/*.js --write",
3031
"prepublishOnly": "run-s build",
3132
"lint-staged": "lint-staged",
3233
"dev": "cross-env BABEL_ENV=cjs babel-node example/startServer.js",

scripts/postinstall.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-disable */
33
/* Adapted from nodemon's postinstall: https://github.com/remy/nodemon/blob/master/package.json */
44

5-
var msg = 'Use styled-components at work? Consider supporting our development efforts at opencollective.com/styled-components';
5+
var msg =
6+
'Use styled-components at work? Consider supporting our development efforts at opencollective.com/styled-components';
67

78
console.log(msg);

0 commit comments

Comments
 (0)