Skip to content

Commit 582296c

Browse files
author
Robert Jackson
committed
eslint . --fix
1 parent dbe14cf commit 582296c

21 files changed

Lines changed: 531 additions & 420 deletions

src/ember-app.js

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class EmberApp {
9797

9898
get distPath() {
9999
return distPath;
100-
}
101-
}
100+
},
101+
},
102102
};
103103

104104
globals = Object.assign(globals, sandboxGlobals);
@@ -125,13 +125,13 @@ class EmberApp {
125125
let isLegacyWhitelist = this.schemaVersion < FastBootSchemaVersions.strictWhitelist;
126126

127127
whitelist.forEach(function(whitelistedModule) {
128-
debug("module whitelisted; module=%s", whitelistedModule);
128+
debug('module whitelisted; module=%s', whitelistedModule);
129129

130130
if (isLegacyWhitelist) {
131131
let packageName = getPackageName(whitelistedModule);
132132

133133
if (packageName !== whitelistedModule && whitelist.indexOf(packageName) === -1) {
134-
console.error("Package '" + packageName + "' is required to be in the whitelist.");
134+
console.error("Package '" + packageName + "' is required to be in the whitelist.");
135135
}
136136
}
137137
});
@@ -163,11 +163,19 @@ class EmberApp {
163163
return require(moduleName);
164164
}
165165
} else {
166-
throw new Error("Unable to require module '" + moduleName + "' because it was not in the whitelist.");
166+
throw new Error(
167+
"Unable to require module '" + moduleName + "' because it was not in the whitelist."
168+
);
167169
}
168170
}
169171

170-
throw new Error("Unable to require module '" + moduleName + "' because its package '" + packageName + "' was not in the whitelist.");
172+
throw new Error(
173+
"Unable to require module '" +
174+
moduleName +
175+
"' because its package '" +
176+
packageName +
177+
"' was not in the whitelist."
178+
);
171179
};
172180
}
173181

