cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-plugin-globalization git commit: CB-10636 Add JSHint for plugins
Date Wed, 02 Mar 2016 08:55:47 GMT
Repository: cordova-plugin-globalization
Updated Branches:
  refs/heads/master 05218c9fa -> 900ea73f3


CB-10636 Add JSHint for plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/900ea73f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/900ea73f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/900ea73f

Branch: refs/heads/master
Commit: 900ea73f364af926e4ecb3f604a40572e5f1e300
Parents: 05218c9
Author: daserge <v-seshak@microsoft.com>
Authored: Mon Feb 29 15:46:06 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Wed Mar 2 11:52:22 2016 +0300

----------------------------------------------------------------------
 .gitignore                        |  2 +-
 .jshintignore                     |  1 +
 .jshintrc                         | 16 ++++++++++++++++
 .travis.yml                       |  4 ++++
 README.md                         |  2 ++
 package.json                      |  9 ++++++++-
 src/blackberry10/index.js         |  2 ++
 src/browser/GlobalizationProxy.js | 19 +++++++++++++------
 src/tizen/GlobalizationProxy.js   |  5 +++--
 src/windows/GlobalizationProxy.js | 10 ++++++----
 tests/tests.js                    |  9 ++++++---
 www/firefoxos/l10n.js             |  1 +
 www/firefoxos/l10n_date.js        |  5 ++---
 www/globalization.js              |  3 +--
 www/ubuntu/globalization.js       |  5 ++++-
 15 files changed, 70 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/.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-globalization/blob/900ea73f/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..2ef22fc
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+www/browser/moment.js

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..cf48aac
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,16 @@
+{
+    "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
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/.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-globalization/blob/900ea73f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 0bce104..5ca8445 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
 #         under the License.
 -->
 
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-globalization.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-globalization)
+
 # cordova-plugin-globalization
 
 This plugin obtains information and performs operations specific to the user's

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index e7e33b3..4489ed1 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,13 @@
     "cordova-tizen",
     "cordova-blackberry10"
   ],
