You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2016/04/15 22:48:54 UTC
[05/11] cordova-plugin-device git commit: CB-10636 Add JSHint for
plugins
CB-10636 Add JSHint for plugins
Added Travis badge
Added node_modules to gitignore
Disabled quotmark as it is deprecated
Fixed jshint issues
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/7d35ac85
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/7d35ac85
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/7d35ac85
Branch: refs/heads/1.1.x
Commit: 7d35ac850642d2f2113e13a601b86875896e74ea
Parents: 52f0b41
Author: daserge <v-...@microsoft.com>
Authored: Wed Feb 17 14:41:14 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Thu Feb 18 09:56:33 2016 +0300
----------------------------------------------------------------------
.gitignore | 2 +-
.jshintrc | 15 +++++++++++++++
.travis.yml | 4 ++++
README.md | 2 ++
package.json | 9 ++++++++-
src/blackberry10/index.js | 2 ++
src/browser/DeviceProxy.js | 2 +-
src/firefoxos/DeviceProxy.js | 2 --
src/tizen/DeviceProxy.js | 1 -
src/ubuntu/device.js | 3 +--
src/windows/DeviceProxy.js | 4 +++-
tests/tests.js | 24 +++++++++++++-----------
12 files changed, 50 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/.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/blob/7d35ac85/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..dd79047
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,15 @@
+{
+ "browser": 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-device/blob/7d35ac85/.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/blob/7d35ac85/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 413a43b..35f6aed 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
# under the License.
-->
+[](https://travis-ci.org/apache/cordova-plugin-device)
+
# cordova-plugin-device
This plugin defines a global `device` object, which describes the device's hardware and software.
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index a170563..0719f86 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,13 @@
"cordova-browser",
"cordova-osx"
],
+ "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/blob/7d35ac85/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index 77f25a9..ef0543b 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -19,6 +19,8 @@
*
*/
+/* global PluginResult */
+
function getModelName () {
var modelName = window.qnx.webplatform.device.modelName;
//Pre 10.2 (meaning Z10 or Q10)
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/src/browser/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/DeviceProxy.js b/src/browser/DeviceProxy.js
index fcaed20..a863201 100644
--- a/src/browser/DeviceProxy.js
+++ b/src/browser/DeviceProxy.js
@@ -19,7 +19,6 @@
*
*/
var browser = require('cordova/platform');
-var cordova = require('cordova');
function getPlatform() {
return "browser";
@@ -36,6 +35,7 @@ function getVersion() {
function getBrowserInfo(getModel) {
var userAgent = navigator.userAgent;
var returnVal = '';
+ var offset;
if ((offset = userAgent.indexOf('Chrome')) !== -1) {
returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/src/firefoxos/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/DeviceProxy.js b/src/firefoxos/DeviceProxy.js
index 79f3a2b..a05d7ca 100644
--- a/src/firefoxos/DeviceProxy.js
+++ b/src/firefoxos/DeviceProxy.js
@@ -20,8 +20,6 @@
*/
//example UA String for Firefox OS
//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0
-var firefoxos = require('cordova/platform');
-var cordova = require('cordova');
//UA parsing not recommended but currently this is the only way to get the Firefox OS version
//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/src/tizen/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/DeviceProxy.js b/src/tizen/DeviceProxy.js
index 2afc324..973b716 100644
--- a/src/tizen/DeviceProxy.js
+++ b/src/tizen/DeviceProxy.js
@@ -20,7 +20,6 @@
*/
var tizen = require('cordova/platform');
-var cordova = require('cordova');
module.exports = {
getDeviceInfo: function(success, error) {
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/src/ubuntu/device.js
----------------------------------------------------------------------
diff --git a/src/ubuntu/device.js b/src/ubuntu/device.js
index 3adb110..838586c 100644
--- a/src/ubuntu/device.js
+++ b/src/ubuntu/device.js
@@ -19,8 +19,7 @@
*
*/
-var cordova = require('cordova');
-var exec = require('cordova/exec');
+/* global Cordova */
module.exports = {
getInfo:function(win,fail,args) {
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/src/windows/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/DeviceProxy.js b/src/windows/DeviceProxy.js
index d21d46b..f338ad3 100644
--- a/src/windows/DeviceProxy.js
+++ b/src/windows/DeviceProxy.js
@@ -19,9 +19,11 @@
*
*/
+/* global Windows, createUUID */
+
var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}";
var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10";
-var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10';
+var DEVICE_CLASS_KEY_NO_SEMICOLON = "{A45C254E-DF1C-4EFD-8020-67D146A850E0}10";
var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\"";
var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318";
var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3";
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/7d35ac85/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 21e4160..ac9a281 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,6 +19,8 @@
*
*/
+/* jshint jasmine: true */
+
exports.defineAutoTests = function() {
describe('Device Information (window.device)', function () {
it("should exist", function() {
@@ -27,18 +29,18 @@ exports.defineAutoTests = function() {
it("should contain a platform specification that is a string", function() {
expect(window.device.platform).toBeDefined();
- expect((new String(window.device.platform)).length > 0).toBe(true);
+ expect((String(window.device.platform)).length > 0).toBe(true);
});
it("should contain a version specification that is a string", function() {
expect(window.device.version).toBeDefined();
- expect((new String(window.device.version)).length > 0).toBe(true);
+ expect((String(window.device.version)).length > 0).toBe(true);
});
it("should contain a UUID specification that is a string or a number", function() {
expect(window.device.uuid).toBeDefined();
if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
- expect((new String(window.device.uuid)).length > 0).toBe(true);
+ expect((String(window.device.uuid)).length > 0).toBe(true);
} else {
expect(window.device.uuid > 0).toBe(true);
}
@@ -46,12 +48,12 @@ exports.defineAutoTests = function() {
it("should contain a cordova specification that is a string", function() {
expect(window.device.cordova).toBeDefined();
- expect((new String(window.device.cordova)).length > 0).toBe(true);
+ expect((String(window.device.cordova)).length > 0).toBe(true);
});
it("should depend on the presence of cordova.version string", function() {
expect(window.cordova.version).toBeDefined();
- expect((new String(window.cordova.version)).length > 0).toBe(true);
+ expect((String(window.cordova.version)).length > 0).toBe(true);
});
it("should contain device.cordova equal to cordova.version", function() {
@@ -60,12 +62,12 @@ exports.defineAutoTests = function() {
it("should contain a model specification that is a string", function() {
expect(window.device.model).toBeDefined();
- expect((new String(window.device.model)).length > 0).toBe(true);
+ expect((String(window.device.model)).length > 0).toBe(true);
});
it("should contain a manufacturer property that is a string", function() {
expect(window.device.manufacturer).toBeDefined();
- expect((new String(window.device.manufacturer)).length > 0).toBe(true);
+ expect((String(window.device.manufacturer)).length > 0).toBe(true);
});
it("should contain an isVirtual property that is a boolean", function() {
@@ -75,7 +77,7 @@ exports.defineAutoTests = function() {
it("should contain a serial number specification that is a string", function() {
expect(window.device.serial).toBeDefined();
- expect((new String(window.device.serial)).length > 0).toBe(true);
+ expect((String(window.device.serial)).length > 0).toBe(true);
});
@@ -83,7 +85,7 @@ exports.defineAutoTests = function() {
};
exports.defineManualTests = function(contentEl, createActionButton) {
- var logMessage = function (message, color) {
+ var logMessage = function (message, color) {
var log = document.getElementById('info');
var logLine = document.createElement('div');
if (color) {
@@ -91,12 +93,12 @@ exports.defineManualTests = function(contentEl, createActionButton) {
}
logLine.innerHTML = message;
log.appendChild(logLine);
- }
+ };
var clearLog = function () {
var log = document.getElementById('info');
log.innerHTML = '';
- }
+ };
var device_tests = '<h3>Press Dump Device button to get device information</h3>' +
'<div id="dump_device"></div>' +
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org