Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 57f65f1

Browse files
authored
style: codeformat with Prettier (#532)
* chore: add prettier * style: format with prettier
1 parent c679570 commit 57f65f1

File tree

96 files changed

+2430
-2363
lines changed

Some content is hidden

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

96 files changed

+2430
-2363
lines changed

.eslintrc.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sourceType": "module"
1919
},
2020
"rules": {
21-
"arrow-parens": [2, "as-needed"],
21+
"prettier/prettier": "error",
2222
"import/no-extraneous-dependencies": [
2323
2,
2424
{
@@ -56,5 +56,6 @@
5656
"max-classes-per-file": 0,
5757
"prefer-object-spread": 0
5858
},
59-
"extends": ["airbnb"]
59+
"extends": ["airbnb", "prettier", "prettier/react"],
60+
"plugins": ["prettier"]
6061
}

aw.config.js

+42-39
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,76 @@ const cmd = process.argv.slice(2).shift();
22

33
module.exports = {
44
coverage: true,
5-
url: 'http://localhost:9677/examples/index.html',
5+
url: "http://localhost:9677/examples/index.html",
66
mocks: [
7-
['**/*.{scss,less,css,html}'],
8-
['./foobar-virtual.html', '"<div>hello world</div>"'],
9-
['mocked-special', './examples/react/test/internal-aw-tests/button-mock.js'],
7+
["**/*.{scss,less,css,html}"],
8+
["./foobar-virtual.html", '"<div>hello world</div>"'],
9+
[
10+
"mocked-special",
11+
"./examples/react/test/internal-aw-tests/button-mock.js",
12+
],
1013
],
1114
nyc: {
1215
exclude: [
13-
'**/*.html',
14-
'**/*.spec.*',
15-
'**/cli/src/index.js',
16-
'**/transform/src/index.js',
17-
'**/browser-shim.js',
18-
'**/commands/aw',
19-
'**/examples/main.js',
20-
'**/examples/react/src/full-match.js',
16+
"**/*.html",
17+
"**/*.spec.*",
18+
"**/cli/src/index.js",
19+
"**/transform/src/index.js",
20+
"**/browser-shim.js",
21+
"**/commands/aw",
22+
"**/examples/main.js",
23+
"**/examples/react/src/full-match.js",
2124
],
2225
},
2326
mocha: {
24-
reporter: 'spec',
27+
reporter: "spec",
2528
},
2629
// Protractor mochaOpts
2730
mochaOpts: {
2831
reporterOptions: {
29-
name: '@after-work.js',
30-
version: 'next',
32+
name: "@after-work.js",
33+
version: "next",
3134
},
3235
},
33-
'transform.typescript.babelOptions': {
36+
"transform.typescript.babelOptions": {
3437
presets: [
3538
[
36-
'@babel/preset-env',
39+
"@babel/preset-env",
3740
{
3841
targets: {
39-
browsers: ['last 2 versions', 'safari >= 7'],
40-
node: 'current',
42+
browsers: ["last 2 versions", "safari >= 7"],
43+
node: "current",
4144
},
42-
modules: cmd !== 'chrome' ? 'commonjs' : false,
45+
modules: cmd !== "chrome" ? "commonjs" : false,
4346
},
4447
],
4548
],
4649
},
47-
'filter.node.packages': [
48-
'!@after-work.js/example-*(protractor|puppeteer|webpack-dev-server)',
49-
'!@after-work.js/example-chrome-*',
50+
"filter.node.packages": [
51+
"!@after-work.js/example-*(protractor|puppeteer|webpack-dev-server)",
52+
"!@after-work.js/example-chrome-*",
5053
],
51-
'filter.node.files': [
52-
'!**/commands/protractor/src/config.js',
53-
'!**/examples/chrome-*/**',
54-
'!**/examples/protractor/**',
55-
'!**/examples/puppeteer/**',
56-
'!**/examples/webpack-dev-server/**',
54+
"filter.node.files": [
55+
"!**/commands/protractor/src/config.js",
56+
"!**/examples/chrome-*/**",
57+
"!**/examples/protractor/**",
58+
"!**/examples/puppeteer/**",
59+
"!**/examples/webpack-dev-server/**",
5760
],
58-
'filter.chrome.packages': ['@after-work.js/example-chrome-*'],
59-
'filter.chrome.files': [
60-
'**/examples/chrome-*/**',
61-
'!**/examples/chrome-esm/**',
61+
"filter.chrome.packages": ["@after-work.js/example-chrome-*"],
62+
"filter.chrome.files": [
63+
"**/examples/chrome-*/**",
64+
"!**/examples/chrome-esm/**",
6265
],
63-
'filter.puppeteer.packages': ['@after-work.js/example-puppeteer'],
64-
'filter.puppeteer.files': ['**/examples/puppeteer/**'],
65-
'filter.protractor.files': ['**/examples/protractor/**'],
66-
artifactsPath: 'test/__artifacts__',
66+
"filter.puppeteer.packages": ["@after-work.js/example-puppeteer"],
67+
"filter.puppeteer.files": ["**/examples/puppeteer/**"],
68+
"filter.protractor.files": ["**/examples/protractor/**"],
69+
artifactsPath: "test/__artifacts__",
6770
http: {
6871
port: 9677,
6972
},
70-
specs: ['./examples/protractor/test/hello.spec.js'],
73+
specs: ["./examples/protractor/test/hello.spec.js"],
7174
transform: {
72-
exclude: ['**/chrome-esm/**'],
75+
exclude: ["**/chrome-esm/**"],
7376
},
7477
};

babel.config.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@ module.exports = (api) => {
22
api.cache(true);
33
const cmd = process.argv.slice(2).shift();
44
switch (cmd) {
5-
case 'chrome':
5+
case "chrome":
66
return {
77
presets: [
88
[
9-
'@babel/preset-env',
9+
"@babel/preset-env",
1010
{
1111
targets: {
12-
browsers: ['last 2 versions', 'safari >= 7'],
12+
browsers: ["last 2 versions", "safari >= 7"],
1313
},
14-
modules: 'amd',
14+
modules: "amd",
1515
},
1616
],
1717
],
18-
ignore: ['**/ignore.js'],
18+
ignore: ["**/ignore.js"],
1919
};
2020
default:
2121
return {
2222
presets: [
2323
[
24-
'@babel/preset-env',
24+
"@babel/preset-env",
2525
{
26-
targets: { node: 'current' },
26+
targets: { node: "current" },
2727
},
2828
],
2929
],
30-
plugins: ['@babel/plugin-transform-react-jsx'],
30+
plugins: ["@babel/plugin-transform-react-jsx"],
3131
};
3232
}
3333
};

commands/aw/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env node
2-
require('@after-work.js/cli');
2+
require("@after-work.js/cli");

commands/cdp/src/browser-shim.js

+26-22
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
const origRun = m.run.bind(m);
55

66
m.run = () => {
7-
win.awMediator.emit('started', m.suite.suites.length);
7+
win.awMediator.emit("started", m.suite.suites.length);
88
m.runner = origRun(() => {
9-
setTimeout(() => win.awMediator.emit('ended', m.runner.stats), 0);
9+
setTimeout(() => win.awMediator.emit("ended", m.runner.stats), 0);
1010
});
1111
return m.runner;
1212
};
1313
}
14-
Object.defineProperty(win, 'mocha', {
14+
Object.defineProperty(win, "mocha", {
1515
get() {
1616
return undefined;
1717
},
@@ -24,22 +24,22 @@
2424
configurable: true,
2525
});
2626

27-
Object.defineProperty(win, 'Mocha', {
27+
Object.defineProperty(win, "Mocha", {
2828
get() {
2929
return undefined;
3030
},
3131
set(m) {
3232
delete win.Mocha;
3333
win.Mocha = m;
3434

35-
m.process.nextTick = cb => cb();
35+
m.process.nextTick = (cb) => cb();
3636
m.process.stdout._write = (chunks, encoding, cb) => {
3737
const output = chunks.toString ? chunks.toString() : chunks;
3838
console.info(output);
3939
m.process.nextTick(cb);
4040
};
4141

42-
win.awMediator.emit('width');
42+
win.awMediator.emit("width");
4343
},
4444
configurable: true,
4545
});
@@ -52,37 +52,41 @@
5252
const origLog = console.log;
5353

5454
console.format = function (f) {
55-
if (typeof f !== 'string') {
56-
return Array.prototype.map.call(arguments, arg => {
57-
try {
58-
return JSON.stringify(arg);
59-
} catch (_) {
60-
return '[Circular]';
61-
}
62-
}).join(' ');
55+
if (typeof f !== "string") {
56+
return Array.prototype.map
57+
.call(arguments, (arg) => {
58+
try {
59+
return JSON.stringify(arg);
60+
} catch (_) {
61+
return "[Circular]";
62+
}
63+
})
64+
.join(" ");
6365
}
6466
let i = 1,
6567
args = arguments,
6668
len = args.length,
67-
str = String(f).replace(/%[sdj%]/g, x => {
68-
if (x === '%%') return '%';
69+
str = String(f).replace(/%[sdj%]/g, (x) => {
70+
if (x === "%%") return "%";
6971
if (i >= len) return x;
7072
switch (x) {
71-
case '%s': return String(args[i++]);
72-
case '%d': return Number(args[i++]);
73-
case '%j':
73+
case "%s":
74+
return String(args[i++]);
75+
case "%d":
76+
return Number(args[i++]);
77+
case "%j":
7478
try {
7579
return JSON.stringify(args[i++]);
7680
} catch (_) {
77-
return '[Circular]';
81+
return "[Circular]";
7882
}
7983
default:
8084
return x;
8185
}
8286
}),
8387
x;
8488
for (x = args[i]; i < len; x = args[++i]) {
85-
if (x === null || typeof x !== 'object') {
89+
if (x === null || typeof x !== "object") {
8690
str += ` ${x}`;
8791
} else {
8892
str += ` ${JSON.stringify(x)}`;
@@ -99,4 +103,4 @@
99103
origLog.call(console, console.format(...arguments));
100104
};
101105
}
102-
}(window));
106+
})(window);

commands/cdp/src/connect.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint object-curly-newline: 0, max-len: 0 */
2-
const fs = require('fs');
3-
const path = require('path');
4-
const CDP = require('chrome-remote-interface');
2+
const fs = require("fs");
3+
const path = require("path");
4+
const CDP = require("chrome-remote-interface");
55

66
const injectMediator = `
77
(function (win) {
@@ -17,7 +17,7 @@ const injectMediator = `
1717
`;
1818

1919
function getContent(filePath) {
20-
return fs.readFileSync(filePath, 'utf-8');
20+
return fs.readFileSync(filePath, "utf-8");
2121
}
2222

2323
module.exports = async function connect(argv, files, presetEnv, debugging) {
@@ -34,7 +34,7 @@ module.exports = async function connect(argv, files, presetEnv, debugging) {
3434
})}`;
3535
const injectAwFiles = `window.awFiles = ${JSON.stringify(files)}`;
3636
const injectAwDevtools = `window.awDevtools = ${JSON.stringify(
37-
argv.chrome.devtools,
37+
argv.chrome.devtools
3838
)}`;
3939
const injectAwDebugging = `window.awDebugging = ${JSON.stringify(debugging)}`;
4040

@@ -47,13 +47,13 @@ module.exports = async function connect(argv, files, presetEnv, debugging) {
4747
Console.enable(),
4848
]);
4949
const sourceMapSupport = `${path.dirname(
50-
require.resolve('source-map-support'),
50+
require.resolve("source-map-support")
5151
)}/browser-source-map-support.js`;
5252
await Page.addScriptToEvaluateOnNewDocument({
5353
source: `${getContent(sourceMapSupport)};`,
5454
});
5555
await Page.addScriptToEvaluateOnNewDocument({
56-
source: 'sourceMapSupport.install();',
56+
source: "sourceMapSupport.install();",
5757
});
5858
await Page.addScriptToEvaluateOnNewDocument({ source: injectMediator });
5959
await Page.addScriptToEvaluateOnNewDocument({
@@ -67,23 +67,23 @@ module.exports = async function connect(argv, files, presetEnv, debugging) {
6767
source: injectAwDebugging,
6868
});
6969
await Page.addScriptToEvaluateOnNewDocument({
70-
source: getContent(path.join(__dirname, 'browser-shim.js')),
70+
source: getContent(path.join(__dirname, "browser-shim.js")),
7171
});
7272
if (presetEnv) {
7373
await Page.addScriptToEvaluateOnNewDocument({
74-
source: getContent(require.resolve('chai/chai')),
74+
source: getContent(require.resolve("chai/chai")),
7575
});
7676
await Page.addScriptToEvaluateOnNewDocument({
77-
source: 'expect = chai.expect;',
77+
source: "expect = chai.expect;",
7878
});
7979
await Page.addScriptToEvaluateOnNewDocument({
80-
source: getContent(require.resolve('chai-subset/lib/chai-subset')),
80+
source: getContent(require.resolve("chai-subset/lib/chai-subset")),
8181
});
8282
await Page.addScriptToEvaluateOnNewDocument({
83-
source: getContent(require.resolve('sinon-chai/lib/sinon-chai')),
83+
source: getContent(require.resolve("sinon-chai/lib/sinon-chai")),
8484
});
8585
await Page.addScriptToEvaluateOnNewDocument({
86-
source: getContent(require.resolve('sinon/pkg/sinon')),
86+
source: getContent(require.resolve("sinon/pkg/sinon")),
8787
});
8888
}
8989
return client;

0 commit comments

Comments
 (0)