Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: transform object shorthand #750

Merged
merged 2 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/templates/scripts/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Api (platform, platformRootDir, events) {
defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
pbxproj: path.join(this.root, xcodeProjDir, 'project.pbxproj'),
xcodeProjDir: path.join(this.root, xcodeProjDir),
xcodeCordovaProj: xcodeCordovaProj
xcodeCordovaProj
};
}

Expand Down Expand Up @@ -352,7 +352,7 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods, installOp
if (obj.declarations[key] === 'true') {
const declaration = Podfile.proofDeclaration(key);
const podJson = {
declaration: declaration
declaration
};
const val = podsjsonFile.getDeclaration(declaration);
if (val) {
Expand Down Expand Up @@ -470,7 +470,7 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods, uninst
if (obj.declarations[key] === 'true') {
const declaration = Podfile.proofDeclaration(key);
const podJson = {
declaration: declaration
declaration
};
const val = podsjsonFile.getDeclaration(declaration);
if (val) {
Expand Down
12 changes: 6 additions & 6 deletions bin/templates/scripts/cordova/lib/BridgingHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BridgingHeader.prototype.__parseForBridgingHeader = function (text) {
case 'comment':
if (i + 1 < text.length && text[i] === '*' && text[i + 1] === '/') {
i += 2;
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
type = 'code';
start = i;
} else {
Expand All @@ -79,7 +79,7 @@ BridgingHeader.prototype.__parseForBridgingHeader = function (text) {
case 'line-comment':
if (i < text.length && text[i] === '\n') {
i += 1;
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
type = 'code';
start = i;
} else {
Expand All @@ -90,19 +90,19 @@ BridgingHeader.prototype.__parseForBridgingHeader = function (text) {
default:
if (i + 1 < text.length && text[i] === '/' && text[i + 1] === '*') { // comment
if (start < i) {
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
}
type = 'comment';
start = i;
} else if (i + 1 < text.length && text[i] === '/' && text[i + 1] === '/') { // line comment
if (start < i) {
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
}
type = 'line-comment';
start = i;
} else if (i < text.length && text[i] === '\n') {
i += 1;
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
start = i;
} else {
i += 1;
Expand All @@ -111,7 +111,7 @@ BridgingHeader.prototype.__parseForBridgingHeader = function (text) {
}
}
if (start < i) {
list.push({ type: type, code: text.slice(start, i) });
list.push({ type, code: text.slice(start, i) });
}
return list;
};
Expand Down
4 changes: 2 additions & 2 deletions bin/templates/scripts/cordova/lib/Podfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ Podfile.prototype.addSpec = function (name, spec) {

if (typeof spec === 'string') {
if (spec.startsWith(':')) {
spec = { name: name, options: spec };
spec = { name, options: spec };
} else {
spec = { name: name, spec: spec };
spec = { name, spec };
}
}

Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/check_reqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
return versions.get_tool_version(tool).then(version => {
version = version.trim();
return versions.compareVersions(version, minVersion) >= 0
? Q.resolve({ version: version })
? Q.resolve({ version })
: Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion +
' or greater, you have version ' + version + '. ' + (message || ''));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const handlers = {
events.emit('verbose', '"Embed Frameworks" Build Phase (Embedded Binaries) does not exist, creating it.');
project.xcode.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Embed Frameworks', null, 'frameworks');
}
const opt = { customFramework: true, embed: embed, link: link, sign: true };
const opt = { customFramework: true, embed, link, sign: true };
events.emit('verbose', util.format('Adding custom framework to project... %s -> %s', src, JSON.stringify(opt)));
project.xcode.addFramework(project_relative, opt);
events.emit('verbose', util.format('Custom framework added to project. %s -> %s', src, JSON.stringify(opt)));
Expand Down
7 changes: 1 addition & 6 deletions bin/templates/scripts/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,12 +606,7 @@ function mapLaunchStoryboardContents (splashScreens, launchStoryboardImagesDir)
scalesForIdiom[idiom].forEach(scale => {
sizes.forEach(width => {
sizes.forEach(height => {
const item = {
idiom: idiom,
scale: scale,
width: width,
height: height
};
const item = { idiom, scale, width, height };

/* examples of the search pattern:
* scale ~ idiom ~ width height
Expand Down
4 changes: 2 additions & 2 deletions bin/templates/scripts/cordova/lib/projectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function parseProjectFile (locations) {
getUninstaller: function (name) {
return pluginHandlers.getUninstaller(name);
},
frameworks: frameworks
frameworks
};
return cachedProjectFiles[project_dir];
}
Expand All @@ -97,7 +97,7 @@ function purgeProjectFileCache (project_dir) {

module.exports = {
parse: parseProjectFile,
purgeProjectFileCache: purgeProjectFileCache
purgeProjectFileCache
};

xcode.project.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) {
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/unit/BridgingHeader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('unit tests for BridgingHeader module', () => {
existsSyncSpy.and.returnValue(true);
readFileSyncSpy.and.callFake((read_path, charset) => bridgingHeaderFileContent);
writeFileSyncSpy.and.callFake((write_path, text, charset) => {
result_json = { write_path: write_path, text: text, charset: charset };
result_json = { write_path, text, charset };
});

let bridgingHeader = new BridgingHeader(dummy_path);
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('unit tests for BridgingHeader module', () => {
readFileSyncSpy.and.callFake((read_path, charset) => bridgingHeaderFileContent);
writeFileSyncSpy.and.callFake((write_path, text, charset) => {
bridgingHeaderFileContent = text;
result_json = { write_path: write_path, text: text, charset: charset };
result_json = { write_path, text, charset };
});

let bridgingHeader = new BridgingHeader(dummy_path);
Expand Down
6 changes: 1 addition & 5 deletions tests/spec/unit/prepare.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ describe('prepare', () => {

describe('launch storyboard feature (CB-9762)', () => {
function makeSplashScreenEntry (src, width, height) {
return {
src: src,
width: width,
height: height
};
return { src, width, height };
}

const noLaunchStoryboardImages = [];
Expand Down