From b6f537fe4c460fc5eb28837ac5314932f40d672a Mon Sep 17 00:00:00 2001 From: daserge Date: Tue, 1 Mar 2016 10:11:09 +0300 Subject: [PATCH] CB-10636 Add JSHint for plugins --- .gitignore | 2 +- .jshintrc | 17 +++++++++++++++++ .travis.yml | 4 ++++ README.md | 2 ++ package.json | 9 ++++++++- src/blackberry10/index.js | 2 ++ src/browser/network.js | 2 -- src/firefoxos/NetworkProxy.js | 7 +++---- src/tizen/NetworkProxy.js | 3 ++- src/windows/NetworkInfoProxy.js | 7 +------ tests/tests.js | 3 +++ 11 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 .jshintrc create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 52b558e..6964ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ Thumbs.db *.swp *.user - +node_modules 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 + } +} 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" diff --git a/README.md b/README.md index 3136147..ed341f4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-network-information) + # cordova-plugin-network-information diff --git a/package.json b/package.json index e4bf913..bbc5bde 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,13 @@ "cordova-tizen", "cordova-browser" ], + "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" + } } diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js index d47d840..c6cd00a 100644 --- a/src/blackberry10/index.js +++ b/src/blackberry10/index.js @@ -19,6 +19,8 @@ * */ +/* global PluginResult */ + //map from BB10 to cordova connection types: //https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js function mapConnectionType(con) { diff --git a/src/browser/network.js b/src/browser/network.js index 5769dd9..8a6ddb0 100644 --- a/src/browser/network.js +++ b/src/browser/network.js @@ -18,8 +18,6 @@ * */ -/*global module, require*/ - var cordova = require('cordova'), proxy = require("cordova/exec/proxy"), Connection = require('./Connection'); diff --git a/src/firefoxos/NetworkProxy.js b/src/firefoxos/NetworkProxy.js index 40d6163..8c82557 100644 --- a/src/firefoxos/NetworkProxy.js +++ b/src/firefoxos/NetworkProxy.js @@ -24,8 +24,7 @@ and http://w3c.github.io/netinfo/ */ -var cordova = require('cordova'), - Connection = require('./Connection'), +var Connection = require('./Connection'), modulemapper = require('cordova/modulemapper'); var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection'); @@ -47,7 +46,7 @@ module.exports = { metered = connection.metered, type = connection.type; - if (type != undefined) { + if (type !== undefined) { // For more information see: // https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API @@ -65,7 +64,7 @@ module.exports = { connectionType = Connection.NONE; break; } - } else if (bandwidth != undefined && metered != undefined) { + } else if (bandwidth !== undefined && metered !== undefined) { /* bandwidth of type double, readonly The user agent must set the value of the bandwidth attribute to: diff --git a/src/tizen/NetworkProxy.js b/src/tizen/NetworkProxy.js index cd9506e..d2de2cc 100644 --- a/src/tizen/NetworkProxy.js +++ b/src/tizen/NetworkProxy.js @@ -19,7 +19,8 @@ * */ -var cordova = require('cordova'); +/* global tizen */ + var Connection = require('./Connection'); module.exports = { diff --git a/src/windows/NetworkInfoProxy.js b/src/windows/NetworkInfoProxy.js index 27ad2f0..92153c7 100644 --- a/src/windows/NetworkInfoProxy.js +++ b/src/windows/NetworkInfoProxy.js @@ -21,15 +21,10 @@ /*global Windows:true */ -var cordova = require('cordova'); var Connection = require('./Connection'); var winNetConn = Windows.Networking.Connectivity; var networkInfo = winNetConn.NetworkInformation; -var networkCostInfo = winNetConn.NetworkCostType; -var networkConnectivityInfo = winNetConn.NetworkConnectivityLevel; -var networkAuthenticationInfo = winNetConn.NetworkAuthenticationType; -var networkEncryptionInfo = winNetConn.NetworkEncryptionType; function getCurrrentConnectionType() { @@ -76,7 +71,7 @@ module.exports = { { var reportConnectionInfoOnce = function () { win(getCurrrentConnectionType(), { keepCallback: true }); - } + }; // report current connection type setTimeout(reportConnectionInfoOnce, 0); diff --git a/tests/tests.js b/tests/tests.js index 23be97a..07f4b27 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -19,6 +19,9 @@ * */ +/* jshint jasmine: true */ +/* global Connection */ + exports.defineAutoTests = function () { describe('Network (navigator.connection)', function () { it("network.spec.1 should exist", function () {