Repository: cordova-lib
Updated Branches:
refs/heads/master 6f7a67a78 -> 8f880f5d3
JSHint fixes
Add the following JSHint config to several files that already had some inline
JSHint config. This is part of figuring out the optimal jshint config for us.
/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
indent:4, unused:vars, latedef:nofunc
*/
In some files tweaks to this config were needed. I added them on a separate
line. For example, the tweaks in plugman/install.js are:
laxcomma:true, sub:true, expr:true, asi:true, quotmark:false
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/8f880f5d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/8f880f5d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/8f880f5d
Branch: refs/heads/master
Commit: 8f880f5d3128e17c8a8f5a4c68798e11f9342172
Parents: 6f7a67a
Author: Mark Koudritsky <[email protected]>
Authored: Tue Jun 17 15:44:09 2014 -0400
Committer: Mark Koudritsky <[email protected]>
Committed: Tue Jun 17 15:44:09 2014 -0400
----------------------------------------------------------------------
cordova-lib/src/PluginInfo.js | 5 ++-
cordova-lib/src/cordova/lazy_load.js | 5 ++-
cordova-lib/src/cordova/platform.js | 8 +++-
cordova-lib/src/cordova/util.js | 8 ++--
cordova-lib/src/plugman/install.js | 11 +++--
cordova-lib/src/plugman/prepare.js | 50 +++++++++++----------
cordova-lib/src/plugman/util/config-changes.js | 17 ++++---
7 files changed, 63 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/PluginInfo.js b/cordova-lib/src/PluginInfo.js
index 64730cd..9b8f43a 100644
--- a/cordova-lib/src/PluginInfo.js
+++ b/cordova-lib/src/PluginInfo.js
@@ -25,7 +25,10 @@ is compatible with a given engine version.
TODO (kamrik): refactor this to use no fs sync fnctions and return promises.
*/
-/* jshint node:true, laxcomma:true, laxbreak:true, sub:true, strict: false */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc,
+ sub:true, laxcomma:true, laxbreak:true
+*/
var path = require('path')
, fs = require('fs')
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/cordova/lazy_load.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/lazy_load.js
b/cordova-lib/src/cordova/lazy_load.js
index 8c9da20..c157cc2 100644
--- a/cordova-lib/src/cordova/lazy_load.js
+++ b/cordova-lib/src/cordova/lazy_load.js
@@ -17,7 +17,10 @@
under the License.
*/
-/* jshint node:true, laxcomma:true, strict:false, trailing:true, unused:vars */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc
+*/
+
// The URL:true below prevents jshint error "Redefinition or 'URL'."
/* globals URL:true */
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js
b/cordova-lib/src/cordova/platform.js
index 38e1bfc..eefba91 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -17,7 +17,11 @@
under the License.
*/
-/* jshint node:true, laxcomma:true, strict:false, trailing:true, unused:vars */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc
+*/
+
+
var config = require('./config'),
cordova = require('./cordova'),
@@ -188,7 +192,7 @@ function check(hooks, projectRoot) {
platforms_on_fs = cordova_util.listPlatforms(projectRoot),
scratch = path.join(os.tmpdir(), 'cordova-platform-check-' +
Date.now()),
listeners = events._events;
- events._events = {};
+ events._events = {};
var result = Q.defer();
cordova.raw.create(scratch)
.then(function () {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js
index 217d7f1..d4ee389 100644
--- a/cordova-lib/src/cordova/util.js
+++ b/cordova-lib/src/cordova/util.js
@@ -17,7 +17,9 @@
under the License.
*/
-/* jshint node:true, laxcomma:true, strict:false, trailing:true, unused:vars */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc
+*/
var fs = require('fs'),
path = require('path'),
@@ -141,8 +143,8 @@ function findPlugins(pluginPath) {
if (fs.existsSync(pluginPath)) {
plugins = fs.readdirSync(pluginPath).filter(function (fileName) {
- stats = fs.statSync(path.join(pluginPath, fileName));
- return fileName != '.svn' && fileName != 'CVS' &&
stats.isDirectory();
+ stats = fs.statSync(path.join(pluginPath, fileName));
+ return fileName != '.svn' && fileName != 'CVS' &&
stats.isDirectory();
});
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js
b/cordova-lib/src/plugman/install.js
index 4ad77f4..edd5932 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -16,13 +16,16 @@
specific language governing permissions and limitations
under the License.
*/
-/* jshint node:true, asi:true, laxcomma:true, sub:true, expr:true, unused:vars
*/
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc,
+ laxcomma:true, sub:true, expr:true, asi:true, quotmark:false
+*/
var path = require('path'),
fs = require('fs'),
action_stack = require('./util/action-stack'),
dep_graph = require('dep-graph'),
- elementtree = require('elementtree'),
child_process = require('child_process'),
semver = require('semver'),
config_changes = require('./util/config-changes'),
@@ -254,7 +257,8 @@ function isPluginInstalled(plugins_dir, platform,
plugin_id) {
// possible options: cli_variables, www_dir, is_top_level
// Returns a promise.
-var runInstall = module.exports.runInstall = function runInstall(actions,
platform, project_dir, plugin_dir, plugins_dir, options) {
+module.exports.runInstall = runInstall;
+function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir,
options) {
var pluginInfo = new PluginInfo.PluginInfo(plugin_dir)
, filtered_variables = {};
@@ -504,7 +508,6 @@ function handleInstall(actions, pluginInfo, platform,
project_dir, plugins_dir,
events.emit('verbose', 'Install start for "' + pluginInfo.id + '" on ' +
platform + '.');
var handler = platform_modules[platform];
- www_dir = options.www_dir || handler.www_dir(project_dir);
var platformTag = pluginInfo._et.find('./platform[@name="'+platform+'"]');
if ( pluginInfo.hasPlatformSection(platform) ) {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/plugman/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare.js
b/cordova-lib/src/plugman/prepare.js
index 74d590c..a4d3c79 100644
--- a/cordova-lib/src/plugman/prepare.js
+++ b/cordova-lib/src/plugman/prepare.js
@@ -17,7 +17,10 @@
under the License.
*/
-/* jshint node:true */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc,
+ expr:true, quotmark:false
+*/
var platform_modules = require('./platforms'),
path = require('path'),
@@ -25,13 +28,12 @@ var platform_modules = require('./platforms'),
xml_helpers = require('../util/xml-helpers'),
wp8 = require('./platforms/wp8'),
windows8 = require('./platforms/windows8'),
- common = require('./platforms/common');
+ common = require('./platforms/common'),
fs = require('fs'),
shell = require('shelljs'),
util = require('util'),
events = require('../events'),
- plugman = require('./plugman'),
- et = require('elementtree');
+ plugman = require('./plugman');
// Called on --prepare.
// Sets up each plugin's Javascript code to be loaded properly.
@@ -74,19 +76,21 @@ module.exports = function handlePrepare(project_dir,
platform, plugins_dir, www_
// for windows phone platform we need to add all www resources to the
.csproj file
// first we need to remove them all to prevent duplicates
var wp_csproj;
+ var item_groups;
+ var i, j, k, l, file, files, group, new_group;
if(platform == 'wp8') {
wp_csproj = wp8.parseProjectFile(project_dir);
- var item_groups = wp_csproj.xml.findall('ItemGroup');
- for (var i = 0, l = item_groups.length; i < l; i++) {
- var group = item_groups[i];
- var files = group.findall('Content');
- for (var j = 0, k = files.length; j < k; j++) {
- var file = files[j];
- if (file.attrib.Include.substr(0,11) == "www\\plugins" ||
file.attrib.Include == "www\\cordova_plugins.js") {
+ item_groups = wp_csproj.xml.findall('ItemGroup');
+ for (i = 0, l = item_groups.length; i < l; i++) {
+ group = item_groups[i];
+ files = group.findall('Content');
+ for (j = 0, k = files.length; j < k; j++) {
+ file = files[j];
+ if (file.attrib.Include.substr(0,11) == 'www\\plugins' ||
file.attrib.Include == 'www\\cordova_plugins.js') {
// remove file reference
group.remove(0, file);
// remove ItemGroup if empty
- var new_group = group.findall('Content');
+ new_group = group.findall('Content');
if(new_group.length < 1) {
wp_csproj.xml.getroot().remove(0, group);
}
@@ -94,19 +98,19 @@ module.exports = function handlePrepare(project_dir,
platform, plugins_dir, www_
}
}
}
- else if(platform == "windows8") {
+ else if(platform == 'windows8') {
wp_csproj = windows8.parseProjectFile(project_dir);
- var item_groups = wp_csproj.xml.findall('ItemGroup');
- for (var i = 0, l = item_groups.length; i < l; i++) {
- var group = item_groups[i];
- var files = group.findall('Content');
- for (var j = 0, k = files.length; j < k; j++) {
- var file = files[j];
- if (file.attrib.Include.substr(0,11) == "www\\plugins" ||
file.attrib.Include == "www\\cordova_plugins.js") {
+ item_groups = wp_csproj.xml.findall('ItemGroup');
+ for (i = 0, l = item_groups.length; i < l; i++) {
+ group = item_groups[i];
+ files = group.findall('Content');
+ for (j = 0, k = files.length; j < k; j++) {
+ file = files[j];
+ if (file.attrib.Include.substr(0,11) == 'www\\plugins' ||
file.attrib.Include == 'www\\cordova_plugins.js') {
// remove file reference
group.remove(0, file);
// remove ItemGroup if empty
- var new_group = group.findall('Content');
+ new_group = group.findall('Content');
if(new_group.length < 1) {
wp_csproj.xml.getroot().remove(0, group);
}
@@ -180,7 +184,7 @@ module.exports = function handlePrepare(project_dir,
platform, plugins_dir, www_
var scriptContent = fs.readFileSync(path.join(pluginDir, fsPath),
'utf-8').replace(/^\ufeff/, ''); // Window BOM
scriptContent = 'cordova.define("' + moduleName + '",
function(require, exports, module) { ' + scriptContent + '\n});\n';
fs.writeFileSync(path.join(platformPluginsDir, plugin_id, fsPath),
scriptContent, 'utf-8');
- if(platform == 'wp8' || platform == "windows8") {
+ if(platform == 'wp8' || platform == 'windows8') {
wp_csproj.addSourceFile(path.join('www', 'plugins', plugin_id,
fsPath));
}
@@ -224,7 +228,7 @@ module.exports = function handlePrepare(project_dir,
platform, plugins_dir, www_
events.emit('verbose', 'Writing out cordova_plugins.js...');
fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents,
'utf-8');
- if(platform == 'wp8' || platform == "windows8") {
+ if(platform == 'wp8' || platform == 'windows8') {
wp_csproj.addSourceFile(path.join('www', 'cordova_plugins.js'));
wp_csproj.write();
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f880f5d/cordova-lib/src/plugman/util/config-changes.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/config-changes.js
b/cordova-lib/src/plugman/util/config-changes.js
index 55aa384..4acead9 100644
--- a/cordova-lib/src/plugman/util/config-changes.js
+++ b/cordova-lib/src/plugman/util/config-changes.js
@@ -30,7 +30,10 @@
* reference counts.
*/
-/* jshint node:true, sub:true, unused:true, indent:4 */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+ indent:4, unused:vars, latedef:nofunc,
+ sub:true
+*/
var fs = require('fs'),
path = require('path'),
@@ -80,7 +83,7 @@ exports.process = function(plugins_dir, project_dir,
platform) {
exports.get_munge_change = function(munge, keys) {
return deep_find.apply(null, arguments);
-}
+};
/******************************************************************************/
@@ -330,7 +333,7 @@ function generate_plugin_config_munge(plugin_dir, vars) {
// interp vars
if (vars) {
Object.keys(vars).forEach(function(key) {
- var regExp = new RegExp("\\$" + key, "g");
+ var regExp = new RegExp('\\$' + key, 'g');
stringified = stringified.replace(regExp, vars[key]);
});
}
@@ -534,8 +537,8 @@ function ConfigFile_save() {
fs.writeFileSync(self.filepath, self.data.writeSync());
} else {
// plist
- var regExp = new RegExp("<string>[ \t\r\n]+?</string>", "g");
- fs.writeFileSync(self.filepath, plist.build(self.data).replace(regExp,
"<string></string>"));
+ var regExp = new RegExp('<string>[ \t\r\n]+?</string>', 'g');
+ fs.writeFileSync(self.filepath, plist.build(self.data).replace(regExp,
'<string></string>'));
}
self.is_changed = false;
}
@@ -715,7 +718,7 @@ function deep_remove(obj, keys /* or key1, key2 .... */ ) {
return undefined;
}, keys);
- return typeof result === "undefined" ? true : result;
+ return typeof result === 'undefined' ? true : result;
}
// search for [key1][key2]...[keyN]
@@ -756,7 +759,7 @@ function process_munge(obj, createParents, func, keys /* or
key1, key2 .... */ )
obj.files[k] = obj.files[k] || { parents: {} };
return process_munge(obj.files[k], createParents, func, keys.slice(1));
} else {
- throw new Error("Invalid key format. Must contain at most 3 elements
(file, parent, xmlChild).");
+ throw new Error('Invalid key format. Must contain at most 3 elements
(file, parent, xmlChild).');
}
}