+  "scripts": {
+    "test": "npm run jshint",
+    "jshint": "jshint www && jshint src && 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-globalization/blob/900ea73f/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index 7d56740..05fde27 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -19,6 +19,8 @@
  *
 */
 
+/* global PluginResult, JNEXT */
+
 var g11n;
 
 var globalization = {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/src/browser/GlobalizationProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/GlobalizationProxy.js b/src/browser/GlobalizationProxy.js
index d998ca3..1c21a52 100644
--- a/src/browser/GlobalizationProxy.js
+++ b/src/browser/GlobalizationProxy.js
@@ -48,8 +48,8 @@ function dstOffsetAbs(date) {
 }
 
 function getWeekDayNames(locale, options) {
-    var result = [];
-    for (i = 0; i < 7; i++) {
+    var result = [], date;
+    for (var i = 0; i < 7; i++) {
         date = new Date(2014, 5, i + 1, 0, 0, 0, 0);
         result[i] = date.toLocaleDateString(locale, options);
     }
@@ -78,10 +78,11 @@ function convertToMomentLocalizedFormat(options) {
             switch(options.selector) {
                 case 'date and time': return 'lll';
                 case 'date': return 'l';
-                case 'time': return 'LT'
+                case 'time': return 'LT';
                 default:
                     throw selectorError;
             }
+            break;
         case 'medium':
             switch(options.selector) {
                 case 'date and time': return 'LLL';
@@ -91,6 +92,7 @@ function convertToMomentLocalizedFormat(options) {
                 default:
                     throw selectorError;
             }
+            break;
         case 'long':
             switch(options.selector) {
                 case 'date and time': return 'llll';
@@ -100,6 +102,7 @@ function convertToMomentLocalizedFormat(options) {
                 default:
                     throw selectorError;
             }
+            break;
         case 'full':
             switch(options.selector) {
                 case 'date and time': return 'LLLL';
@@ -108,13 +111,14 @@ function convertToMomentLocalizedFormat(options) {
                 default:
                     throw selectorError;
             }
+            break;
         default:
             throw formatLengthError;
     }
 }
 
 function prepareAndGetDateOptions(options) {
-    var options = options || {formatLength:'short', selector:'date and time'};
+    options = options || {formatLength:'short', selector:'date and time'};
     options.formatLength = options.formatLength || 'short';
     options.selector = options.selector || 'date and time';
 
@@ -175,7 +179,7 @@ var globalization = {
             var locale = getCrossPlatformLocale();
 
             if (item === 'months' && type === 'wide') {
-                var options = { month: 'long' };
+                options = { month: 'long' };
             } else if (item === 'months' && type === 'narrow') {
                 options = { month: 'short'};
             } else if (item === 'days' && type === 'wide') {
@@ -229,7 +233,10 @@ var globalization = {
 
             var formatter = new Intl.NumberFormat(getCrossPlatformLocale(), options);
 
-            if (!formatter.hasOwnProperty('resolved')) { fail('Not supported'); return; };
+            if (!formatter.hasOwnProperty('resolved')) {
+                fail('Not supported'); 
+                return; 
+            }
             var pattern = formatter.resolved.pattern;
             win( { 
                 pattern: pattern,

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/src/tizen/GlobalizationProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/GlobalizationProxy.js b/src/tizen/GlobalizationProxy.js
index 9e6b981..bfde856 100644
--- a/src/tizen/GlobalizationProxy.js
+++ b/src/tizen/GlobalizationProxy.js
@@ -19,6 +19,8 @@
  *
 */
 
+/* global tizen */
+
 var argscheck = require('cordova/argscheck'),
     GlobalizationError = require('cordova-plugin-globalization.GlobalizationError');
 
@@ -114,7 +116,6 @@ var globalization = {
     *                {formatLength:'short'});
     */
     dateToString:function(date, successCB, failureCB, options) {
-        var dateValue = date.valueOf();
         console.log('exec(successCB, failureCB, "Globalization", "dateToString", [{"date":
dateValue, "options": options}]);');
 
         var tzdate = null;
@@ -308,7 +309,7 @@ var globalization = {
 
         tzdate = new tizen.TZDate(date);
         if (tzdate) {
-            isDLS = false | (tzdate && tzdate.isDST());
+            isDLS = tzdate && tzdate.isDST();
 
             console.log ("Cordova, globalization, isDayLightSavingsTime, " + isDLS);
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/src/windows/GlobalizationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy.js b/src/windows/GlobalizationProxy.js
index 83b64a1..13bdd1e 100644
--- a/src/windows/GlobalizationProxy.js
+++ b/src/windows/GlobalizationProxy.js
@@ -12,6 +12,8 @@
 	limitations under the License.
 */
 
+/* global Windows, GlobalizationProxy */
+
 var GlobalizationError = require('./GlobalizationError');
 var locale = navigator.userLanguage || navigator.language;
 
@@ -97,7 +99,7 @@ function getNumberFormatter(options) {
         }
         default:
             throw "The options.type can be 'decimal', 'percent', or 'currency' only";
-    };
+    }
 }
 
 module.exports = {
@@ -163,10 +165,10 @@ module.exports = {
                 Windows.Globalization.DateTimeFormatting.SecondFormat.none, 
                 [locale]);
 
-            var result = [];
+            var result = [], i, date;
             if (item === 'months') {
-                for (var i = 0; i < 12; i++) {
-                    var date = new Date(2014, i, 20, 0, 0, 0, 0);
+                for (i = 0; i < 12; i++) {
+                    date = new Date(2014, i, 20, 0, 0, 0, 0);
                     result[i] = formatter.format(date);
                 }
             } else {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 98fd31d..c395e83 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,6 +19,9 @@
 *
 */
 
+/* jshint jasmine: true */
+/* global cordova, GlobalizationError */
+
 exports.defineAutoTests = function () {
     var isWindowsPhone = cordova.platformId == 'windowsphone',
         isWindows = (cordova.platformId === "windows") || (cordova.platformId === "windows8"),
@@ -83,7 +86,7 @@ exports.defineAutoTests = function () {
             it("globalization.spec.3 getLocaleName success callback should be called with
a Properties object", function (done) {
                 navigator.globalization.getLocaleName(function (a) {
                     checkLocaleName(a);
-                    done()
+                    done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.4 getLocaleName return string should have a hyphen", function
(done) {
@@ -384,7 +387,7 @@ exports.defineAutoTests = function () {
                 }, fail.bind(null, done));
             });
             it("globalization.spec.31 numberToString using type=percent options, should be
called with a Properties object", function (done) {
-                navigator.globalization.numberToString(.25, function (a) {
+                navigator.globalization.numberToString(0.25, function (a) {
                     checkNumberToString(a);
                     done();
                 }, fail.bind(null, done),
@@ -442,7 +445,7 @@ exports.defineAutoTests = function () {
                     done();
                 };
 
-                navigator.globalization.numberToString(.25, function (a) {
+                navigator.globalization.numberToString(0.25, function (a) {
                     navigator.globalization.stringToNumber(a.value, win, fail.bind(null,
done), { type: 'percent' });
                 }, fail.bind(null, done), { type: 'percent' });
             });

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/www/firefoxos/l10n.js
----------------------------------------------------------------------
diff --git a/www/firefoxos/l10n.js b/www/firefoxos/l10n.js
index 5a735a0..a2cd328 100644
--- a/www/firefoxos/l10n.js
+++ b/www/firefoxos/l10n.js
@@ -19,6 +19,7 @@
  *
 */
 
+/* global unescape */
 
 (function(window, undefined) {
   'use strict';

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/www/firefoxos/l10n_date.js
----------------------------------------------------------------------
diff --git a/www/firefoxos/l10n_date.js b/www/firefoxos/l10n_date.js
index 8c09d38..dcafba8 100644
--- a/www/firefoxos/l10n_date.js
+++ b/www/firefoxos/l10n_date.js
@@ -19,9 +19,6 @@
  *
 */
 
-
-'use strict';
-
 /**
  * This lib relies on `l10n.js' to implement localizable date/time strings.
  *
@@ -41,6 +38,8 @@
  */
 
 navigator.mozL10n.DateTimeFormat = function(locales, options) {
+  'use strict';
+
   var _ = navigator.mozL10n.get;
 
   // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleFormat

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/www/globalization.js
----------------------------------------------------------------------
diff --git a/www/globalization.js b/www/globalization.js
index 88b3640..aa5f60c 100644
--- a/www/globalization.js
+++ b/www/globalization.js
@@ -20,8 +20,7 @@
 */
 
 var argscheck = require('cordova/argscheck'),
-    exec = require('cordova/exec'),
-    GlobalizationError = require('./GlobalizationError');
+    exec = require('cordova/exec');
 
 var globalization = {
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/900ea73f/www/ubuntu/globalization.js
----------------------------------------------------------------------
diff --git a/www/ubuntu/globalization.js b/www/ubuntu/globalization.js
index 51900db..6b423be 100644
--- a/www/ubuntu/globalization.js
+++ b/www/ubuntu/globalization.js
@@ -16,6 +16,9 @@
  * under the License.
  *
 */
+
+/* global Cordova */
+
 var exec = require('cordova/exec');
 var argscheck = require('cordova/argscheck');
 var GlobalizationError = require('./GlobalizationError');
@@ -158,7 +161,7 @@ module.exports = {
     getCurrencyPattern: function(currencyCode, successCB, failureCB) {
         argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
 
-        failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR, "unimplemented"))
+        failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR, "unimplemented"));
         //exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode":
currencyCode}]);
     }
 };


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


Mime
View raw message