cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-plugin-device-motion git commit: CB-10636 Add JSHint for plugins
Date Mon, 29 Feb 2016 07:39:44 GMT
Repository: cordova-plugin-device-motion
Updated Branches:
  refs/heads/master 194bf5497 -> aa717efa9


CB-10636 Add JSHint for plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/aa717efa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/aa717efa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/aa717efa

Branch: refs/heads/master
Commit: aa717efa95958c26af07099d358590d7b0e19239
Parents: 194bf54
Author: daserge <v-seshak@microsoft.com>
Authored: Fri Feb 26 14:01:01 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Fri Feb 26 14:03:36 2016 +0300

----------------------------------------------------------------------
 .gitignore                        |  2 +-
 .jshintrc                         | 17 ++++++++++++
 .travis.yml                       |  4 +++
 README.md                         |  2 ++
 package.json                      |  9 ++++++-
 src/blackberry10/index.js         |  2 ++
 src/tizen/AccelerometerProxy.js   |  4 +--
 src/windows/AccelerometerProxy.js | 12 +++++----
 tests/tests.js                    | 47 ++++++++++++++++++----------------
 www/accelerometer.js              |  8 ++++--
 10 files changed, 73 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 52b558e..6964ea0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ Thumbs.db
 *.swp
 *.user
 
-
+node_modules
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..df32482
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,17 @@
+{
+    "browser": true
+  , "devel": true
+  , "bitwise": true
+  , "undef": true
+  , "trailing": true
+  , "quotmark": false
+  , "indent": 4
+  , "unused": "vars"
+  , "latedef": "nofunc"
+  , "globals": {
+        "module": false,
+        "exports": false,
+        "require": false,
+        "cordova": true
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b9af4c5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+sudo: false
+node_js:
+  - "4.2"

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 8b6dc27..9019804 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
 #         under the License.
 -->
 
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-motion.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device-motion)
+
 # cordova-plugin-device-motion
 
 This plugin provides access to the device's accelerometer. The accelerometer is

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index d6aec17..85d7b69 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,13 @@
     "cordova-tizen",
     "cordova-browser"
   ],
+  "scripts": {
+    "test": "npm run jshint",
+    "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint
src && node node_modules/jshint/bin/jshint tests"
+  },
   "author": "Apache Software Foundation",
-  "license": "Apache-2.0"
+  "license": "Apache-2.0",
+  "devDependencies": {
+    "jshint": "^2.6.0"
+  }
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index 47abe42..98bd8ce 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -19,6 +19,8 @@
  *
 */
 
