Skip to content

Commit cdc7f53

Browse files
committed
run prettier fix
1 parent 9a48fa8 commit cdc7f53

22 files changed

Lines changed: 340 additions & 190 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Ember Cli FastBoot
22

3-
See the [main readme](../../README.md) or http://ember-fastboot.com/ for more information.
3+
See the [main readme](../../README.md) or http://ember-fastboot.com/ for more information.

packages/ember-cli-fastboot/addon/instance-initializers/clear-double-boot.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function clearHtml() {
1313
if (current && endMarker) {
1414
let shoeboxNodes = document.querySelectorAll('[type="fastboot/shoebox"]');
1515
let shoeboxNodesArray = []; // Note that IE11 doesn't support more concise options like Array.from, so we have to do something like this
16-
for(let i=0; i < shoeboxNodes.length; i++){
16+
for (let i = 0; i < shoeboxNodes.length; i++) {
1717
shoeboxNodesArray.push(shoeboxNodes[i]);
1818
}
1919
let parent = current.parentElement;
@@ -22,21 +22,25 @@ export function clearHtml() {
2222
nextNode = current.nextSibling;
2323
parent.removeChild(current);
2424
current = nextNode;
25-
} while (nextNode && nextNode !== endMarker && shoeboxNodesArray.indexOf(nextNode) < 0);
25+
} while (
26+
nextNode &&
27+
nextNode !== endMarker &&
28+
shoeboxNodesArray.indexOf(nextNode) < 0
29+
);
2630
endMarker.parentElement.removeChild(endMarker);
2731
}
2832
}
2933
export default {
30-
name: "clear-double-boot",
34+
name: 'clear-double-boot',
3135

3236
initialize(instance) {
3337
if (typeof FastBoot === 'undefined') {
3438
var originalDidCreateRootView = instance.didCreateRootView;
3539

36-
instance.didCreateRootView = function() {
40+
instance.didCreateRootView = function () {
3741
clearHtml();
3842
originalDidCreateRootView.apply(instance, arguments);
3943
};
4044
}
41-
}
42-
}
45+
},
46+
};

packages/ember-cli-fastboot/addon/locations/none.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { computed, get } from '@ember/object';
33
import { bool, readOnly } from '@ember/object/computed';
44
import { inject as service } from '@ember/service';
5-
import { getOwner } from '@ember/application'
6-
import NoneLocation from '@ember/routing/none-location'
5+
import { getOwner } from '@ember/application';
6+
import NoneLocation from '@ember/routing/none-location';
77

88
const TEMPORARY_REDIRECT_CODE = 307;
99

@@ -18,7 +18,9 @@ export default NoneLocation.extend({
1818
_fastbootHeadersEnabled: bool('_config.fastboot.fastbootHeaders'),
1919

2020
_redirectCode: computed(function () {
21-
return get(this, '_config.fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE;
21+
return (
22+
get(this, '_config.fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE
23+
);
2224
}),
2325

2426
_response: readOnly('fastboot.response'),
@@ -50,5 +52,5 @@ export default NoneLocation.extend({
5052
}
5153

5254
this._super(...arguments);
53-
}
55+
},
5456
});

packages/ember-cli-fastboot/addon/services/fastboot.js

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,57 +21,70 @@ const RequestObject = EObject.extend({
2121
this.queryParams = request?.queryParams;
2222
this.path = request?.path;
2323
this.protocol = request?.protocol;
24-
this._host = function() {
24+
this._host = function () {
2525
return request?.host();
2626
};
2727
},
2828

29-
host: computed(function() {
29+
host: computed(function () {
3030
return this._host();
31-
})
31+
}),
3232
});
3333

3434
const Shoebox = EObject.extend({
3535
put(key, value) {
36-
assert('shoebox.put is only invoked from the FastBoot rendered application', this.get('fastboot.isFastBoot'));
36+
assert(
37+
'shoebox.put is only invoked from the FastBoot rendered application',
38+
this.get('fastboot.isFastBoot'),
39+
);
3740
assert('the provided key is a string', typeof key === 'string');
3841

3942
let fastbootInfo = this.get('fastboot._fastbootInfo');
40-
if (!fastbootInfo.shoebox) { fastbootInfo.shoebox = {}; }
43+
if (!fastbootInfo.shoebox) {
44+
fastbootInfo.shoebox = {};
45+
}
4146

4247
fastbootInfo.shoebox[key] = value;
4348
},
4449

4550
retrieve(key) {
4651
if (this.get('fastboot.isFastBoot')) {
4752
let shoebox = this.get('fastboot._fastbootInfo.shoebox');
48-
if (!shoebox) { return; }
53+
if (!shoebox) {
54+
return;
55+
}
4956

5057
return shoebox[key];
5158
}
5259

5360
let shoeboxItem = this.get(key);
54-
if (shoeboxItem) { return shoeboxItem; }
61+
if (shoeboxItem) {
62+
return shoeboxItem;
63+
}
5564

5665
let el = document.querySelector(`#shoebox-${key}`);
57-
if (!el) { return; }
66+
if (!el) {
67+
return;
68+
}
5869
let valueString = el.textContent;
59-
if (!valueString) { return; }
70+
if (!valueString) {
71+
return;
72+
}
6073

6174
shoeboxItem = JSON.parse(valueString);
6275
this.set(key, shoeboxItem);
6376

6477
return shoeboxItem;
65-
}
78+
},
6679
});
6780

