Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav0 committed May 13, 2023
1 parent 89ecb72 commit e34e3e1
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 215 deletions.
2 changes: 1 addition & 1 deletion packages/fastboot/dev/memory-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ session.connect();

let file;
// uses whatever the "current" file is
session.on('HeapProfiler.addHeapSnapshotChunk', (m) => {
session.on('HeapProfiler.addHeapSnapshotChunk', m => {
fs.writeSync(file, m.params.chunk);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/fastboot/src/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class EmberApp {
debug('files evaluated');

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

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

function escapeJSONString(string) {
return string.replace(JSON_ESCAPE_REGEXP, function (match) {
return string.replace(JSON_ESCAPE_REGEXP, function(match) {
return JSON_ESCAPE[match];
});
}
Expand All @@ -432,7 +432,7 @@ function registerFastBootInfo(info, instance) {
}

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

return new vm.Script(source, { filename: filePath });
Expand Down
2 changes: 1 addition & 1 deletion packages/fastboot/src/fastboot-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FastBootRequest {
}

var host = this.headers.get('host');
var matchFound = this.hostWhitelist.some(function (entry) {
var matchFound = this.hostWhitelist.some(function(entry) {
if (entry[0] === '/' && entry.slice(-1) === '/') {
var regexp = new RegExp(entry.slice(1, -1));
return regexp.test(host);
Expand Down
6 changes: 3 additions & 3 deletions packages/fastboot/src/fastboot-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) {
}
}

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

if (isLegacyWhitelist) {
Expand All @@ -161,7 +161,7 @@ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) {
}
});

return function (moduleName) {
return function(moduleName) {
let packageName = getPackageName(moduleName);
let isWhitelisted = whitelist.indexOf(packageName) > -1;

Expand Down
2 changes: 1 addition & 1 deletion packages/fastboot/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FastBoot {
console.warn(
'[DEPRECATION] Instantiating `fastboot` with a `sandboxGlobals` option has been deprecated. Please migrate to specifying `buildSandboxGlobals` instead.'
);
buildSandboxGlobals = (globals) => Object.assign({}, globals, options.sandboxGlobals);
buildSandboxGlobals = globals => Object.assign({}, globals, options.sandboxGlobals);
}

this.buildSandboxGlobals = buildSandboxGlobals;
Expand Down
18 changes: 9 additions & 9 deletions packages/fastboot/src/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Result {
this._body,
this._bodyAttributes,
this._bodyClass
).then((html) => {
).then(html => {
let docParts = html.match(HTML_HEAD_REGEX);
if (!docParts || docParts.length === 1) {
return [html];
Expand All @@ -97,7 +97,7 @@ class Result {
let [plainBody, ...shoeboxes] = body.split(SHOEBOX_TAG_PATTERN);

let chunks = [head, plainBody].concat(
shoeboxes.map((shoebox) => `${SHOEBOX_TAG_PATTERN}${shoebox}`)
shoeboxes.map(shoebox => `${SHOEBOX_TAG_PATTERN}${shoebox}`)
);

return chunks;
Expand Down Expand Up @@ -203,10 +203,10 @@ function extractExtraAttributes(element) {
let klass;
let attributes;
if (element.attributes.length > 0) {
let elementClass = element.attributes.find((attr) => attr.name === 'class');
let elementClass = element.attributes.find(attr => attr.name === 'class');
if (elementClass) {
klass = elementClass;
let otherAttrs = element.attributes.filter((attr) => attr.name !== 'class');
let otherAttrs = element.attributes.filter(attr => attr.name !== 'class');
if (otherAttrs.length > 0) {
attributes = HTMLSerializer.attributes(otherAttrs);
} else {
Expand All @@ -229,9 +229,9 @@ function missingTag(tag) {
}

function addClass(html, regex, newClass) {
return html.replace(regex, function (_, tag, attributes) {
return html.replace(regex, function(_, tag, attributes) {
if (/class="([^"]*)"/i.test(attributes)) {
attributes = attributes.replace(/class="([^"]*)"/i, function (_, klass) {
attributes = attributes.replace(/class="([^"]*)"/i, function(_, klass) {
return `class="${klass} ${newClass}"`;
});
} else {
Expand All @@ -256,7 +256,7 @@ async function insertIntoIndexHTML(
let isBodyReplaced = false;
let isHeadReplaced = false;

html = html.replace(/<!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function (match, tag) {
html = html.replace(/<!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function(match, tag) {
if (tag === 'HEAD' && head && !isHeadReplaced) {
isHeadReplaced = true;
return head;
Expand All @@ -271,7 +271,7 @@ async function insertIntoIndexHTML(
html = addClass(html, /<(html)(.*)>/i, htmlClass.value);
}
if (htmlAttributes) {
html = html.replace(/<html[^>]*/i, function (match) {
html = html.replace(/<html[^>]*/i, function(match) {
return match + ' ' + htmlAttributes;
});
}
Expand All @@ -280,7 +280,7 @@ async function insertIntoIndexHTML(
html = addClass(html, /<(body)(.*)>/i, bodyClass.value);
}
if (bodyAttributes) {
html = html.replace(/<body[^>]*/i, function (match) {
html = html.replace(/<body[^>]*/i, function(match) {
return match + ' ' + bodyAttributes;
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fastboot/src/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ module.exports = class Sandbox {
buildWrappedConsole() {
let wrappedConsole = Object.create(console);

wrappedConsole.error = function (...args) {
wrappedConsole.error = function(...args) {
console.error.apply(
console,
args.map(function (a) {
args.map(function(a) {
return typeof a === 'string' ? chalk.red(a) : a;
})
);
Expand Down
8 changes: 4 additions & 4 deletions packages/fastboot/test/fastboot-dependencies-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const expect = require('chai').expect;
const fixture = require('./helpers/fixture-path');
const FastBoot = require('./../src/index');

describe('FastBoot with dependencies', function () {
it('it works with dependencies', function () {
describe('FastBoot with dependencies', function() {
it('it works with dependencies', function() {
var fastboot = new FastBoot({
distPath: fixture('app-with-dependencies'),
});

return fastboot
.visit('/')
.then((r) => r.html())
.then((html) => {
.then(r => r.html())
.then(html => {
expect(html).to.match(/https:\/\/emberjs.com/);
expect(html).to.match(/FOO/);
expect(html).to.match(/BAR/);
Expand Down
30 changes: 15 additions & 15 deletions packages/fastboot/test/fastboot-headers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
var expect = require('chai').expect;
var FastBootHeaders = require('./../src/fastboot-headers.js');

describe('FastBootHeaders', function () {
it('lower normalizes the headers to lowercase', function () {
describe('FastBootHeaders', function() {
it('lower normalizes the headers to lowercase', function() {
var headers = {
'X-Test-Header': 'value1, value2',
};
Expand All @@ -13,7 +13,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']);
});

it('returns an array from getAll when header value is string', function () {
it('returns an array from getAll when header value is string', function() {
var headers = {
'x-test-header': 'value1, value2',
};
Expand All @@ -22,7 +22,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']);
});

it('returns an array of header values from getAll, regardless of header name casing', function () {
it('returns an array of header values from getAll, regardless of header name casing', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand All @@ -32,7 +32,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('x-test-header')).to.deep.equal(['value1', 'value2']);
});

it('returns an emtpy array when a header is not present', function () {
it('returns an emtpy array when a header is not present', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand All @@ -42,7 +42,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('host')).to.deep.equal([]);
});

it('returns the first value when using get, regardless of case', function () {
it('returns the first value when using get, regardless of case', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand All @@ -52,7 +52,7 @@ describe('FastBootHeaders', function () {
expect(headers.get('x-test-header')).to.equal('value1');
});

it('returns null when using get when a header is not present', function () {
it('returns null when using get when a header is not present', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand All @@ -62,7 +62,7 @@ describe('FastBootHeaders', function () {
expect(headers.get('host')).to.be.null;
});

it('returns whether or not a header is present via has, regardless of casing', function () {
it('returns whether or not a header is present via has, regardless of casing', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand All @@ -74,7 +74,7 @@ describe('FastBootHeaders', function () {
expect(headers.has('host')).to.be.false;
});

it('appends entries onto a header, regardless of casing', function () {
it('appends entries onto a header, regardless of casing', function() {
var headers = new FastBootHeaders();

expect(headers.has('x-foo')).to.be.false;
Expand All @@ -87,7 +87,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('x-foo')).to.deep.equal(['bar', 'baz']);
});

it('deletes entries onto a header, regardless of casing', function () {
it('deletes entries onto a header, regardless of casing', function() {
var headers = new FastBootHeaders();

headers.append('X-Foo', 'bar');
Expand All @@ -97,7 +97,7 @@ describe('FastBootHeaders', function () {
expect(headers.has('x-foo')).to.be.false;
});

it('returns an iterator for the header/value pairs when calling entries', function () {
it('returns an iterator for the header/value pairs when calling entries', function() {
var headers = new FastBootHeaders();

headers.append('X-Foo', 'foo');
Expand All @@ -111,7 +111,7 @@ describe('FastBootHeaders', function () {
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});

it('returns an iterator for keys containing all the keys', function () {
it('returns an iterator for keys containing all the keys', function() {
var headers = new FastBootHeaders();

headers.append('X-Foo', 'foo');
Expand All @@ -125,7 +125,7 @@ describe('FastBootHeaders', function () {
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});

it('sets a header, overwriting existing values, regardless of casing', function () {
it('sets a header, overwriting existing values, regardless of casing', function() {
var headers = new FastBootHeaders();

expect(headers.getAll('x-foo')).to.deep.equal([]);
Expand All @@ -141,7 +141,7 @@ describe('FastBootHeaders', function () {
expect(headers.getAll('x-bar')).to.deep.equal(['baz']);
});

it('returns an iterator for values containing all the values', function () {
it('returns an iterator for values containing all the values', function() {
var headers = new FastBootHeaders();

headers.append('X-Foo', 'foo');
Expand All @@ -155,7 +155,7 @@ describe('FastBootHeaders', function () {
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});

it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () {
it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function() {
var headers = {
'x-test-header': ['value1', 'value2'],
};
Expand Down
16 changes: 8 additions & 8 deletions packages/fastboot/test/fastboot-info-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var FastBootResponse = require('./../src/fastboot-response.js');
var FastBootRequest = require('./../src/fastboot-request.js');

function delayFor(ms) {
let promise = new Promise((resolve) => {
let promise = new Promise(resolve => {
setTimeout(() => {
resolve();
}, ms);
Expand All @@ -13,7 +13,7 @@ function delayFor(ms) {
return promise;
}

describe('FastBootInfo', function () {
describe('FastBootInfo', function() {
var response;
var request;
var fastbootInfo;
Expand All @@ -22,33 +22,33 @@ describe('FastBootInfo', function () {
baz: 'apple',
};

beforeEach(function () {
beforeEach(function() {
response = {};
request = {
cookie: '',
protocol: 'http',
headers: {},
get: function () {
get: function() {
return this.cookie;
},
};

fastbootInfo = new FastBootInfo(request, response, { metadata });
});

it('has a FastBootRequest', function () {
it('has a FastBootRequest', function() {
expect(fastbootInfo.request).to.be.an.instanceOf(FastBootRequest);
});

it('has a FastBootResponse', function () {
it('has a FastBootResponse', function() {
expect(fastbootInfo.response).to.be.an.instanceOf(FastBootResponse);
});

it('has metadata', function () {
it('has metadata', function() {
expect(fastbootInfo.metadata).to.deep.equal(metadata);
});

it('can use deferRendering', async function () {
it('can use deferRendering', async function() {
let steps = [];

steps.push('deferRendering called');
Expand Down
Loading

0 comments on commit e34e3e1

Please sign in to comment.