Skip to content

Commit 77547d6

Browse files
committed
chore(lint): apply prettier on existing files
1 parent 4af61ff commit 77547d6

11 files changed

+107
-93
lines changed

examples/generate.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
'use strict';
2-
var fs = require('fs');
3-
var ejs = require('ejs');
4-
var data = require('./vars');
5-
var tpl = fs.readFileSync(__dirname + '/template.ejs').toString();
1+
"use strict";
2+
var fs = require("fs");
3+
var ejs = require("ejs");
4+
var data = require("./vars");
5+
var tpl = fs.readFileSync(__dirname + "/template.ejs").toString();
66

7-
var base = 'http://localhost:4002';
8-
var banner = 'Do not edit this file! It is generated by `generate.js` in this folder, from `template.ejs` and ' +
9-
'vars.js.';
7+
var base = "http://localhost:4002";
8+
var banner =
9+
"Do not edit this file! It is generated by `generate.js` in this folder, from `template.ejs` and " +
10+
"vars.js.";
1011

1112
data.forEach(function(datum, i) {
1213
datum.base = base;
@@ -15,5 +16,5 @@ data.forEach(function(datum, i) {
1516
datum.previous = data[i - 1];
1617
datum.next = data[i + 1];
1718
var html = ejs.render(tpl, datum);
18-
fs.writeFileSync(__dirname + '/' + i + '-' + datum.source + '.html', html);
19+
fs.writeFileSync(__dirname + "/" + i + "-" + datum.source + ".html", html);
1920
});

examples/vars.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ module.exports = [
136136
source: "drag-from-outside",
137137
paragraphs: [
138138
"This demo shows what happens when an item is added from outside of the grid.",
139-
"Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with " +
140-
"it accordingly."
139+
"Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with " +
140+
"it accordingly."
141141
]
142142
}
143143
];

index-dev.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module.exports = require('./lib/ReactGridLayout').default;
2-
module.exports.utils = require('./lib/utils');
3-
module.exports.Responsive = require('./lib/ResponsiveReactGridLayout').default;
4-
module.exports.Responsive.utils = require('./lib/responsiveUtils');
5-
module.exports.WidthProvider = require('./lib/components/WidthProvider').default;
1+
module.exports = require("./lib/ReactGridLayout").default;
2+
module.exports.utils = require("./lib/utils");
3+
module.exports.Responsive = require("./lib/ResponsiveReactGridLayout").default;
4+
module.exports.Responsive.utils = require("./lib/responsiveUtils");
5+
module.exports.WidthProvider = require("./lib/components/WidthProvider").default;

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module.exports = require('./build/ReactGridLayout').default;
2-
module.exports.utils = require('./build/utils');
3-
module.exports.Responsive = require('./build/ResponsiveReactGridLayout').default;
4-
module.exports.Responsive.utils = require('./build/responsiveUtils');
5-
module.exports.WidthProvider = require('./build/components/WidthProvider').default;
1+
module.exports = require("./build/ReactGridLayout").default;
2+
module.exports.utils = require("./build/utils");
3+
module.exports.Responsive = require("./build/ResponsiveReactGridLayout").default;
4+
module.exports.Responsive.utils = require("./build/responsiveUtils");
5+
module.exports.WidthProvider = require("./build/components/WidthProvider").default;

index.js.flow

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// @flow
22

3-
import * as utils from './lib/utils';
4-
export { default } from './lib/ReactGridLayout';
5-
export { default as Responsive } from './lib/ResponsiveReactGridLayout';
6-
export { default as WidthProvider } from './lib/components/WidthProvider';
3+
import * as utils from "./lib/utils";
4+
export { default } from "./lib/ReactGridLayout";
5+
export { default as Responsive } from "./lib/ResponsiveReactGridLayout";
6+
export { default as WidthProvider } from "./lib/components/WidthProvider";
77

8-
export {
9-
utils
10-
};
8+
export { utils };

lib/utils.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ export function moveElement(
368368
// Short-circuit if nothing to do.
369369
if (l.y === y && l.x === x) return layout;
370370

371-
log(`Moving element ${l.i} to [${String(x)},${String(y)}] from [${l.x},${l.y}]`);
371+
log(
372+
`Moving element ${l.i} to [${String(x)},${String(y)}] from [${l.x},${l.y}]`
373+
);
372374
const oldX = l.x;
373375
const oldY = l.y;
374376

@@ -383,9 +385,11 @@ export function moveElement(
383385
// nearest collision.
384386
let sorted = sortLayoutItems(layout, compactType);
385387
const movingUp =
386-
compactType === "vertical" && typeof y === "number" ? oldY >= y
387-
: compactType === "horizontal" && typeof x === "number" ? oldX >= x
388-
: false;
388+
compactType === "vertical" && typeof y === "number"
389+
? oldY >= y
390+
: compactType === "horizontal" && typeof x === "number"
391+
? oldX >= x
392+
: false;
389393
if (movingUp) sorted = sorted.reverse();
390394
const collisions = getAllCollisions(sorted, l);
391395

test/examples/14-toolbox.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ class ShowcaseLayout extends React.Component {
9595
const compactType =
9696
oldCompactType === "horizontal"
9797
? "vertical"
98-
: oldCompactType === "vertical" ? null : "horizontal";
98+
: oldCompactType === "vertical"
99+
? null
100+
: "horizontal";
99101
this.setState({ compactType });
100102
};
101103

@@ -152,10 +154,8 @@ class ShowcaseLayout extends React.Component {
152154
return (
153155
<div>
154156
<div>
155-
Current Breakpoint: {this.state.currentBreakpoint} ({
156-
this.props.cols[this.state.currentBreakpoint]
157-
}{" "}
158-
columns)
157+
Current Breakpoint: {this.state.currentBreakpoint} (
158+
{this.props.cols[this.state.currentBreakpoint]} columns)
159159
</div>
160160
<div>
161161
Compaction type:{" "}

test/examples/15-drag-from-outside.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ class ShowcaseLayout extends React.Component {
5353
const compactType =
5454
oldCompactType === "horizontal"
5555
? "vertical"
56-
: oldCompactType === "vertical" ? null : "horizontal";
56+
: oldCompactType === "vertical"
57+
? null
58+
: "horizontal";
5759
this.setState({ compactType });
5860
};
5961

@@ -75,10 +77,8 @@ class ShowcaseLayout extends React.Component {
7577
return (
7678
<div>
7779
<div>
78-
Current Breakpoint: {this.state.currentBreakpoint} ({
79-
this.props.cols[this.state.currentBreakpoint]
80-
}{" "}
81-
columns)
80+
Current Breakpoint: {this.state.currentBreakpoint} (
81+
{this.props.cols[this.state.currentBreakpoint]} columns)
8282
</div>
8383
<div>
8484
Compaction type:{" "}

webpack-dev-server.config.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
const path = require('path');
1+
const path = require("path");
22
var webpack = require("webpack");
33

44
module.exports = {
5-
mode: 'development',
5+
mode: "development",
66
context: __dirname,
77
entry: "./test/dev-hook.jsx",
88
output: {
9-
path: '/',
9+
path: "/",
1010
filename: "bundle.js",
11-
sourceMapFilename: "[file].map",
11+
sourceMapFilename: "[file].map"
1212
},
1313
module: {
1414
rules: [
15-
{test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader',
15+
{
16+
test: /\.jsx?$/,
17+
exclude: /node_modules/,
18+
loader: "babel-loader",
1619
query: {
1720
cacheDirectory: true,
1821
plugins: [
19-
['react-transform',
22+
[
23+
"react-transform",
2024
{
2125
transforms: [
2226
{
23-
transform: 'react-transform-hmr',
24-
imports: ['react'],
25-
locals: ['module']
27+
transform: "react-transform-hmr",
28+
imports: ["react"],
29+
locals: ["module"]
2630
}
2731
]
2832
}
@@ -35,20 +39,20 @@ module.exports = {
3539
plugins: [
3640
new webpack.DefinePlugin({
3741
"process.env": {
38-
NODE_ENV: JSON.stringify('development')
42+
NODE_ENV: JSON.stringify("development")
3943
}
40-
}),
44+
})
4145
],
4246
devtool: "eval",
4347
devServer: {
44-
publicPath: '/',
48+
publicPath: "/",
4549
compress: true,
4650
port: 4002
4751
},
4852
resolve: {
4953
extensions: [".webpack.js", ".web.js", ".js", ".jsx"],
5054
alias: {
51-
'react-grid-layout': path.join(__dirname, '/index-dev.js')
55+
"react-grid-layout": path.join(__dirname, "/index-dev.js")
5256
}
5357
}
5458
};

webpack-examples.config.js

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,68 @@
1-
'use strict';
2-
var webpack = require('webpack');
3-
var fs = require('fs');
1+
"use strict";
2+
var webpack = require("webpack");
3+
var fs = require("fs");
44

55
// Builds example bundles
66
module.exports = {
7-
mode: 'development',
7+
mode: "development",
88
context: __dirname,
99
entry: {
10-
commons: ["lodash"],
10+
commons: ["lodash"]
1111
},
1212
optimization: {
1313
splitChunks: {
1414
cacheGroups: {
1515
commons: {
16-
name: 'commons',
17-
chunks: 'initial',
16+
name: "commons",
17+
chunks: "initial",
1818
minChunks: 2
1919
}
2020
}
2121
}
2222
},
2323
output: {
24-
path: __dirname + "/dist",
25-
filename: "[name].bundle.js",
26-
sourceMapFilename: "[file].map",
24+
path: __dirname + "/dist",
25+
filename: "[name].bundle.js",
26+
sourceMapFilename: "[file].map"
2727
},
2828
module: {
2929
rules: [
30-
{test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: {
31-
cacheDirectory: true,
32-
plugins: [
33-
'transform-react-inline-elements',
34-
'transform-react-constant-elements',
35-
]
36-
}}
30+
{
31+
test: /\.jsx?$/,
32+
exclude: /node_modules/,
33+
loader: "babel-loader",
34+
query: {
35+
cacheDirectory: true,
36+
plugins: [
37+
"transform-react-inline-elements",
38+
"transform-react-constant-elements"
39+
]
40+
}
41+
}
3742
]
3843
},
3944
plugins: [
4045
new webpack.DefinePlugin({
4146
"process.env": {
42-
NODE_ENV: JSON.stringify('production')
47+
NODE_ENV: JSON.stringify("production")
4348
}
44-
}),
49+
})
4550
],
4651
resolve: {
4752
extensions: [".webpack.js", ".web.js", ".js", ".jsx"],
48-
alias: {'react-grid-layout': __dirname + '/index-dev.js'}
53+
alias: { "react-grid-layout": __dirname + "/index-dev.js" }
4954
}
5055
};
5156

5257
// Load all entry points
53-
var files = fs.readdirSync(__dirname + '/test/examples').filter(function(element, index, array){
58+
var files = fs
59+
.readdirSync(__dirname + "/test/examples")
60+
.filter(function(element, index, array) {
5461
return element.match(/^.+\.jsx$/);
55-
});
62+
});
5663

57-
for(var idx in files){
58-
var file = files[idx];
59-
var module_name = file.replace(/\.jsx$/,'');
60-
module.exports.entry[module_name] = './test/examples/' + file;
64+
for (var idx in files) {
65+
var file = files[idx];
66+
var module_name = file.replace(/\.jsx$/, "");
67+
module.exports.entry[module_name] = "./test/examples/" + file;
6168
}

webpack.config.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var webpack = require("webpack");
22

33
// Builds bundle usable <script>. Includes RGL and all deps, excluding React.
44
module.exports = {
5-
mode: 'production',
5+
mode: "production",
66
optimization: {
77
minimize: true
88
},
@@ -18,24 +18,24 @@ module.exports = {
1818
},
1919
devtool: "source-map",
2020
externals: {
21-
"react": {
22-
"commonjs": "react",
23-
"commonjs2": "react",
24-
"amd": "react",
21+
react: {
22+
commonjs: "react",
23+
commonjs2: "react",
24+
amd: "react",
2525
// React dep should be available as window.React, not window.react
26-
"root": "React"
26+
root: "React"
2727
},
2828
"react-dom": {
29-
"commonjs": "react-dom",
30-
"commonjs2": "react-dom",
31-
"amd": "react-dom",
29+
commonjs: "react-dom",
30+
commonjs2: "react-dom",
31+
amd: "react-dom",
3232
// React dep should be available as window.React, not window.react
33-
"root": "ReactDOM"
33+
root: "ReactDOM"
3434
}
3535
},
3636
module: {
3737
rules: [
38-
{test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader"}
38+
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader" }
3939
]
4040
},
4141
plugins: [
@@ -44,7 +44,7 @@ module.exports = {
4444
NODE_ENV: JSON.stringify("production")
4545
}
4646
}),
47-
new webpack.optimize.ModuleConcatenationPlugin(),
47+
new webpack.optimize.ModuleConcatenationPlugin()
4848
],
4949
resolve: {
5050
extensions: [".js", ".jsx"]

0 commit comments

Comments
 (0)