6881
const FastBootService = Service.extend({
6982
isFastBoot: typeof FastBoot !== 'undefined',
7083

71-
isFastboot: computed(function() {
84+
isFastboot: computed(function () {
7285
assert(
7386
'The fastboot service does not have an `isFastboot` property. This is likely a typo. Please use `isFastBoot` instead.',
74-
false
87+
false,
7588
);
7689
}),
7790

@@ -85,9 +98,11 @@ const FastBootService = Service.extend({
8598
response: readOnly('_fastbootInfo.response'),
8699
metadata: readOnly('_fastbootInfo.metadata'),
87100

88-
request: computed(function() {
101+
request: computed(function () {
89102
if (!this.isFastBoot) return null;
90-
return RequestObject.create({ request: get(this, '_fastbootInfo.request') });
103+
return RequestObject.create({
104+
request: get(this, '_fastbootInfo.request'),
105+
});
91106
}),
92107

93108
// this getter/setter pair is to avoid deprecation from [RFC - 680](https://github.com/emberjs/rfcs/pull/680)
@@ -102,13 +117,16 @@ const FastBootService = Service.extend({
102117
set(_key, value) {
103118
this.__fastbootInfo = value;
104119
return value;
105-
}
120+
},
106121
}),
107122

108123
deferRendering(promise) {
109-
assert('deferRendering requires a promise or thennable object', typeof promise.then === 'function');
124+
assert(
125+
'deferRendering requires a promise or thennable object',
126+
typeof promise.then === 'function',
127+
);
110128
this._fastbootInfo.deferRendering(promise);
111-
}
129+
},
112130
});
113131

114132
export default FastBootService;

packages/ember-cli-fastboot/blueprints/ember-cli-fastboot/index.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,44 @@ module.exports = {
88
},
99

1010
afterInstall() {
11-
let targetsFile = './config/targets.js'
11+
let targetsFile = './config/targets.js';
1212

13-
if(this.project.isEmberCLIAddon()) {
13+
if (this.project.isEmberCLIAddon()) {
1414
targetsFile = './tests/dummy/config/targets.js';
1515
}
1616

1717
const targetsAst = recast.parse(readFileSync(targetsFile));
1818

1919
recast.visit(targetsAst, {
20-
visitAssignmentExpression (path) {
20+
visitAssignmentExpression(path) {
2121
let node = path.node;
2222

23-
if (node.left.object.name === 'module' && node.left.property.name === 'exports') {
24-
let nodeProperty = node.right.properties.find(property => property.key.name === 'node');
23+
if (
24+
node.left.object.name === 'module' &&
25+
node.left.property.name === 'exports'
26+
) {
27+
let nodeProperty = node.right.properties.find(
28+
(property) => property.key.name === 'node',
29+
);
2530

26-
if(!nodeProperty) {
31+
if (!nodeProperty) {
2732
let builders = recast.types.builders;
2833
nodeProperty = builders.property(
2934
'init',
3035
builders.identifier('node'),
31-
builders.literal('current')
36+
builders.literal('current'),
3237
);
3338
node.right.properties.push(nodeProperty);
3439
}
3540
}
3641

3742
this.traverse(path);
38-
}
43+
},
3944
});
4045

41-
writeFileSync(targetsFile, recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code);
42-
}
46+
writeFileSync(
47+
targetsFile,
48+
recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code,
49+
);
50+
},
4351
};

packages/ember-cli-fastboot/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default [
9292
'.template-lintrc.js',
9393
'ember-cli-build.js',
9494
'blueprints/ember-cli-fastboot/index.js',
95-
'lib/**/*.js'
95+
'lib/**/*.js',
9696
],
9797
plugins: {
9898
n,
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* eslint-disable no-redeclare, no-unused-vars */
22
/*globals Ember, URL*/
33
export default {
4-
name: "dom-helper-patches",
4+
name: 'dom-helper-patches',
55

6-
initialize: function(App) {
6+
initialize: function (App) {
77
// TODO: remove me
8-
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function(url) {
8+
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function (url) {
99
var protocol = URL.parse(url).protocol;
10-
return (protocol == null) ? ':' : protocol;
10+
return protocol == null ? ':' : protocol;
1111
};
1212

1313
// TODO: remove me https://github.com/tildeio/htmlbars/pull/425
14-
Ember.HTMLBars.DOMHelper.prototype.parseHTML = function(html) {
14+
Ember.HTMLBars.DOMHelper.prototype.parseHTML = function (html) {
1515
return this.document.createRawHTMLSection(html);
1616
};
17-
}
17+
},
1818
};

packages/ember-cli-fastboot/fastboot/initializers/ajax.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Ember from 'ember';
44

55
const { get } = Ember;
66

7-
var nodeAjax = function(options) {
7+
var nodeAjax = function (options) {
88
let httpRegex = /^https?:\/\//;
99
let protocolRelativeRegex = /^\/\//;
1010
let protocol = get(this, 'fastboot.request.protocol');
@@ -13,23 +13,29 @@ var nodeAjax = function(options) {
1313
options.url = protocol + options.url;
1414
} else if (!httpRegex.test(options.url)) {
1515
try {
16-
options.url = protocol + '//' + get(this, 'fastboot.request.host') + options.url;
16+
options.url =
17+
protocol + '//' + get(this, 'fastboot.request.host') + options.url;
1718
} catch (fbError) {
18-
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message);
19+
throw new Error(
20+
'You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' +
21+
fbError.message,
22+
);
1923
}
2024
}
2125

2226
if (najax) {
2327
najax(options);
2428
} else {
25-
throw new Error('najax does not seem to be defined in your app. Did you override it via `addOrOverrideSandboxGlobals` in the fastboot server?');
29+
throw new Error(
30+
'najax does not seem to be defined in your app. Did you override it via `addOrOverrideSandboxGlobals` in the fastboot server?',
31+
);
2632
}
2733
};
2834

2935
export default {
3036
name: 'ajax-service',
3137

32-
initialize: function(application) {
38+
initialize: function (application) {
3339
application.register('ajax:node', nodeAjax, { instantiate: false });
34-
}
40+
},
3541
};

packages/ember-cli-fastboot/fastboot/initializers/error-handler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import Ember from 'ember';
88
export default {
99
name: 'error-handler',
1010

11-
initialize: function() {
11+
initialize: function () {
1212
if (!Ember.onerror) {
1313
// if no onerror handler is defined, define one for fastboot environments
14-
Ember.onerror = function(err) {
14+
Ember.onerror = function (err) {
1515
const errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${err.stack || err}`;
1616
console.error(errorMessage);
17-
}
17+
};
1818
}
19-
}
19+
},
2020
};

0 commit comments

Comments
 (0)