+/* global PluginResult */
+
 var callback;
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/src/tizen/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/AccelerometerProxy.js b/src/tizen/AccelerometerProxy.js
index 47fe642..8352ba9 100644
--- a/src/tizen/AccelerometerProxy.js
+++ b/src/tizen/AccelerometerProxy.js
@@ -20,9 +20,7 @@
 */
 
 (function(win) {
-    var cordova = require('cordova'),
-        Acceleration = require('cordova-plugin-device-motion.Acceleration'),
-        accelerometerCallback = null;
+    var accelerometerCallback = null;
 
     module.exports = {
         start: function (successCallback, errorCallback) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/src/windows/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/AccelerometerProxy.js b/src/windows/AccelerometerProxy.js
index b5fec0b..aa07780 100644
--- a/src/windows/AccelerometerProxy.js
+++ b/src/windows/AccelerometerProxy.js
@@ -21,8 +21,7 @@
 
 /*global Windows:true */
 
-var cordova = require('cordova'),
-    Acceleration = require('cordova-plugin-device-motion.Acceleration');
+var Acceleration = require('cordova-plugin-device-motion.Acceleration');
 
 /* This is the actual implementation part that returns the result on Windows 8
 */
@@ -34,10 +33,11 @@ module.exports = {
 
         var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
         if(!accel) {
-            lose && lose("No accelerometer found");
+            if (lose) {
+                lose("No accelerometer found");
+            }
         }
         else {
-            var self = this;
             accel.reportInterval = Math.max(16,accel.minimumReportInterval);
 
             // store our bound function
@@ -57,7 +57,9 @@ module.exports = {
         win = win || function(){};
         var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
         if(!accel) {
-            lose && lose("No accelerometer found");
+            if (lose) {
+                lose("No accelerometer found");
+            }
         }
         else {
             accel.removeEventListener("readingchanged",this.onDataChanged);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index af552ef..73587e7 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,6 +19,9 @@
  *
 */
 
+/* jshint jasmine: true */
+/* global Windows */
+
 exports.defineAutoTests = function () {
     var isWindows = (cordova.platformId === "windows") || (cordova.platformId === "windows8"),
      // Checking existence of accelerometer for windows platform 
@@ -74,7 +77,7 @@ exports.defineAutoTests = function () {
             isAccelExist = false;
             expect(true).toBe(true);
             done();
-         }
+         };
 
         navigator.accelerometer.getCurrentAcceleration(win, onError);
       });
@@ -92,7 +95,7 @@ exports.defineAutoTests = function () {
           expect(a.y).toBeGreaterThan(reasonableThreshold * -1);
           expect(a.z).toBeLessThan(reasonableThreshold);
           expect(a.z).toBeGreaterThan(reasonableThreshold * -1);
-          done()
+          done();
         };
 
         navigator.accelerometer.getCurrentAcceleration(win, fail.bind(null,done));
@@ -231,7 +234,7 @@ exports.defineAutoTests = function () {
             win = function() {
               clearTimeout(tid);
               fail(done);
-            }
+            };
           };
 
           // wrap the success call in a closure since the value of win changes between calls
@@ -255,6 +258,25 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
     var watchAccelId = null;
 
     /**
+     * Set accelerometer status
+     */
+    function setAccelStatus(status) {
+        document.getElementById('accel_status').innerHTML = status;
+    }
+
+    /**
+     * Stop watching the acceleration
+     */
+    function stopAccel() {
+        console.log("stopAccel()");
+        setAccelStatus("Stopped");
+        if (watchAccelId) {
+            navigator.accelerometer.clearWatch(watchAccelId);
+            watchAccelId = null;
+        }
+    }
+
+    /**
      * Start watching acceleration
      */
     var watchAccel = function () {
@@ -283,18 +305,6 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
     };
 
     /**
-     * Stop watching the acceleration
-     */
-    var stopAccel = function () {
-        console.log("stopAccel()");
-        setAccelStatus("Stopped");
-        if (watchAccelId) {
-            navigator.accelerometer.clearWatch(watchAccelId);
-            watchAccelId = null;
-        }
-    };
-
-    /**
      * Get current acceleration
      */
     var getAccel = function () {
@@ -322,13 +332,6 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
         navigator.accelerometer.getCurrentAcceleration(success, fail, opt);
     };
 
-    /**
-     * Set accelerometer status
-     */
-    var setAccelStatus = function (status) {
-        document.getElementById('accel_status').innerHTML = status;
-    };
-
     /******************************************************************************/
 
     var accelerometer_tests = '<div id="getAcceleration"></div>' +

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/aa717efa/www/accelerometer.js
----------------------------------------------------------------------
diff --git a/www/accelerometer.js b/www/accelerometer.js
index cfd016a..21abe8b 100644
--- a/www/accelerometer.js
+++ b/www/accelerometer.js
@@ -112,7 +112,9 @@ var accelerometer = {
         };
         var fail = function (e) {
             removeListeners(p);
-            errorCallback && errorCallback(e);
+            if (errorCallback) {
+                errorCallback(e);
+            }
         };
 
         p = createCallbackPair(win, fail);
@@ -141,7 +143,9 @@ var accelerometer = {
 
         var p = createCallbackPair(function () { }, function (e) {
             removeListeners(p);
-            errorCallback && errorCallback(e);
+            if (errorCallback) {
+                errorCallback(e);
+            }
         });
         listeners.push(p);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message