Skip to content

Commit

Permalink
chore(lint): apply prettier on existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed Sep 27, 2019
1 parent 4af61ff commit 77547d6
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 93 deletions.
19 changes: 10 additions & 9 deletions examples/generate.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';
var fs = require('fs');
var ejs = require('ejs');
var data = require('./vars');
var tpl = fs.readFileSync(__dirname + '/template.ejs').toString();
"use strict";
var fs = require("fs");
var ejs = require("ejs");
var data = require("./vars");
var tpl = fs.readFileSync(__dirname + "/template.ejs").toString();

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

data.forEach(function(datum, i) {
datum.base = base;
Expand All @@ -15,5 +16,5 @@ data.forEach(function(datum, i) {
datum.previous = data[i - 1];
datum.next = data[i + 1];
var html = ejs.render(tpl, datum);
fs.writeFileSync(__dirname + '/' + i + '-' + datum.source + '.html', html);
fs.writeFileSync(__dirname + "/" + i + "-" + datum.source + ".html", html);
});
4 changes: 2 additions & 2 deletions examples/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ module.exports = [
source: "drag-from-outside",
paragraphs: [
"This demo shows what happens when an item is added from outside of the grid.",
"Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with " +
"it accordingly."
"Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with " +
"it accordingly."
]
}
];
10 changes: 5 additions & 5 deletions index-dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = require('./lib/ReactGridLayout').default;
module.exports.utils = require('./lib/utils');
module.exports.Responsive = require('./lib/ResponsiveReactGridLayout').default;
module.exports.Responsive.utils = require('./lib/responsiveUtils');
module.exports.WidthProvider = require('./lib/components/WidthProvider').default;
module.exports = require("./lib/ReactGridLayout").default;
module.exports.utils = require("./lib/utils");
module.exports.Responsive = require("./lib/ResponsiveReactGridLayout").default;
module.exports.Responsive.utils = require("./lib/responsiveUtils");
module.exports.WidthProvider = require("./lib/components/WidthProvider").default;
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = require('./build/ReactGridLayout').default;
module.exports.utils = require('./build/utils');
module.exports.Responsive = require('./build/ResponsiveReactGridLayout').default;
module.exports.Responsive.utils = require('./build/responsiveUtils');
module.exports.WidthProvider = require('./build/components/WidthProvider').default;
module.exports = require("./build/ReactGridLayout").default;
module.exports.utils = require("./build/utils");
module.exports.Responsive = require("./build/ResponsiveReactGridLayout").default;
module.exports.Responsive.utils = require("./build/responsiveUtils");
module.exports.WidthProvider = require("./build/components/WidthProvider").default;
12 changes: 5 additions & 7 deletions index.js.flow
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// @flow

import * as utils from './lib/utils';
export { default } from './lib/ReactGridLayout';
export { default as Responsive } from './lib/ResponsiveReactGridLayout';
export { default as WidthProvider } from './lib/components/WidthProvider';
import * as utils from "./lib/utils";
export { default } from "./lib/ReactGridLayout";
export { default as Responsive } from "./lib/ResponsiveReactGridLayout";
export { default as WidthProvider } from "./lib/components/WidthProvider";

export {
utils
};
export { utils };
12 changes: 8 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ export function moveElement(
// Short-circuit if nothing to do.
if (l.y === y && l.x === x) return layout;

log(`Moving element ${l.i} to [${String(x)},${String(y)}] from [${l.x},${l.y}]`);
log(
`Moving element ${l.i} to [${String(x)},${String(y)}] from [${l.x},${l.y}]`
);
const oldX = l.x;
const oldY = l.y;

Expand All @@ -383,9 +385,11 @@ export function moveElement(
// nearest collision.
let sorted = sortLayoutItems(layout, compactType);
const movingUp =
compactType === "vertical" && typeof y === "number" ? oldY >= y
: compactType === "horizontal" && typeof x === "number" ? oldX >= x
: false;
compactType === "vertical" && typeof y === "number"
? oldY >= y
: compactType === "horizontal" && typeof x === "number"
? oldX >= x
: false;
if (movingUp) sorted = sorted.reverse();
const collisions = getAllCollisions(sorted, l);

Expand Down
10 changes: 5 additions & 5 deletions test/examples/14-toolbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class ShowcaseLayout extends React.Component {
const compactType =
oldCompactType === "horizontal"
? "vertical"
: oldCompactType === "vertical" ? null : "horizontal";
: oldCompactType === "vertical"
? null
: "horizontal";
this.setState({ compactType });
};

Expand Down Expand Up @@ -152,10 +154,8 @@ class ShowcaseLayout extends React.Component {
return (
<div>
<div>
Current Breakpoint: {this.state.currentBreakpoint} ({
this.props.cols[this.state.currentBreakpoint]
}{" "}
columns)
Current Breakpoint: {this.state.currentBreakpoint} (
{this.props.cols[this.state.currentBreakpoint]} columns)
</div>
<div>
Compaction type:{" "}
Expand Down
10 changes: 5 additions & 5 deletions test/examples/15-drag-from-outside.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class ShowcaseLayout extends React.Component {
const compactType =
oldCompactType === "horizontal"
? "vertical"
: oldCompactType === "vertical" ? null : "horizontal";
: oldCompactType === "vertical"
? null
: "horizontal";
this.setState({ compactType });
};

Expand All @@ -75,10 +77,8 @@ class ShowcaseLayout extends React.Component {
return (
<div>
<div>
Current Breakpoint: {this.state.currentBreakpoint} ({
this.props.cols[this.state.currentBreakpoint]
}{" "}
columns)
Current Breakpoint: {this.state.currentBreakpoint} (
{this.props.cols[this.state.currentBreakpoint]} columns)
</div>
<div>
Compaction type:{" "}
Expand Down
30 changes: 17 additions & 13 deletions webpack-dev-server.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
const path = require('path');
const path = require("path");
var webpack = require("webpack");

module.exports = {
mode: 'development',
mode: "development",
context: __dirname,
entry: "./test/dev-hook.jsx",
output: {
path: '/',
path: "/",
filename: "bundle.js",
sourceMapFilename: "[file].map",
sourceMapFilename: "[file].map"
},
module: {
rules: [
{test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader',
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
cacheDirectory: true,
plugins: [
['react-transform',
[
"react-transform",
{
transforms: [
{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
transform: "react-transform-hmr",
imports: ["react"],
locals: ["module"]
}
]
}
Expand All @@ -35,20 +39,20 @@ module.exports = {
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify('development')
NODE_ENV: JSON.stringify("development")
}
}),
})
],
devtool: "eval",
devServer: {
publicPath: '/',
publicPath: "/",
compress: true,
port: 4002
},
resolve: {
extensions: [".webpack.js", ".web.js", ".js", ".jsx"],
alias: {
'react-grid-layout': path.join(__dirname, '/index-dev.js')
"react-grid-layout": path.join(__dirname, "/index-dev.js")
}
}
};
59 changes: 33 additions & 26 deletions webpack-examples.config.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,68 @@
'use strict';
var webpack = require('webpack');
var fs = require('fs');
"use strict";
var webpack = require("webpack");
var fs = require("fs");

// Builds example bundles
module.exports = {
mode: 'development',
mode: "development",
context: __dirname,
entry: {
commons: ["lodash"],
commons: ["lodash"]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
name: "commons",
chunks: "initial",
minChunks: 2
}
}
}
},
output: {
path: __dirname + "/dist",
filename: "[name].bundle.js",
sourceMapFilename: "[file].map",
path: __dirname + "/dist",
filename: "[name].bundle.js",
sourceMapFilename: "[file].map"
},
module: {
rules: [
{test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: {
cacheDirectory: true,
plugins: [
'transform-react-inline-elements',
'transform-react-constant-elements',
]
}}
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
cacheDirectory: true,
plugins: [
"transform-react-inline-elements",
"transform-react-constant-elements"
]
}
}
]
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify('production')
NODE_ENV: JSON.stringify("production")
}
}),
})
],
resolve: {
extensions: [".webpack.js", ".web.js", ".js", ".jsx"],
alias: {'react-grid-layout': __dirname + '/index-dev.js'}
alias: { "react-grid-layout": __dirname + "/index-dev.js" }
}
};

