Skip to content

Commit d727dea

Browse files
committed
fix lint
1 parent 89ecb72 commit d727dea

22 files changed

+244
-244
lines changed

packages/fastboot-express-middleware/src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function fastbootExpressMiddleware(distPath, options) {
1313

1414
opts = opts || {};
1515

16-
let log = opts.log !== false ? _log : function () {};
16+
let log = opts.log !== false ? _log : function() {};
1717

1818
let fastboot = opts.fastboot;
1919

@@ -25,7 +25,7 @@ function fastbootExpressMiddleware(distPath, options) {
2525
});
2626
}
2727

28-
return async function (req, res, next) {
28+
return async function(req, res, next) {
2929
let path = req.url;
3030

3131
try {
@@ -53,7 +53,7 @@ function fastbootExpressMiddleware(distPath, options) {
5353
} else if (result.error) {
5454
res.send(body[0]);
5555
} else {
56-
body.forEach((chunk) => res.write(chunk));
56+
body.forEach(chunk => res.write(chunk));
5757
res.end();
5858
}
5959
} catch (error) {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var path = require('path');
22

3-
module.exports = function (fixturePath) {
3+
module.exports = function(fixturePath) {
44
return path.join(__dirname, '../fixtures/', fixturePath);
55
};

packages/fastboot-express-middleware/test/helpers/test-http-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TestHTTPServer {
3535
});
3636
}
3737

38-
return new Promise((resolve) => {
38+
return new Promise(resolve => {
3939
let port = options.port || 3000;
4040
let host = options.host || 'localhost';
4141

packages/fastboot-express-middleware/test/middleware-test.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ const fastbootMiddleware = require('./../src/index');
66
const fixture = require('./helpers/fixture-path');
77
const TestHTTPServer = require('./helpers/test-http-server');
88

9-
describe('FastBoot', function () {
9+
describe('FastBoot', function() {
1010
let server;
1111

1212
this.timeout(10000);
1313

14-
afterEach(function () {
14+
afterEach(function() {
1515
if (server) {
1616
server.stop();
1717
server = null;
1818
}
1919
});
2020

21-
it('throws an exception if no distPath is provided', function () {
22-
let fn = function () {
21+
it('throws an exception if no distPath is provided', function() {
22+
let fn = function() {
2323
fastbootMiddleware();
2424
};
2525

2626
expect(fn).to.throw(/You must instantiate FastBoot with a distPath option/);
2727
});
2828

29-
it('can provide distPath as the first argument', async function () {
29+
it('can provide distPath as the first argument', async function() {
3030
let middleware = fastbootMiddleware(fixture('basic-app'));
3131
server = new TestHTTPServer(middleware);
3232
await server.start();
@@ -35,7 +35,7 @@ describe('FastBoot', function () {
3535
expect(html).to.match(/Welcome to Ember/);
3636
});
3737

38-
it('can provide distPath as an option', async function () {
38+
it('can provide distPath as an option', async function() {
3939
let middleware = fastbootMiddleware({
4040
distPath: fixture('basic-app'),
4141
});
@@ -46,7 +46,7 @@ describe('FastBoot', function () {
4646
expect(html).to.match(/Welcome to Ember/);
4747
});
4848

49-
it('can be provided with a custom FastBoot instance', async function () {
49+
it('can be provided with a custom FastBoot instance', async function() {
5050
let fastboot = new FastBoot({
5151
distPath: fixture('basic-app'),
5252
});
@@ -62,7 +62,7 @@ describe('FastBoot', function () {
6262
expect(html).to.match(/Welcome to Ember/);
6363
});
6464

65-
it('can reload the FastBoot instance', async function () {
65+
it('can reload the FastBoot instance', async function() {
6666
let fastboot = new FastBoot({
6767
distPath: fixture('basic-app'),
6868
});
@@ -85,7 +85,7 @@ describe('FastBoot', function () {
8585
expect(html).to.match(/Goodbye from Ember/);
8686
});
8787

88-
it('it appends multivalue headers', async function () {
88+
it('it appends multivalue headers', async function() {
8989
let middleware = fastbootMiddleware(fixture('multivalue-headers'));
9090
server = new TestHTTPServer(middleware);
9191
await server.start();
@@ -94,7 +94,7 @@ describe('FastBoot', function () {
9494
expect(headers['x-fastboot']).to.eq('a, b, c');
9595
});
9696

97-
it('can pass metadata info to the app', async function () {
97+
it('can pass metadata info to the app', async function() {
9898
let middleware = fastbootMiddleware({
9999
distPath: fixture('app-with-metadata'),
100100
visitOptions: {
@@ -111,7 +111,7 @@ describe('FastBoot', function () {
111111
// FIXME:
112112
// TODO:
113113
// https://github.com/ember-fastboot/ember-cli-fastboot/pull/840#issuecomment-894329631
114-
xit('works without metadata passed', async function () {
114+
it('works without metadata passed', async function() {
115115
let middleware = fastbootMiddleware({
116116
distPath: fixture('app-with-metadata'),
117117
});
@@ -123,10 +123,10 @@ describe('FastBoot', function () {
123123
});
124124

125125
/* eslint-disable mocha/no-setup-in-describe */
126-
[true, false].forEach((chunkedResponse) => {
127-
describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function () {
126+
[true, false].forEach(chunkedResponse => {
127+
describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function() {
128128
if (chunkedResponse) {
129-
it('responds with a chunked response', async function () {
129+
it('responds with a chunked response', async function() {
130130
let middleware = fastbootMiddleware({
131131
distPath: fixture('basic-app'),
132132
chunkedResponse,
@@ -140,7 +140,7 @@ describe('FastBoot', function () {
140140
});
141141
}
142142

143-
it("returns 404 when navigating to a URL that doesn't exist", async function () {
143+
it("returns 404 when navigating to a URL that doesn't exist", async function() {
144144
let middleware = fastbootMiddleware({
145145
distPath: fixture('basic-app'),
146146
chunkedResponse,
@@ -155,7 +155,7 @@ describe('FastBoot', function () {
155155
}
156156
});
157157

158-
it('returns a 500 error if an error occurs', async function () {
158+
it('returns a 500 error if an error occurs', async function() {
159159
let middleware = fastbootMiddleware({
160160
distPath: fixture('rejected-promise'),
161161
chunkedResponse,
@@ -170,8 +170,8 @@ describe('FastBoot', function () {
170170
}
171171
});
172172

173-
describe('when resilient mode is enabled', function () {
174-
it('renders no FastBoot markup', async function () {
173+
describe('when resilient mode is enabled', function() {
174+
it('renders no FastBoot markup', async function() {
175175
let middleware = fastbootMiddleware({
176176
distPath: fixture('rejected-promise'),
177177
resilient: true,
@@ -184,7 +184,7 @@ describe('FastBoot', function () {
184184
expect(html).to.not.match(/error/);
185185
});
186186

187-
it('propagates to error handling middleware', async function () {
187+
it('propagates to error handling middleware', async function() {
188188
let middleware = fastbootMiddleware({
189189
distPath: fixture('rejected-promise'),
190190
resilient: true,
@@ -201,7 +201,7 @@ describe('FastBoot', function () {
201201
expect(body).to.match(/hello world/);
202202
});
203203

204-
it('is does not propagate errors when and there is no error handling middleware', async function () {
204+
it('is does not propagate errors when and there is no error handling middleware', async function() {
205205
let middleware = fastbootMiddleware({
206206
distPath: fixture('rejected-promise'),
207207
resilient: true,
@@ -219,7 +219,7 @@ describe('FastBoot', function () {
219219
expect(body).to.match(/hello world/);
220220
});
221221

222-
it('allows post-fastboot middleware to recover the response when it fails', async function () {
222+
it('allows post-fastboot middleware to recover the response when it fails', async function() {
223223
let middleware = fastbootMiddleware({
224224
distPath: fixture('rejected-promise'),
225225
resilient: true,
@@ -237,8 +237,8 @@ describe('FastBoot', function () {
237237
});
238238
});
239239

240-
describe('when resilient mode is disabled', function () {
241-
it('propagates to error handling middleware', async function () {
240+
describe('when resilient mode is disabled', function() {
241+
it('propagates to error handling middleware', async function() {
242242
let middleware = fastbootMiddleware({
243243
distPath: fixture('rejected-promise'),
244244
resilient: false,
@@ -257,7 +257,7 @@ describe('FastBoot', function () {
257257
}
258258
});
259259

260-
it('allows post-fastboot middleware to recover the response when it fails', async function () {
260+
it('allows post-fastboot middleware to recover the response when it fails', async function() {
261261
let middleware = fastbootMiddleware({
262262
distPath: fixture('rejected-promise'),
263263
resilient: false,

packages/fastboot/dev/memory-usage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ session.connect();
2828

2929
let file;
3030
// uses whatever the "current" file is
31-
session.on('HeapProfiler.addHeapSnapshotChunk', (m) => {
31+
session.on('HeapProfiler.addHeapSnapshotChunk', m => {
3232
fs.writeSync(file, m.params.chunk);
3333
});
3434

packages/fastboot/src/ember-app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class EmberApp {
165165
debug('files evaluated');
166166

167167
// Retrieve the application factory from within the sandbox
168-
let AppFactory = sandbox.run(function (ctx) {
168+
let AppFactory = sandbox.run(function(ctx) {
169169
return ctx.require('~fastboot/app-factory');
170170
});
171171

@@ -316,7 +316,7 @@ class EmberApp {
316316
if (destroyAppInstanceInMs > 0) {
317317
// start a timer to destroy the appInstance forcefully in the given ms.
318318
// This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes.
319-
destroyAppInstanceTimer = setTimeout(function () {
319+
destroyAppInstanceTimer = setTimeout(function() {
320320
if (result._destroy()) {
321321
result.error = new Error(
322322
'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms'
@@ -418,7 +418,7 @@ const JSON_ESCAPE = {
418418
const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g;
419419

420420
function escapeJSONString(string) {
421-
return string.replace(JSON_ESCAPE_REGEXP, function (match) {
421+
return string.replace(JSON_ESCAPE_REGEXP, function(match) {
422422
return JSON_ESCAPE[match];
423423
});
424424
}
@@ -432,7 +432,7 @@ function registerFastBootInfo(info, instance) {
432432
}
433433

434434
function buildScripts(filePaths) {
435-
return filePaths.filter(Boolean).map((filePath) => {
435+
return filePaths.filter(Boolean).map(filePath => {
436436
let source = fs.readFileSync(filePath, { encoding: 'utf8' });
437437

438438
return new vm.Script(source, { filename: filePath });

packages/fastboot/src/fastboot-request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FastBootRequest {
2323
}
2424

2525
var host = this.headers.get('host');
26-
var matchFound = this.hostWhitelist.some(function (entry) {
26+
var matchFound = this.hostWhitelist.some(function(entry) {
2727
if (entry[0] === '/' && entry.slice(-1) === '/') {
2828
var regexp = new RegExp(entry.slice(1, -1));
2929
return regexp.test(host);

packages/fastboot/src/fastboot-schema.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) {
127127
}
128128
}
129129

130-
let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function (file) {
130+
let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function(file) {
131131
return path.join(distPath, file);
132132
});
133133
let html = fs.readFileSync(path.join(distPath, manifest.htmlFile), 'utf8');
@@ -149,7 +149,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) {
149149
* @param {boolean} isLegacyWhiteList flag to enable legacy behavior
150150
*/
151151
function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) {
152-
whitelist.forEach(function (whitelistedModule) {
152+
whitelist.forEach(function(whitelistedModule) {
153153
debug('module whitelisted; module=%s', whitelistedModule);
154154

155155
if (isLegacyWhitelist) {
@@ -161,7 +161,7 @@ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) {
161161
}
162162
});
163163

164-
return function (moduleName) {
164+
return function(moduleName) {
165165
let packageName = getPackageName(moduleName);
166166
let isWhitelisted = whitelist.indexOf(packageName) > -1;
167167

packages/fastboot/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class FastBoot {
5555
console.warn(
5656
'[DEPRECATION] Instantiating `fastboot` with a `sandboxGlobals` option has been deprecated. Please migrate to specifying `buildSandboxGlobals` instead.'
5757
);
58-
buildSandboxGlobals = (globals) => Object.assign({}, globals, options.sandboxGlobals);
58+
buildSandboxGlobals = globals => Object.assign({}, globals, options.sandboxGlobals);
5959
}
6060

6161
this.buildSandboxGlobals = buildSandboxGlobals;

packages/fastboot/src/result.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Result {
8080
this._body,
8181
this._bodyAttributes,
8282
this._bodyClass
83-
).then((html) => {
83+
).then(html => {
8484
let docParts = html.match(HTML_HEAD_REGEX);
8585
if (!docParts || docParts.length === 1) {
8686
return [html];
@@ -97,7 +97,7 @@ class Result {
9797
let [plainBody, ...shoeboxes] = body.split(SHOEBOX_TAG_PATTERN);
9898

9999
let chunks = [head, plainBody].concat(
100-
shoeboxes.map((shoebox) => `${SHOEBOX_TAG_PATTERN}${shoebox}`)
100+
shoeboxes.map(shoebox => `${SHOEBOX_TAG_PATTERN}${shoebox}`)
101101
);
102102

103103
return chunks;
@@ -203,10 +203,10 @@ function extractExtraAttributes(element) {
203203
let klass;
204204
let attributes;
205205
if (element.attributes.length > 0) {
206-
let elementClass = element.attributes.find((attr) => attr.name === 'class');
206+
let elementClass = element.attributes.find(attr => attr.name === 'class');
207207
if (elementClass) {
208208
klass = elementClass;
209-
let otherAttrs = element.attributes.filter((attr) => attr.name !== 'class');
209+
let otherAttrs = element.attributes.filter(attr => attr.name !== 'class');
210210
if (otherAttrs.length > 0) {
211211
attributes = HTMLSerializer.attributes(otherAttrs);
212212
} else {
@@ -229,9 +229,9 @@ function missingTag(tag) {
229229
}
230230

231231
function addClass(html, regex, newClass) {
232-
return html.replace(regex, function (_, tag, attributes) {
232+
return html.replace(regex, function(_, tag, attributes) {
233233
if (/class="([^"]*)"/i.test(attributes)) {
234-
attributes = attributes.replace(/class="([^"]*)"/i, function (_, klass) {
234+
attributes = attributes.replace(/class="([^"]*)"/i, function(_, klass) {
235235
return `class="${klass} ${newClass}"`;
236236
});
237237
} else {
@@ -256,7 +256,7 @@ async function insertIntoIndexHTML(
256256
let isBodyReplaced = false;
257257
let isHeadReplaced = false;
258258

259-
html = html.replace(/<!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function (match, tag) {
259+
html = html.replace(/<!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function(match, tag) {
260260
if (tag === 'HEAD' && head && !isHeadReplaced) {
261261
isHeadReplaced = true;
262262
return head;
@@ -271,7 +271,7 @@ async function insertIntoIndexHTML(
271271
html = addClass(html, /<(html)(.*)>/i, htmlClass.value);
272272
}
273273
if (htmlAttributes) {
274-
html = html.replace(/<html[^>]*/i, function (match) {
274+
html = html.replace(/<html[^>]*/i, function(match) {
275275
return match + ' ' + htmlAttributes;
276276
});
277277
}
@@ -280,7 +280,7 @@ async function insertIntoIndexHTML(
280280
html = addClass(html, /<(body)(.*)>/i, bodyClass.value);
281281
}
282282
if (bodyAttributes) {
283-
html = html.replace(/<body[^>]*/i, function (match) {
283+
html = html.replace(/<body[^>]*/i, function(match) {
284284
return match + ' ' + bodyAttributes;
285285
});
286286
}

packages/fastboot/src/sandbox.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module.exports = class Sandbox {
4646
buildWrappedConsole() {
4747
let wrappedConsole = Object.create(console);
4848

49-
wrappedConsole.error = function (...args) {
49+
wrappedConsole.error = function(...args) {
5050
console.error.apply(
5151
console,
52-
args.map(function (a) {
52+
args.map(function(a) {
5353
return typeof a === 'string' ? chalk.red(a) : a;
5454
})
5555
);

0 commit comments

Comments
 (0)