Skip to content

Commit 20ab0b2

Browse files
committed
chore: runs yarn lint:fix
1 parent 891425c commit 20ab0b2

33 files changed

+505
-426
lines changed

.eslintrc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
rules: {
2626
'ember/no-new-mixins': 'off',
2727
'ember/no-jquery': 'error',
28-
'no-console': ['error', { allow: ['warn'] }]
28+
'no-console': ['error', { allow: ['warn'] }],
2929
},
3030
overrides: [
3131
// TypeScript files
@@ -35,8 +35,8 @@ module.exports = {
3535
plugins: ['@typescript-eslint'],
3636
rules: {
3737
'no-undef': 'off',
38-
'no-unused-var': 'off'
39-
}
38+
'no-unused-var': 'off',
39+
},
4040
},
4141
// node files
4242
{
@@ -62,8 +62,8 @@ module.exports = {
6262
extends: ['plugin:n/recommended'],
6363
rules: {
6464
'node/no-unpublished-require': 'off',
65-
'node/no-extraneous-require': 'off'
66-
}
65+
'node/no-extraneous-require': 'off',
66+
},
6767
},
6868
{
6969
// test files

ember-cli-build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module.exports = function (defaults) {
77
// Add options here
88
'ember-fetch': {
99
nativePromise: process.env.NATIVE_PROMISE ? true : false,
10-
preferNative: process.env.PREFER_NATIVE ? true : false
11-
}
10+
preferNative: process.env.PREFER_NATIVE ? true : false,
11+
},
1212
});
1313

1414
/*

fastboot/instance-initializers/setup-fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ function patchFetchForRelativeURLs(instance) {
1212

1313
export default {
1414
name: 'fetch',
15-
initialize: patchFetchForRelativeURLs
15+
initialize: patchFetchForRelativeURLs,
1616
};

index.js

Lines changed: 102 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@ module.exports = {
6666
* which allows us to use the `import()` method to tell it to include a file
6767
* from our `vendor` tree into the final built app.
6868
*/
69-
included: function() {
69+
included: function () {
7070
this._super.included.apply(this, arguments);
7171

7272
let isApp = !this.project.isEmberCLIAddon();
7373

7474
let hasEmberFetch = !!this.project.findAddonByName('ember-fetch');
75-
let hasEmberCliFastboot = !!this.project.findAddonByName('ember-cli-fastboot');
75+
let hasEmberCliFastboot =
76+
!!this.project.findAddonByName('ember-cli-fastboot');
7677

7778
let emberSource = new VersionChecker(this.project).for('ember-source');
78-
let hasEmberSourceModules = emberSource.exists() && emberSource.gte('4.4.0');
79+
let hasEmberSourceModules =
80+
emberSource.exists() && emberSource.gte('4.4.0');
7981

80-
if(isApp && hasEmberCliFastboot && !hasEmberFetch) {
82+
if (isApp && hasEmberCliFastboot && !hasEmberFetch) {
8183
throw new Error(`Ember fetch is not installed as top-level dependency of the application using fastboot. Add ember-fetch as dependecy in application's package.json.
8284
For details check here - https://github.com/ember-cli/ember-fetch#top-level-addon`);
8385
}
@@ -89,13 +91,16 @@ module.exports = {
8991
importTarget = this;
9092
}
9193

92-
app._fetchBuildConfig = Object.assign({
93-
preferNative: false,
94-
nativePromise: false,
95-
alwaysIncludePolyfill: false,
96-
hasEmberSourceModules,
97-
browsers: this.project.targets && this.project.targets.browsers
98-
}, app.options['ember-fetch']);
94+
app._fetchBuildConfig = Object.assign(
95+
{
96+
preferNative: false,
97+
nativePromise: false,
98+
alwaysIncludePolyfill: false,
99+
hasEmberSourceModules,
100+
browsers: this.project.targets && this.project.targets.browsers,
101+
},
102+
app.options['ember-fetch']
103+
);
99104

100105
importTarget.import('vendor/ember-fetch.js', {
101106
exports: {
@@ -104,9 +109,9 @@ module.exports = {
104109
'Headers',
105110
'Request',
106111
'Response',
107-
'AbortController'
108-
]
109-
}
112+
'AbortController',
113+
],
114+
},
110115
});
111116
},
112117