// Load all entry points
var files = fs.readdirSync(__dirname + '/test/examples').filter(function(element, index, array){
var files = fs
.readdirSync(__dirname + "/test/examples")
.filter(function(element, index, array) {
return element.match(/^.+\.jsx$/);
});
});

for(var idx in files){
var file = files[idx];
var module_name = file.replace(/\.jsx$/,'');
module.exports.entry[module_name] = './test/examples/' + file;
for (var idx in files) {
var file = files[idx];
var module_name = file.replace(/\.jsx$/, "");
module.exports.entry[module_name] = "./test/examples/" + file;
}
24 changes: 12 additions & 12 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var webpack = require("webpack");

// Builds bundle usable <script>. Includes RGL and all deps, excluding React.
module.exports = {
mode: 'production',
mode: "production",
optimization: {
minimize: true
},
Expand All @@ -18,24 +18,24 @@ module.exports = {
},
devtool: "source-map",
externals: {
"react": {
"commonjs": "react",
"commonjs2": "react",
"amd": "react",
react: {
commonjs: "react",
commonjs2: "react",
amd: "react",
// React dep should be available as window.React, not window.react
"root": "React"
root: "React"
},
"react-dom": {
"commonjs": "react-dom",
"commonjs2": "react-dom",
"amd": "react-dom",
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "react-dom",
// React dep should be available as window.React, not window.react
"root": "ReactDOM"
root: "ReactDOM"
}
},
module: {
rules: [
{test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader"}
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
plugins: [
Expand All @@ -44,7 +44,7 @@ module.exports = {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.ModuleConcatenationPlugin()
],
resolve: {
extensions: [".js", ".jsx"]
Expand Down

0 comments on commit 77547d6

Please sign in to comment.