Skip to content

Commit f8d4dcb

Browse files
committed
Reformat code using prettier and rules from preact codebase
1 parent 0d9d7d2 commit f8d4dcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+12572
-12568
lines changed

jest-puppeteer.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { port } = require("./scripts/serve");
1+
const { port } = require('./scripts/serve');
22

33
module.exports = {
44
launch: {
5-
devtools: process.env.PPTR_DEBUG === "true"
5+
devtools: process.env.PPTR_DEBUG === 'true'
66
},
77
server: {
8-
command: "node ./scripts serve",
8+
command: 'node ./scripts serve',
99
port,
1010
launchTimeout: 10000
1111
}

package-lock.json

Lines changed: 12174 additions & 12168 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,71 @@
11
{
2-
"name": "preact-integrations",
3-
"version": "0.0.1",
4-
"description": "A collection of sample apps demonstrating Preact's compatibility with various 3rd party libraries",
5-
"main": "index.js",
6-
"scripts": {
7-
"build": "node ./scripts build",
8-
"dev": "node ./scripts dev",
9-
"test": "jest",
10-
"test:debug": "cross-env PPTR_DEBUG=true jest",
11-
"serve": "node ./scripts serve"
12-
},
13-
"keywords": [
14-
"preact",
15-
"preact-compat"
16-
],
17-
"author": "",
18-
"license": "MIT",
19-
"dependencies": {
20-
"classcat": "^4.0.2",
21-
"classnames": "^2.2.6",
22-
"preact": "^10.0.0-rc.3",
23-
"preact-router": "^3.0.1",
24-
"react-redux": "^7.1.1",
25-
"redux": "^4.0.4"
26-
},
27-
"devDependencies": {
28-
"@babel/core": "^7.6.0",
29-
"@babel/plugin-proposal-class-properties": "^7.5.5",
30-
"@babel/preset-env": "^7.6.0",
31-
"@babel/preset-react": "^7.0.0",
32-
"@types/jasmine": "^3.4.0",
33-
"@types/jest": "^24.0.18",
34-
"@types/jest-environment-puppeteer": "^4.3.1",
35-
"autoprefixer": "^9.6.1",
36-
"babel-loader": "^8.0.6",
37-
"clean-webpack-plugin": "^3.0.0",
38-
"cross-env": "^6.0.3",
39-
"css-loader": "^3.2.0",
40-
"file-loader": "^4.2.0",
41-
"html-webpack-plugin": "^3.2.0",
42-
"jest": "^24.9.0",
43-
"jest-puppeteer": "^4.3.0",
44-
"mini-css-extract-plugin": "^0.8.0",
45-
"node-sass": "^4.12.0",
46-
"optimize-css-assets-webpack-plugin": "^5.0.3",
47-
"postcss-loader": "^3.0.0",
48-
"puppeteer": "^1.20.0",
49-
"sade": "^1.6.1",
50-
"sass-loader": "^8.0.0",
51-
"serve": "^11.2.0",
52-
"terser-webpack-plugin": "^2.1.0",
53-
"webpack": "^4.40.0",
54-
"webpack-bundle-analyzer": "^3.5.0",
55-
"webpack-cli": "^3.3.8"
56-
},
57-
"jest": {
58-
"rootDir": "tests",
59-
"preset": "jest-puppeteer",
60-
"transform": {
61-
"^.+\\.[t|j]sx?$": "<rootDir>/babelTransformer.js"
62-
}
63-
}
2+
"name": "preact-integrations",
3+
"version": "0.0.1",
4+
"description": "A collection of sample apps demonstrating Preact's compatibility with various 3rd party libraries",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "node ./scripts build",
8+
"dev": "node ./scripts dev",
9+
"test": "jest",
10+
"test:debug": "cross-env PPTR_DEBUG=true jest",
11+
"serve": "node ./scripts serve"
12+
},
13+
"keywords": [
14+
"preact",
15+
"preact-compat"
16+
],
17+
"author": "",
18+
"license": "MIT",
19+
"dependencies": {
20+
"classcat": "^4.0.2",
21+
"classnames": "^2.2.6",
22+
"preact": "^10.0.0-rc.3",
23+
"preact-router": "^3.0.1",
24+
"react-redux": "^7.1.1",
25+
"redux": "^4.0.4"
26+
},
27+
"devDependencies": {
28+
"@babel/core": "^7.6.0",
29+
"@babel/plugin-proposal-class-properties": "^7.5.5",
30+
"@babel/preset-env": "^7.6.0",
31+
"@babel/preset-react": "^7.0.0",
32+
"@types/jasmine": "^3.4.0",
33+
"@types/jest": "^24.0.18",
34+
"@types/jest-environment-puppeteer": "^4.3.1",
35+
"autoprefixer": "^9.6.1",
36+
"babel-loader": "^8.0.6",
37+
"clean-webpack-plugin": "^3.0.0",
38+
"cross-env": "^6.0.3",
39+
"css-loader": "^3.2.0",
40+
"file-loader": "^4.2.0",
41+
"html-webpack-plugin": "^3.2.0",
42+
"jest": "^24.9.0",
43+
"jest-puppeteer": "^4.3.0",
44+
"mini-css-extract-plugin": "^0.8.0",
45+
"node-sass": "^4.12.0",
46+
"optimize-css-assets-webpack-plugin": "^5.0.3",
47+
"postcss-loader": "^3.0.0",
48+
"prettier": "^1.18.2",
49+
"puppeteer": "^1.20.0",
50+
"sade": "^1.6.1",
51+
"sass-loader": "^8.0.0",
52+
"serve": "^11.2.0",
53+
"terser-webpack-plugin": "^2.1.0",
54+
"webpack": "^4.40.0",
55+
"webpack-bundle-analyzer": "^3.5.0",
56+
"webpack-cli": "^3.3.8"
57+
},
58+
"prettier": {
59+
"singleQuote": true,
60+
"trailingComma": "none",
61+
"useTabs": true,
62+
"tabWidth": 2
63+
},
64+
"jest": {
65+
"rootDir": "tests",
66+
"preset": "jest-puppeteer",
67+
"transform": {
68+
"^.+\\.[t|j]sx?$": "<rootDir>/babelTransformer.js"
69+
}
70+
}
6471
}

