Skip to content

Commit ae13e10

Browse files
committedJan 10, 2019
Use prettier
1 parent 0455f81 commit ae13e10

11 files changed

+117
-106
lines changed
 

‎LICENSE.md

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ The MIT License (MIT)
22

33
Copyright (c) 2015 Shusaku Uesugi, (c) 2016-present Alexander Kuznetsov
44

5-
65
Permission is hereby granted, free of charge, to any person obtaining a copy
76
of this software and associated documentation files (the "Software"), to deal
87
in the Software without restriction, including without limitation the rights

‎README.md

+22-19
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Check out [examples](examples) directory for more details.
3333
### Theming
3434

3535
This component now uses [react-base16-styling](https://github.com/alexkuz/react-base16-styling) module, which allows to customize component via `theme` property, which can be the following:
36+
3637
- [base16](http://chriskempson.github.io/base16) theme data. [The example theme data can be found here](https://github.com/gaearon/redux-devtools/tree/75322b15ee7ba03fddf10ac3399881e302848874/src/react/themes).
3738
- object that contains style objects, strings (that treated as classnames) or functions. A function is used to extend its first argument `{ style, className }` and should return an object with the same structure. Other arguments depend on particular context (and should be described here). See [createStylingFromTheme.js](https://github.com/alexkuz/react-json-tree/blob/feature-refactor-styling/src/createStylingFromTheme.js) for the list of styling object keys. Also, this object can extend `base16` theme via `extend` property.
3839

@@ -62,8 +63,7 @@ const theme = {
6263

6364
<div>
6465
<JSONTree data={data} theme={theme} invertTheme={false} />
65-
</div>
66-
66+
</div>;
6767
```
6868

6969
#### Result (Monokai theme, dark background):
@@ -74,21 +74,24 @@ const theme = {
7474

7575
```jsx
7676
<div>
77-
<JSONTree data={data} theme={{
78-
extend: theme,
79-
// underline keys for literal values
80-
valueLabel: {
81-
textDecoration: 'underline'
82-
},
83-
// switch key for objects to uppercase when object is expanded.
84-
// `nestedNodeLabel` receives additional arguments `expanded` and `keyPath`
85-
nestedNodeLabel: ({ style }, nodeType, expanded) => ({
86-
style: {
87-
...style,
88-
textTransform: expanded ? 'uppercase' : style.textTransform
89-
}
90-
})
91-
}} />
77+
<JSONTree
78+
data={data}
79+
theme={{
80+
extend: theme,
81+
// underline keys for literal values
82+
valueLabel: {
83+
textDecoration: 'underline'
84+
},
85+
// switch key for objects to uppercase when object is expanded.
86+
// `nestedNodeLabel` receives additional arguments `expanded` and `keyPath`
87+
nestedNodeLabel: ({ style }, nodeType, expanded) => ({
88+
style: {
89+
...style,
90+
textTransform: expanded ? 'uppercase' : style.textTransform
91+
}
92+
})
93+
}}
94+
/>
9295
</div>
9396
```
9497

@@ -120,8 +123,8 @@ You can pass the following properties to customize rendered labels and values:
120123
121124
```jsx
122125
<JSONTree
123-
labelRenderer={raw => <strong>{raw}</strong>}
124-
valueRenderer={raw => <em>{raw}</em>}
126+
labelRenderer={raw => <strong>{raw}</strong>}
127+
valueRenderer={raw => <em>{raw}</em>}
125128
/>
126129
```
127130

‎examples/README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
react-hot-boilerplate
2-
=====================
1+
# react-hot-boilerplate
32

43
The minimal dev environment to enable live-editing React components.
54

@@ -32,16 +31,16 @@ This boilerplate is purposefully simple to show the minimal configuration for Re
3231

3332
### Dependencies
3433

35-
* React
36-
* Webpack
37-
* [webpack-dev-server](https://github.com/webpack/webpack-dev-server)
38-
* [babel-loader](https://github.com/babel/babel-loader)
39-
* [react-hot-loader](https://github.com/gaearon/react-hot-loader)
34+
- React
35+
- Webpack
36+
- [webpack-dev-server](https://github.com/webpack/webpack-dev-server)
37+
- [babel-loader](https://github.com/babel/babel-loader)
38+
- [react-hot-loader](https://github.com/gaearon/react-hot-loader)
4039

4140
### Resources
4241

43-
* [Demo video](http://vimeo.com/100010922)
44-
* [react-hot-loader on Github](https://github.com/gaearon/react-hot-loader)
45-
* [Integrating JSX live reload into your workflow](http://gaearon.github.io/react-hot-loader/getstarted/)
46-
* [Troubleshooting guide](https://github.com/gaearon/react-hot-loader/blob/master/docs/Troubleshooting.md)
47-
* Ping dan_abramov on Twitter or #reactjs IRC
42+
- [Demo video](http://vimeo.com/100010922)
43+
- [react-hot-loader on Github](https://github.com/gaearon/react-hot-loader)
44+
- [Integrating JSX live reload into your workflow](http://gaearon.github.io/react-hot-loader/getstarted/)
45+
- [Troubleshooting guide](https://github.com/gaearon/react-hot-loader/blob/master/docs/Troubleshooting.md)
46+
- Ping dan_abramov on Twitter or #reactjs IRC

‎examples/index.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
<title>Sample App</title>
44
<style>
55
body {
6-
font-family: SF UI Text,Roboto,Helvetica Neue,Helvetica,sans-serif;
6+
font-family: SF UI Text, Roboto, Helvetica Neue, Helvetica, sans-serif;
77
font-size: 18px;
88
line-height: 1.5;
99
}
1010
</style>
1111
</head>
1212
<body>
13-
<div id='root'>
14-
</div>
13+
<div id="root"></div>
1514
<script src="/static/bundle.js"></script>
1615
</body>
1716
</html>

‎examples/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ new WebpackDevServer(webpack(config), {
77
publicPath: config.output.publicPath,
88
hot: true,
99
historyApiFallback: true
10-
}).listen(3000, 'localhost', function (err) {
10+
}).listen(3000, 'localhost', function(err) {
1111
if (err) {
1212
console.log(err);
1313
}

‎examples/webpack.config.js

+19-15
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,33 @@ module.exports = {
2323
}),
2424
new webpack.HotModuleReplacementPlugin(),
2525
new webpack.NoEmitOnErrorsPlugin(),
26-
isProduction && new webpack.optimize.UglifyJsPlugin({
27-
compress: { warnings: false },
28-
output: { comments: false },
29-
sourceMap: true
30-
})
26+
isProduction &&
27+
new webpack.optimize.UglifyJsPlugin({
28+
compress: { warnings: false },
29+
output: { comments: false },
30+
sourceMap: true
31+
})
3132
].filter(Boolean),
3233
resolve: {
3334
alias: {
3435
'react-json-tree/lib': path.join(__dirname, '..', 'src'),
3536
'react-json-tree': path.join(__dirname, '..', 'src'),
36-
'react': path.join(__dirname, 'node_modules', 'react')
37+
react: path.join(__dirname, 'node_modules', 'react')
3738
},
3839
extensions: ['.js']
3940
},
4041
module: {
41-
loaders: [{
42-
test: /\.js$/,
43-
loaders: ['babel-loader'].filter(Boolean),
44-
include: path.join(__dirname, 'src')
45-
}, {
46-
test: /\.js$/,
47-
loaders: ['babel-loader'].filter(Boolean),
48-
include: path.join(__dirname, '..', 'src')
49-
}]
42+
loaders: [
43+
{
44+
test: /\.js$/,
45+
loaders: ['babel-loader'].filter(Boolean),
46+
include: path.join(__dirname, 'src')
47+
},
48+
{
49+
test: /\.js$/,
50+
loaders: ['babel-loader'].filter(Boolean),
51+
include: path.join(__dirname, '..', 'src')
52+
}
53+
]
5054
}
5155
};

‎package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"type": "git",
2323
"url": "https://github.com/reduxjs/redux-devtools.git"
2424
},
25-
"keywords": ["react", "json viewer"],
25+
"keywords": [
26+
"react",
27+
"json viewer"
28+
],
2629
"author": "Shu Uesugi <shu@chibicode.com> (http://github.com/chibicode)",
2730
"contributors": [
2831
"Alexander Kuznetsov <alexkuz@gmail.com> (http://kuzya.org/)",
@@ -55,7 +58,7 @@
5558
"terser-webpack-plugin": "^1.2.1",
5659
"webpack": "^4.27.1",
5760
"webpack-cli": "^3.2.0"
58-
},
61+
},
5962
"peerDependencies": {
6063
"react": "^15.0.0 || ^16.0.0",
6164
"react-dom": "^15.0.0 || ^16.0.0"

‎src/JSONNode.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ const JSONNode = ({
8686
return <JSONValueNode {...simpleNodeProps} />;
8787
default:
8888
return (
89-
<JSONValueNode {...simpleNodeProps} valueGetter={() => `<${nodeType}>`} />
89+
<JSONValueNode
90+
{...simpleNodeProps}
91+
valueGetter={() => `<${nodeType}>`}
92+
/>
9093
);
9194
}
9295
};

‎src/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ export default class JSONTree extends React.Component {
117117
}
118118

119119
shouldComponentUpdate(nextProps) {
120-
return !!Object.keys(nextProps).find(
121-
k =>
122-
k === 'keyPath'
123-
? nextProps[k].join('/') !== this.props[k].join('/')
124-
: nextProps[k] !== this.props[k]
120+
return !!Object.keys(nextProps).find(k =>
121+
k === 'keyPath'
122+
? nextProps[k].join('/') !== this.props[k].join('/')
123+
: nextProps[k] !== this.props[k]
125124
);
126125
}
127126

‎src/objType.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ export default function objType(obj) {
44
return 'Iterable';
55
}
66

7-
if (type === 'Custom' && obj.constructor !== Object && obj instanceof Object) {
7+
if (
8+
type === 'Custom' &&
9+
obj.constructor !== Object &&
10+
obj instanceof Object
11+
) {
812
// For projects implementing objects overriding `.prototype[Symbol.toStringTag]`
913
return 'Object';
1014
}

‎webpack.config.umd.js

+44-46
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
11
const path = require('path');
22
const TerserPlugin = require('terser-webpack-plugin');
33

4-
module.exports = (env = {}) => (
5-
{
6-
mode: 'production',
7-
entry: {
8-
app: ['./src/index.js']
9-
},
10-
output: {
11-
library: 'ReactJsonTree',
12-
libraryTarget: 'umd',
13-
path: path.resolve(__dirname, 'umd'),
14-
filename: env.minimize ? 'react-json-tree.min.js' : 'react-json-tree.js'
15-
},
16-
module: {
17-
rules: [
18-
{
19-
test: /\.js$/,
20-
loader: 'babel-loader',
21-
exclude: /node_modules/
22-
}
23-
]
24-
},
25-
externals: {
26-
react: {
27-
root: 'React',
28-
commonjs2: 'react',
29-
commonjs: 'react',
30-
amd: 'react'
31-
},
32-
'react-dom': {
33-
root: 'ReactDOM',
34-
commonjs2: 'react-dom',
35-
commonjs: 'react-dom',
36-
amd: 'react-dom'
4+
module.exports = (env = {}) => ({
5+
mode: 'production',
6+
entry: {
7+
app: ['./src/index.js']
8+
},
9+
output: {
10+
library: 'ReactJsonTree',
11+
libraryTarget: 'umd',
12+
path: path.resolve(__dirname, 'umd'),
13+
filename: env.minimize ? 'react-json-tree.min.js' : 'react-json-tree.js'
14+
},
15+
module: {
16+
rules: [
17+
{
18+
test: /\.js$/,
19+
loader: 'babel-loader',
20+
exclude: /node_modules/
3721
}
22+
]
23+
},
24+
externals: {
25+
react: {
26+
root: 'React',
27+
commonjs2: 'react',
28+
commonjs: 'react',
29+
amd: 'react'
3830
},
39-
optimization: {
40-
minimize: !!env.minimize,
41-
minimizer: [
42-
new TerserPlugin({
43-
terserOptions: {
44-
safari10: true
45-
}
46-
})
47-
]
48-
},
49-
performance: {
50-
hints: false
31+
'react-dom': {
32+
root: 'ReactDOM',
33+
commonjs2: 'react-dom',
34+
commonjs: 'react-dom',
35+
amd: 'react-dom'
5136
}
37+
},
38+
optimization: {
39+
minimize: !!env.minimize,
40+
minimizer: [
41+
new TerserPlugin({
42+
terserOptions: {
43+
safari10: true
44+
}
45+
})
46+
]
47+
},
48+
performance: {
49+
hints: false
5250
}
53-
);
51+
});

0 commit comments

Comments
 (0)
Please sign in to comment.