Skip to content

Commit

Permalink
style(js): Update javascript style to match latest standard
Browse files Browse the repository at this point in the history
  • Loading branch information
jstoffan committed Sep 3, 2019
1 parent 65ca616 commit 956b2f7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 45 deletions.
5 changes: 3 additions & 2 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const languages = isProd ? locales : ['en-US']; // Only 1 language needed for de

/* eslint-disable key-spacing, require-jsdoc */
function updateConfig(conf, language, index) {
const config = Object.assign(conf, {
const config = {
...conf,
entry: {
annotations: ['box-annotations'],
preview: [`${lib}/Preview.js`],
Expand Down Expand Up @@ -64,7 +65,7 @@ function updateConfig(conf, language, index) {
inline: true,
port: 8000,
},
});
};

if (index === 0) {
config.plugins.push(new RsyncPlugin(thirdParty, staticFolder));
Expand Down
5 changes: 3 additions & 2 deletions build/webpack.karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ const commonConfig = require('./webpack.common.config');

const baseConfig = commonConfig('en-US');

const config = Object.assign(baseConfig, {
const config = {
...baseConfig,
mode: 'development',
resolve: {
alias: {
sinon: 'sinon/pkg/sinon',
},
},
});
};

if (isDebug) {
config.devtool = 'inline-source-map';
Expand Down
46 changes: 20 additions & 26 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Preview extends EventEmitter {
// Token can also be null or undefined for offline use case.
// But it cannot be a random object.
if (token === null || typeof token !== 'object') {
this.previewOptions = Object.assign({}, options, { token });
this.previewOptions = { ...options, token };
} else {
throw new Error('Bad access token!');
}
Expand Down Expand Up @@ -331,9 +331,7 @@ class Preview extends EventEmitter {
fileIds.push(fileOrId.toString());
} else if (fileOrId && typeof fileOrId === 'object' && isValidFileId(fileOrId.id)) {
// Possible well-formed file object found in the collection
const wellFormedFileObj = Object.assign({}, fileOrId, {
id: fileOrId.id.toString(),
});
const wellFormedFileObj = { ...fileOrId, id: fileOrId.id.toString() };
fileIds.push(wellFormedFileObj.id);
files.push(wellFormedFileObj);
} else {
Expand Down Expand Up @@ -537,7 +535,7 @@ class Preview extends EventEmitter {
}

// This allows the browser to download representation content
const params = Object.assign({ response_content_disposition_type: 'attachment' }, queryParams);
const params = { response_content_disposition_type: 'attachment', ...queryParams };
const downloadUrl = appendQueryParams(
this.viewer.createContentUrlWithAuthParams(contentUrlTemplate, this.viewer.getAssetPath()),
params,
Expand Down Expand Up @@ -869,7 +867,7 @@ class Preview extends EventEmitter {
* @return {void}
*/
parseOptions(previewOptions) {
const options = Object.assign({}, previewOptions);
const options = { ...previewOptions };

// Reset all options
this.options = {};
Expand Down Expand Up @@ -986,14 +984,14 @@ class Preview extends EventEmitter {
* @return {Object} combined options
*/
createViewerOptions(moreOptions) {
return cloneDeep(
Object.assign({}, this.options, moreOptions, {
api: this.api,
location: this.location,
cache: this.cache,
ui: this.ui,
}),
);
return cloneDeep({
...this.options,
...moreOptions,
api: this.api,
location: this.location,
cache: this.cache,
ui: this.ui,
});
}

/**
Expand Down Expand Up @@ -1023,12 +1021,10 @@ class Preview extends EventEmitter {
*/
loadFromServer() {
const { apiHost, previewWMPref, queryParams } = this.options;
const params = Object.assign(
{
watermark_preference: convertWatermarkPref(previewWMPref),
},
queryParams,
);
const params = {
watermark_preference: convertWatermarkPref(previewWMPref),
...queryParams,
};

const fileVersionId = this.getFileOption(this.file.id, FILE_OPTION_FILE_VERSION_ID) || '';

Expand Down Expand Up @@ -1639,12 +1635,10 @@ class Preview extends EventEmitter {
*/
prefetchNextFiles() {
const { apiHost, previewWMPref, queryParams, skipServerUpdate } = this.options;
const params = Object.assign(
{
watermark_preference: convertWatermarkPref(previewWMPref),
},
queryParams,
);
const params = {
watermark_preference: convertWatermarkPref(previewWMPref),
...queryParams,
};

// Don't bother prefetching when there aren't more files or we need to skip server update
if (this.collection.length < 2 || skipServerUpdate) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__tests__/Preview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('lib/Preview', () => {

preview.show(file, token, options);

expect(stubs.parseOptions).to.be.calledWith(Object.assign({}, options, { token }));
expect(stubs.parseOptions).to.be.calledWith({ ...options, token });
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function checkFileValid(file) {
* @return {Object} File version object normalized to a file object from the API
*/
export function normalizeFileVersion(fileVersion, fileId) {
const file = Object.assign({}, fileVersion);
const file = { ...fileVersion };
file.id = fileId; // ID returned by file versions API is file version ID, so we need to set to file ID
file.shared_link = {}; // File versions API does not return shared link object
file.file_version = {
Expand Down
16 changes: 8 additions & 8 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,14 +1121,14 @@ class BaseViewer extends EventEmitter {
whoDrew: __('annotation_who_drew'),
};

return cloneDeep(
Object.assign({}, this.options, moreOptions, {
isMobile: this.isMobile,
hasTouch: this.hasTouch,
locale: this.options.location.locale,
localizedStrings,
}),
);
return cloneDeep({
...this.options,
...moreOptions,
isMobile: this.isMobile,
hasTouch: this.hasTouch,
locale: this.options.location.locale,
localizedStrings,
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/lib/viewers/box3d/model3d/Model3DSettingsPullup.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Model3DSettingsPullup extends EventEmitter {

// Render Mode dropdown
const renderPanelData = RENDER_MODES.map(entry => {
const entryCopy = Object.assign({}, entry);
const entryCopy = { ...entry };
this.convertToValidCallback(entryCopy);
return entryCopy;
});
Expand Down Expand Up @@ -181,7 +181,7 @@ class Model3DSettingsPullup extends EventEmitter {

// Camera Projection dropdown
const projectionPanelData = PROJECTION_MODES.map(entry => {
const entryCopy = Object.assign({}, entry);
const entryCopy = { ...entry };
this.convertToValidCallback(entryCopy);
return entryCopy;
});
Expand Down
6 changes: 3 additions & 3 deletions src/lib/viewers/office/__tests__/OfficeLoader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe('lib/viewers/office/OfficeLoader', () => {

describe('determineViewer()', () => {
const fakeFiles = [
Object.assign({}, fakeFileTemplate, { extension: 'xlsx' }),
Object.assign({}, fakeFileTemplate, { extension: 'xlsm' }),
Object.assign({}, fakeFileTemplate, { extension: 'xlsb' }),
{ ...fakeFileTemplate, extension: 'xlsx' },
{ ...fakeFileTemplate, extension: 'xlsm' },
{ ...fakeFileTemplate, extension: 'xlsb' },
];

fakeFiles.forEach(fakeFile => {
Expand Down

0 comments on commit 956b2f7

Please sign in to comment.