@@ -176,29 +184,29 @@ class EmberApp {
176184
*
177185
* Loads the app and vendor files in the sandbox (Node vm).
178186
*
179-
*/
187+
*/
180188
loadAppFiles() {
181189
let sandbox = this.sandbox;
182190
let appFilePaths = this.appFilePaths;
183191
let vendorFilePaths = this.vendorFilePaths;
184192

185193
sandbox.eval('sourceMapSupport.install(Error);');
186194

187-
debug("evaluating app and vendor files");
195+
debug('evaluating app and vendor files');
188196

189197
vendorFilePaths.forEach(function(vendorFilePath) {
190-
debug("evaluating vendor file %s", vendorFilePath);
198+
debug('evaluating vendor file %s', vendorFilePath);
191199
let vendorFile = fs.readFileSync(vendorFilePath, 'utf8');
192200
sandbox.eval(vendorFile, vendorFilePath);
193201
});
194-
debug("vendor file evaluated");
202+
debug('vendor file evaluated');
195203

196204
appFilePaths.forEach(function(appFilePath) {
197-
debug("evaluating app file %s", appFilePath);
205+
debug('evaluating app file %s', appFilePath);
198206
let appFile = fs.readFileSync(appFilePath, 'utf8');
199207
sandbox.eval(appFile, appFilePath);
200208
});
201-
debug("app files evaluated");
209+
debug('app files evaluated');
202210
}
203211

204212
/**
@@ -217,7 +225,9 @@ class EmberApp {
217225

218226
// If the application factory couldn't be found, throw an error
219227
if (!AppFactory || typeof AppFactory['default'] !== 'function') {
220-
throw new Error('Failed to load Ember app from app.js, make sure it was built for FastBoot with the `ember fastboot:build` command.');
228+
throw new Error(
229+
'Failed to load Ember app from app.js, make sure it was built for FastBoot with the `ember fastboot:build` command.'
230+
);
221231
}
222232

223233
// Otherwise, return a new `Ember.Application` instance
@@ -327,20 +337,19 @@ class EmberApp {
327337
let disableShoebox = options.disableShoebox || false;
328338
let destroyAppInstanceInMs = parseInt(options.destroyAppInstanceInMs, 10);
329339

330-
let shouldRender = (options.shouldRender !== undefined) ? options.shouldRender : true;
340+
let shouldRender = options.shouldRender !== undefined ? options.shouldRender : true;
331341
let bootOptions = buildBootOptions(shouldRender);
332-
let fastbootInfo = new FastBootInfo(
333-
req,
334-
res,
335-
{ hostWhitelist: this.hostWhitelist, metadata: options.metadata }
336-
);
342+
let fastbootInfo = new FastBootInfo(req, res, {
343+
hostWhitelist: this.hostWhitelist,
344+
metadata: options.metadata,
345+
});
337346

338347
let doc = bootOptions.document;
339348

340349
let result = new Result({
341350
doc: doc,
342351
html: html,
343-
fastbootInfo: fastbootInfo
352+
fastbootInfo: fastbootInfo,
344353
});
345354

346355
let destroyAppInstanceTimer;
@@ -349,7 +358,9 @@ class EmberApp {
349358
// This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes.
350359
destroyAppInstanceTimer = setTimeout(function() {
351360
if (result._destroyAppInstance()) {
352-
result.error = new Error('App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms');
361+
result.error = new Error(
362+
'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms'
363+
);
353364
}
354365
}, destroyAppInstanceInMs);
355366
}
@@ -361,7 +372,7 @@ class EmberApp {
361372
createShoebox(doc, fastbootInfo);
362373
}
363374
})
364-
.catch(error => result.error = error)
375+
.catch(error => (result.error = error))
365376
.then(() => result._finalize())
366377
.finally(() => {
367378
if (result._destroyAppInstance()) {
@@ -383,7 +394,9 @@ class EmberApp {
383394
try {
384395
file = fs.readFileSync(pkgPath);
385396
} catch (e) {
386-
throw new Error(`Couldn't find ${pkgPath}. You may need to update your version of ember-cli-fastboot.`);
397+
throw new Error(
398+
`Couldn't find ${pkgPath}. You may need to update your version of ember-cli-fastboot.`
399+
);
387400
}
388401

389402
let manifest;
@@ -395,15 +408,23 @@ class EmberApp {
395408
manifest = pkg.fastboot.manifest;
396409
schemaVersion = pkg.fastboot.schemaVersion;
397410
} catch (e) {
398-
throw new Error(`${pkgPath} was malformed or did not contain a manifest. Ensure that you have a compatible version of ember-cli-fastboot.`);
411+
throw new Error(
412+
`${pkgPath} was malformed or did not contain a manifest. Ensure that you have a compatible version of ember-cli-fastboot.`
413+
);
399414
}
400415

401416
const currentSchemaVersion = FastBootSchemaVersions.latest;
402417
// set schema version to 1 if not defined
403418
schemaVersion = schemaVersion || FastBootSchemaVersions.base;
404-
debug('Current schemaVersion from `ember-cli-fastboot` is %s while latest schema version is %s', schemaVersion, currentSchemaVersion);
419+
debug(
420+
'Current schemaVersion from `ember-cli-fastboot` is %s while latest schema version is %s',
421+
schemaVersion,
422+
currentSchemaVersion
423+
);
405424
if (schemaVersion > currentSchemaVersion) {
406-
let errorMsg = chalk.bold.red('An incompatible version between `ember-cli-fastboot` and `fastboot` was found. Please update the version of fastboot library that is compatible with ember-cli-fastboot.');
425+
let errorMsg = chalk.bold.red(
426+
'An incompatible version between `ember-cli-fastboot` and `fastboot` was found. Please update the version of fastboot library that is compatible with ember-cli-fastboot.'
427+
);
407428
throw new Error(errorMsg);
408429
}
409430

@@ -423,12 +444,12 @@ class EmberApp {
423444
}
424445
}
425446

426-
debug("reading array of app file paths from manifest");
447+
debug('reading array of app file paths from manifest');
427448
let appFiles = manifest.appFiles.map(function(appFile) {
428449
return path.join(distPath, appFile);
429450
});
430451

431-
debug("reading array of vendor file paths from manifest");
452+
debug('reading array of vendor file paths from manifest');
432453
let vendorFiles = manifest.vendorFiles.map(function(vendorFile) {
433454
return path.join(distPath, vendorFile);
434455
});
@@ -470,7 +491,7 @@ function buildBootOptions(shouldRender) {
470491
document: doc,
471492
rootElement,
472493
shouldRender,
473-
_renderMode
494+
_renderMode,
474495
};
475496
}
476497

@@ -486,10 +507,14 @@ const hasOwnProperty = Object.prototype.hasOwnProperty; // jshint ignore:line
486507

487508
function createShoebox(doc, fastbootInfo) {
488509
let shoebox = fastbootInfo.shoebox;
489-
if (!shoebox) { return; }
510+
if (!shoebox) {
511+
return;
512+
}
490513

491514
for (let key in shoebox) {
492-
if (!hasOwnProperty.call(shoebox, key)) { continue; } // TODO: remove this later #144, ember-fastboot/ember-cli-fastboot/pull/417
515+
if (!hasOwnProperty.call(shoebox, key)) {
516+
continue;
517+
} // TODO: remove this later #144, ember-fastboot/ember-cli-fastboot/pull/417
493518
let value = shoebox[key];
494519
let textValue = JSON.stringify(value);
495520
textValue = escapeJSONString(textValue);
@@ -509,7 +534,7 @@ const JSON_ESCAPE = {
509534
'>': '\\u003e',
510535
'<': '\\u003c',
511536
'\u2028': '\\u2028',
512-
'\u2029': '\\u2029'
537+
'\u2029': '\\u2029',
513538
};
514539

515540
const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g;

src/fastboot-headers.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class FastBootHeaders {
3838
entries() {
3939
let entries = [];
4040

41-
for(let key in this.headers) {
41+
for (let key in this.headers) {
4242
let values = this.headers[key];
43-
for(let index = 0; index < values.length; ++index ) {
43+
for (let index = 0; index < values.length; ++index) {
4444
entries.push([key, values[index]]);
4545
}
4646
}
@@ -63,9 +63,9 @@ class FastBootHeaders {
6363
keys() {
6464
let entries = [];
6565

66-
for(let key in this.headers) {
66+
for (let key in this.headers) {
6767
let values = this.headers[key];
68-
for(let index = 0; index < values.length; ++index ) {
68+
for (let index = 0; index < values.length; ++index) {
6969
entries.push(key);
7070
}
7171
}
@@ -81,9 +81,9 @@ class FastBootHeaders {
8181
values() {
8282
let entries = [];
8383

84-
for(let key in this.headers) {
84+
for (let key in this.headers) {
8585
let values = this.headers[key];
86-
for(let index = 0; index < values.length; ++index ) {
86+
for (let index = 0; index < values.length; ++index) {
8787
entries.push(values[index]);
8888
}
8989
}
@@ -92,7 +92,9 @@ class FastBootHeaders {
9292
}
9393

9494
unknownProperty(maybeHeader) {
95-
console.warn(`You called \`Ember.get(headers, '${maybeHeader}')\` with a FastBootHeaders instance as first argument. FastBootHeader is not an Ember object and you should use \`headers.get('${maybeHeader}')\` instead.`);
95+
console.warn(
96+
`You called \`Ember.get(headers, '${maybeHeader}')\` with a FastBootHeaders instance as first argument. FastBootHeader is not an Ember object and you should use \`headers.get('${maybeHeader}')\` instead.`
97+
);
9698
return this.get(maybeHeader);
9799
}
98100
}

src/fastboot-request.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class FastBootRequest {
5555
// Return an empty object instead of undefined if no cookies are present.
5656
return {};
5757
}
58-
5958
}
6059

61-
6260
module.exports = FastBootRequest;

src/fastboot-schema-versions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* should be added in fastboot lib) everytime fastboot addon schema version is bumped.
88
*/
99
const FastBootSchemaVersions = {
10-
'latest': 4, // latest schema version supported by fastboot library
11-
'base': 1, // first schema version supported by fastboot library
12-
'manifestFileArrays': 2, // schema version when app and vendor in manifest supported an array of files
13-
'configExtension': 3, // schema version when FastBoot.config can read arbitrary indexed config
14-
'strictWhitelist': 4 // schema version when fastbootDependencies and whitelist support only package names
10+
latest: 4, // latest schema version supported by fastboot library
11+
base: 1, // first schema version supported by fastboot library
12+
manifestFileArrays: 2, // schema version when app and vendor in manifest supported an array of files
13+
configExtension: 3, // schema version when FastBoot.config can read arbitrary indexed config
14+
strictWhitelist: 4, // schema version when fastbootDependencies and whitelist support only package names
1515
};
1616

1717
module.exports = FastBootSchemaVersions;

src/index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,21 @@ class FastBoot {
8888
this._buildEmberApp(distPath);
8989
}
9090

91-
_buildEmberApp(distPath = this.distPath, sandbox = this.sandbox, sandboxGlobals = this.sandboxGlobals) {
91+
_buildEmberApp(
92+
distPath = this.distPath,
93+
sandbox = this.sandbox,
94+
sandboxGlobals = this.sandboxGlobals
95+
) {
9296
if (!distPath) {
93-
throw new Error('You must instantiate FastBoot with a distPath ' +
94-
'option that contains a path to a dist directory ' +
95-
'produced by running ember fastboot:build in your Ember app:' +
96-
'\n\n' +
97-
'new FastBootServer({\n' +
98-
' distPath: \'path/to/dist\'\n' +
99-
'});');
97+
throw new Error(
98+
'You must instantiate FastBoot with a distPath ' +
99+
'option that contains a path to a dist directory ' +
100+
'produced by running ember fastboot:build in your Ember app:' +
101+
'\n\n' +
102+
'new FastBootServer({\n' +
103+
" distPath: 'path/to/dist'\n" +
104+
'});'
105+
);
100106
}
101107

102108
this.distPath = distPath;
@@ -107,7 +113,6 @@ class FastBoot {
107113
sandboxGlobals,
108114
});
109115
}
110-
111116
}
112117

113118
module.exports = FastBoot;

src/install-source-map-support.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const sourceMapSupport = require('source-map-support');
22

33
function prepareStackTrace(error, stack) {
4-
return error + stack.map((frame) => '\n at ' + sourceMapSupport.wrapCallSite(frame)).join('');
4+
return error + stack.map(frame => '\n at ' + sourceMapSupport.wrapCallSite(frame)).join('');
55
}
66

77
function install(errorClass) {
@@ -16,5 +16,5 @@ function install(errorClass) {
1616
}
1717

1818
module.exports = {
19-
install
19+
install,
2020
};

0 commit comments

Comments
 (0)