scripts/build.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { runNode } = require("./lib/node");
1+
const { runNode } = require('./lib/node');
22
const {
33
repoRoot,
44
webpackConfigPath,
55
srcPath,
66
listDirs,
77
exists
8-
} = require("./util");
8+
} = require('./util');
99

1010
/**
1111
* @param {string} configPath
@@ -14,12 +14,12 @@ const {
1414
function runWebpack(configPath, options) {
1515
const extraArgs = [];
1616
if (options.watch) {
17-
extraArgs.push("--watch");
17+
extraArgs.push('--watch');
1818
}
1919

2020
return runNode(
21-
repoRoot("./node_modules/webpack/bin/webpack.js"),
22-
["--config", configPath, "--mode", options.mode, ...extraArgs],
21+
repoRoot('./node_modules/webpack/bin/webpack.js'),
22+
['--config', configPath, '--mode', options.mode, ...extraArgs],
2323
options
2424
);
2525
}
@@ -66,7 +66,7 @@ async function getAvailableLibraries(bundles) {
6666
const defaultBuildOptions = Object.freeze({
6767
debug: false,
6868
watch: false,
69-
mode: "production",
69+
mode: 'production',
7070
cwd: repoRoot()
7171
});
7272

scripts/dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { getWebpackTasks } = require("./build");
2-
const { runDevServer } = require("./serve");
1+
const { getWebpackTasks } = require('./build');
2+
const { runDevServer } = require('./serve');
33

44
/**
55
* @param {string[]} buildRequests

scripts/index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const { readFile } = require("fs").promises;
2-
const sade = require("sade");
3-
const { toCompletion } = require("./lib/node");
4-
const { repoRoot } = require("./util");
5-
const { build } = require("./build");
6-
const { dev } = require("./dev");
7-
const { runDevServer } = require("./serve");
1+
const { readFile } = require('fs').promises;
2+
const sade = require('sade');
3+
const { toCompletion } = require('./lib/node');
4+
const { repoRoot } = require('./util');
5+
const { build } = require('./build');
6+
const { dev } = require('./dev');
7+
const { runDevServer } = require('./serve');
88

99
// TODO: Uncomment if needed
1010
// https://github.com/mysticatea/npm-run-all/issues/105
@@ -14,15 +14,15 @@ const { runDevServer } = require("./serve");
1414
// process.stderr.setMaxListeners(0);
1515

1616
/** @type {Array<import('./build').BuildMode>} */
17-
const modes = ["production", "development"];
17+
const modes = ['production', 'development'];
1818