@@ -120,37 +125,51 @@ module.exports = {
120125
* the correct version of the polyfill at the `vendor/ember-fetch.js` path.
121126
*/
122127
treeForVendor() {
123-
let babelAddon = this.addons.find(addon => addon.name === 'ember-cli-babel');
128+
let babelAddon = this.addons.find(
129+
(addon) => addon.name === 'ember-cli-babel'
130+
);
124131

125132
const app = this._findApp();
126133
const options = app._fetchBuildConfig;
127134

128135
let browserTree = this.treeForBrowserFetch(options);
129136
if (babelAddon) {
130-
browserTree = debug(babelAddon.transpileTree(browserTree, {
131-
'ember-cli-babel': {
132-
compileModules: false,
133-
},
134-
}), 'after-babel');
135-
137+
browserTree = debug(
138+
babelAddon.transpileTree(browserTree, {
139+
'ember-cli-babel': {
140+
compileModules: false,
141+
},
142+
}),
143+
'after-babel'
144+
);
136145
} else {
137-
this.ui.writeWarnLine('[ember-fetch] Could not find `ember-cli-babel` addon, opting out of transpilation!')
146+
this.ui.writeWarnLine(
147+
'[ember-fetch] Could not find `ember-cli-babel` addon, opting out of transpilation!'
148+
);
138149
}
139150

140151
const preferNative = options.preferNative;
141152

142-
return debug(map(browserTree, (content) => `if (typeof FastBoot === 'undefined') {
153+
return debug(
154+
map(
155+
browserTree,
156+
(content) => `if (typeof FastBoot === 'undefined') {
143157
var preferNative = ${preferNative};
144158
${content}
145-
}`), 'wrapped');
159+
}`
160+
),
161+
'wrapped'
162+
);
146163
},
147164

148165
// Only include public/fetch-fastboot.js if top level addon
149166
treeForPublic() {
150-
const fastbootEnabled = process.env.FASTBOOT_DISABLED !== 'true'
151-
&& !!this.project.findAddonByName('ember-cli-fastboot');
167+
const fastbootEnabled =
168+
process.env.FASTBOOT_DISABLED !== 'true' &&
169+
!!this.project.findAddonByName('ember-cli-fastboot');
152170
return !this.parent.parent && fastbootEnabled
153-
? this._super.treeForPublic.apply(this, arguments) : null;
171+
? this._super.treeForPublic.apply(this, arguments)
172+
: null;
154173
},
155174

156175
cacheKeyForTree(treeType) {
@@ -175,52 +194,73 @@ module.exports = {
175194
treeForBrowserFetch(options) {
176195
const browsers = options.browsers;
177196
// To skip including the polyfill, `preferNative` needs to be `true` AND `alwaysIncludePolyfill` needs to be `false` (default)
178-
const alwaysIncludePolyfill = !options.preferNative || options.alwaysIncludePolyfill;
179-
const needsFetchPolyfill = alwaysIncludePolyfill || !this._checkSupports('fetch', browsers);
180-
const needsAbortControllerPolyfill = alwaysIncludePolyfill || !this._checkSupports('abortcontroller', browsers);
197+
const alwaysIncludePolyfill =
198+
!options.preferNative || options.alwaysIncludePolyfill;
199+
const needsFetchPolyfill =
200+
alwaysIncludePolyfill || !this._checkSupports('fetch', browsers);
201+
const needsAbortControllerPolyfill =
202+
alwaysIncludePolyfill ||
203+
!this._checkSupports('abortcontroller', browsers);
181204

182205
const inputNodes = [];
183206
const inputFiles = [];
184207

185208
if (needsAbortControllerPolyfill) {
186-
const abortcontrollerNode = debug(new Rollup(path.dirname(path.dirname(require.resolve('abortcontroller-polyfill'))), {
187-
rollup: {
188-
input: 'src/abortcontroller-polyfill.js',
189-
output: {
190-
file: 'abortcontroller.js',
191-
// abortcontroller is polyfill only, the name is only required by rollup iife
192-
name: 'AbortController',
193-
format: 'iife'
209+
const abortcontrollerNode = debug(
210+
new Rollup(
211+
path.dirname(
212+
path.dirname(require.resolve('abortcontroller-polyfill'))
213+
),
214+
{
215+
rollup: {
216+
input: 'src/abortcontroller-polyfill.js',
217+
output: {
218+
file: 'abortcontroller.js',
219+
// abortcontroller is polyfill only, the name is only required by rollup iife
220+
name: 'AbortController',
221+
format: 'iife',
222+
},
223+
},
194224
}
195-
}
196-
}), 'abortcontroller');
225+
),
226+
'abortcontroller'
227+
);
197228

198229
inputNodes.push(abortcontrollerNode);
199230
inputFiles.push('abortcontroller.js');
200231
}
201232

202233
if (needsFetchPolyfill) {
203-
const fetchNode = debug(new Rollup(path.dirname(path.dirname(require.resolve('whatwg-fetch'))), {
204-
rollup: {
205-
input: 'fetch.js',
206-
output: {
207-
file: 'fetch.js',
208-
name: 'WHATWGFetch',
209-
format: 'iife'
234+
const fetchNode = debug(
235+
new Rollup(
236+
path.dirname(path.dirname(require.resolve('whatwg-fetch'))),
237+
{
238+
rollup: {
239+
input: 'fetch.js',
240+
output: {
241+
file: 'fetch.js',
242+
name: 'WHATWGFetch',
243+
format: 'iife',
244+
},
245+
},
210246
}
211-
}
212-
}), 'whatwg-fetch');
247+
),
248+
'whatwg-fetch'
249+
);
213250

214251
inputNodes.push(fetchNode);
215252
inputFiles.push('fetch.js');
216253
}
217254

218-
const polyfillNode = debug(concat(new MergeTrees(inputNodes), {
219-
inputFiles,
220-
allowNone: true,
221-
outputFile: 'ember-fetch.js',
222-
sourceMapConfig: { enabled: false }
223-
}), 'after-concat');
255+
const polyfillNode = debug(
256+
concat(new MergeTrees(inputNodes), {
257+
inputFiles,
258+
allowNone: true,
259+
outputFile: 'ember-fetch.js',
260+
sourceMapConfig: { enabled: false },
261+
}),
262+
'after-concat'
263+
);
224264

225265
const moduleHeader = this._getModuleHeader(options);
226266

@@ -231,7 +271,7 @@ module.exports = {
231271
moduleBody: content,
232272
};
233273
}),
234-
"browser-fetch"
274+
'browser-fetch'
235275
);
236276
},
237277

@@ -286,8 +326,12 @@ define('fetch', ['exports'], function(exports) {
286326
let app;
287327
let current = this;
288328
do {
289-
app = current.app || this;
290-
} while (current.parent && current.parent.parent && (current = current.parent));
329+
app = current.app || this;
330+
} while (
331+
current.parent &&
332+
current.parent.parent &&
333+
(current = current.parent)
334+
);
291335

292336
return app;
293337
}

public/fetch-fastboot.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* globals define FastBoot */
2-
define('fetch', ['exports'], function(exports) {
2+
define('fetch', ['exports'], function (exports) {
33
var httpRegex = /^https?:\/\//;
44
var protocolRelativeRegex = /^\/\//;
55

@@ -10,10 +10,13 @@ define('fetch', ['exports'], function(exports) {
1010

1111
function parseRequest(request) {
1212
if (request === null) {
13-
throw new Error('Trying to fetch with relative url but ember-fetch hasn\'t finished loading FastBootInfo, see details at https://github.com/ember-cli/ember-fetch#relative-url');
13+
throw new Error(
14+
"Trying to fetch with relative url but ember-fetch hasn't finished loading FastBootInfo, see details at https://github.com/ember-cli/ember-fetch#relative-url"
15+
);
1416
}
1517
// Old Prember version is not sending protocol
16-
const protocol = request.protocol === 'undefined:' ? 'http:' : request.protocol;
18+
const protocol =
19+
request.protocol === 'undefined:' ? 'http:' : request.protocol;
1720
return [request.get('host'), protocol];
1821
}
1922

@@ -26,7 +29,7 @@ define('fetch', ['exports'], function(exports) {
2629
*/
2730
function buildAbsoluteUrl(url) {
2831
if (protocolRelativeRegex.test(url)) {
29-
let [host,] = parseRequest(REQUEST);
32+
let [host] = parseRequest(REQUEST);
3033
url = host + url;
3134
} else if (!httpRegex.test(url)) {
3235
let [host, protocol] = parseRequest(REQUEST);
@@ -75,7 +78,7 @@ define('fetch', ['exports'], function(exports) {
7578
*/
7679
exports.setupFastboot = function setupFastboot(fastBootRequest) {
7780
REQUEST = fastBootRequest;
78-
}
81+
};
7982
exports.Request = FastBootRequest;
8083
exports.Headers = nodeFetch.Headers;
8184
exports.Response = nodeFetch.Response;

0 commit comments

Comments
 (0)