1919
/**
2020
* @typedef {{ _: string[]; debug: boolean; mode: import('./build').BuildMode; watch: boolean; }} CmdLineOptions
2121
* @param {(libraries: string[], options: any) => Promise<any>} cmd
2222
* @returns {(lib1: string, opts: CmdLineOptions) => Promise<any>}
2323
*/
2424
const run = cmd => async (lib1, opts) => {
25-
if ("mode" in opts && modes.indexOf(opts.mode) == -1) {
25+
if ('mode' in opts && modes.indexOf(opts.mode) == -1) {
2626
throw new Error(`Invalid mode given: "${opts.mode}"`);
2727
}
2828

@@ -34,32 +34,32 @@ const run = cmd => async (lib1, opts) => {
3434
};
3535

3636
async function main() {
37-
const version = JSON.parse(await readFile(repoRoot("package.json"), "utf8"))
37+
const version = JSON.parse(await readFile(repoRoot('package.json'), 'utf8'))
3838
.version;
3939

40-
const prog = sade("scripts");
41-
prog.version(version).option("--debug", "Print out debugging info", false);
40+
const prog = sade('scripts');
41+
prog.version(version).option('--debug', 'Print out debugging info', false);
4242

4343
prog
44-
.command("build [libraries]")
44+
.command('build [libraries]')
4545
.describe(
46-
"Build the bundles that include the libraries passed in (defaults to building all)"
46+
'Build the bundles that include the libraries passed in (defaults to building all)'
4747
)
48-
.option("--mode, -m", "'production' or 'development'", "production")
49-
.option("--watch, -w", "Watch source files and rebuild on change", false)
48+
.option('--mode, -m', "'production' or 'development'", 'production')
49+
.option('--watch, -w', 'Watch source files and rebuild on change', false)
5050
.action(run(build));
5151

5252
prog
53-
.command("dev [libraries]")
54-
.option("--mode, -m", "'production' or 'development'", "development")
53+
.command('dev [libraries]')
54+
.option('--mode, -m', "'production' or 'development'", 'development')
5555
.describe(
56-
"Watch src files of the passed in libraries (defaults to all), build them on change, and run a web server to serve them"
56+
'Watch src files of the passed in libraries (defaults to all), build them on change, and run a web server to serve them'
5757
)
5858
.action(run(dev));
5959

6060
prog
61-
.command("serve")
62-
.describe("Run a development web server")
61+
.command('serve')
62+
.describe('Run a development web server')
6363
.action(() => toCompletion(runDevServer()));
6464

6565
return prog.parse(process.argv);

scripts/lib/node.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { spawn } = require("child_process");
2-
const { repoRoot } = require("../../scripts/util");
1+
const { spawn } = require('child_process');
2+
const { repoRoot } = require('../../scripts/util');
33

44
/**
55
* @typedef {{ debug?: boolean; cwd?: string; }} NodeOptions
@@ -10,10 +10,10 @@ const { repoRoot } = require("../../scripts/util");
1010
function runNode(path, args, options = {}) {
1111
args.unshift(path);
1212
if (options.debug) {
13-
console.log("$", process.execPath, args.join(" "));
13+
console.log('$', process.execPath, args.join(' '));
1414
}
1515
return spawn(process.execPath, args, {
16-
stdio: "inherit",
16+
stdio: 'inherit',
1717
cwd: options.cwd || repoRoot()
1818
});
1919
}
@@ -24,17 +24,16 @@ function runNode(path, args, options = {}) {
2424
*/
2525
function toCompletion(childProcess) {
2626
return new Promise((resolve, reject) => {
27-
childProcess.on("error", reject);
28-
childProcess.on("exit", (code, signal) => {
27+
childProcess.on('error', reject);
28+
childProcess.on('exit', (code, signal) => {
2929
if (code > 0) {
3030
const error = new Error(
3131
`Child process exited with non-success code: ${code}`
3232
);
3333
error.signal = signal;
3434

3535
reject(error);
36-
}
37-
else {
36+
} else {
3837
resolve();
3938
}
4039
});

scripts/lib/request.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const http = require("http");
1+
const http = require('http');
22

33
function get(url) {
44
return new Promise((resolve, reject) => {
@@ -14,18 +14,18 @@ function get(url) {
1414
reject(error);
1515
}
1616

17-
res.setEncoding("utf8");
17+
res.setEncoding('utf8');
1818

19-
let rawData = "";
20-
res.on("data", chunk => {
19+
let rawData = '';
20+
res.on('data', chunk => {
2121
rawData += chunk;
2222
});
2323

24-
res.on("end", () => {
24+
res.on('end', () => {
2525
resolve(rawData);
2626
});
2727
})
28-
.on("error", reject);
28+
.on('error', reject);
2929
});
3030
}
3131

scripts/serve.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { repoRoot } = require("./util");
2-
const { get } = require("./lib/request");
3-
const { runNode, toCompletion } = require("./lib/node");
1+
const { repoRoot } = require('./util');
2+
const { get } = require('./lib/request');
3+
const { runNode, toCompletion } = require('./lib/node');
44

55
const port = 5000;
66
const devHost = `http://localhost:${port}`;
@@ -10,8 +10,8 @@ const devHost = `http://localhost:${port}`;
1010
*/
1111
function runDevServer(options) {
1212
return runNode(
13-
repoRoot("node_modules/serve/bin/serve.js"),
14-
[repoRoot(), "-l", port.toString()],
13+
repoRoot('node_modules/serve/bin/serve.js'),
14+
[repoRoot(), '-l', port.toString()],
1515
options
1616
);
1717
}

scripts/util.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const path = require("path");
2-
const { promisify } = require("util");
3-
const { exists: existsAsync } = require("fs");
4-
const { readdir } = require("fs").promises;
1+
const path = require('path');
2+
const { promisify } = require('util');
3+
const { exists: existsAsync } = require('fs');
4+
const { readdir } = require('fs').promises;
55

6-
const outputFolder = "preact-integrations";
6+
const outputFolder = 'preact-integrations';
77
const outputPath = (...args) => repoRoot(outputFolder, ...args);
88

9-
const repoRoot = (...args) => path.join(__dirname, "..", ...args);
10-
const srcPath = (...args) => repoRoot("src", ...args);
9+
const repoRoot = (...args) => path.join(__dirname, '..', ...args);
10+
const srcPath = (...args) => repoRoot('src', ...args);
1111
const webpackConfigPath = bundleName =>
12-
srcPath(bundleName, "webpack.config.js");
12+
srcPath(bundleName, 'webpack.config.js');
1313

1414
const exists = promisify(existsAsync);
1515

src/direct/DirectIntro.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, Fragment } from "preact";
1+
import { createElement, Fragment } from 'preact';
22

33
export function DirectIntro() {
44
return (

0 commit comments

Comments
 (0)