Skip to content
Permalink
Browse files
CB-10636 Add JSHint for plugins
Fixed file.spec.115
  • Loading branch information
daserge committed Feb 24, 2016
1 parent f231e7c commit f6d42aee153e260422786f7b561081247c3975e5
Showing 27 changed files with 428 additions and 296 deletions.
@@ -13,3 +13,4 @@ Thumbs.db
*.user

/.project
node_modules
@@ -0,0 +1,30 @@
{
"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": false,
"File": true,
"FileSystem": true,
"FileReader": true,
"FileWriter": true,
"FileError": true,
"LocalFileSystem": true,
"Metadata": true,
"Flags": true,
"DirectoryEntry": true,
"resolveLocalFileSystemURL": false,
"requestFileSystem": true,
"FILESYSTEM_PREFIX": true,
"FILESYSTEM_PROTOCOL": true
}
}
@@ -0,0 +1,4 @@
language: node_js
sudo: false
node_js:
- "4.2"
@@ -17,6 +17,8 @@
# under the License.
-->

[![Build Status](https://travis-ci.org/apache/cordova-plugin-file.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-file)

# cordova-plugin-file

This plugin implements a File API allowing read/write access to files residing on the device.
@@ -38,6 +38,13 @@
"cordova-windows",
"cordova-firefoxos"
],
"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"
}
}
@@ -18,6 +18,9 @@
* under the License.
*
*/

/* global PluginResult */

module.exports = {
setSandbox : function (success, fail, args, env) {
require("lib/webview").setSandbox(JSON.parse(decodeURIComponent(args[0])));
@@ -88,7 +88,9 @@
var size = args[1]; // jshint ignore: line

if (type !== LocalFileSystem.TEMPORARY && type !== LocalFileSystem.PERSISTENT) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -236,7 +238,9 @@
isBinary = args[3]; // jshint ignore: line

if (!data) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -520,14 +524,18 @@
}

if (path.trim()[0] === '/') {
errorCallback && errorCallback(FileError.ENCODING_ERR);
if (errorCallback) {
errorCallback(FileError.ENCODING_ERR);
}
return;
}

//support for cdvfile
if (path.trim().substr(0,7) === "cdvfile") {
if (path.indexOf("cdvfile://localhost") === -1) {
errorCallback && errorCallback(FileError.ENCODING_ERR);
if (errorCallback) {
errorCallback(FileError.ENCODING_ERR);
}
return;
}

@@ -540,7 +548,9 @@
} else if (indexTemporary !== -1) {
path = "file:///temporary" + path.substr(indexTemporary + 9);
} else {
errorCallback && errorCallback(FileError.ENCODING_ERR);
if (errorCallback) {
errorCallback(FileError.ENCODING_ERR);
}
return;
}
}
@@ -600,12 +610,16 @@
};

xhr.onerror = function () {
errorCallback && errorCallback(FileError.NOT_READABLE_ERR);
if(errorCallback) {
errorCallback(FileError.NOT_READABLE_ERR);
}
};

xhr.send();
} else {
errorCallback && errorCallback(FileError.NOT_FOUND_ERR);
if(errorCallback) {
errorCallback(FileError.NOT_FOUND_ERR);
}
}

function writeFile(entry) {
@@ -617,7 +631,9 @@
}
};
fileWriter.onerror = function () {
errorCallback && errorCallback(FileError.NOT_READABLE_ERR);
if (errorCallback) {
errorCallback(FileError.NOT_READABLE_ERR);
}
};
fileWriter.write(new Blob([xhr.response]));
}, errorCallback);
@@ -819,7 +835,9 @@

idb_.get = function(fullPath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -835,7 +853,9 @@

idb_.getAllEntries = function(fullPath, storagePath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -896,7 +916,9 @@

idb_['delete'] = function(fullPath, successCallback, errorCallback, isDirectory) {
if (!idb_.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -926,7 +948,9 @@

idb_.put = function(entry, storagePath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -19,6 +19,8 @@
*
*/

/* global IDBKeyRange */

var LocalFileSystem = require('./LocalFileSystem'),
FileSystem = require('./FileSystem'),
FileEntry = require('./FileEntry'),
@@ -67,10 +69,12 @@ QUIRKS:

exports.requestFileSystem = function(successCallback, errorCallback, args) {
var type = args[0];
var size = args[1];
//var size = args[1];

if (type !== LocalFileSystem.TEMPORARY && type !== LocalFileSystem.PERSISTENT) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -206,11 +210,13 @@ QUIRKS:
exports.write = function(successCallback, errorCallback, args) {
var fileName = args[0],
data = args[1],
position = args[2],
isBinary = args[3];
position = args[2];
//isBinary = args[3];

if (!data) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -393,8 +399,8 @@ QUIRKS:

exports.moveTo = function(successCallback, errorCallback, args) {
var srcPath = args[0];
var parentFullPath = args[1];
var name = args[2];
//var parentFullPath = args[1];
//var name = args[2];

exports.copyTo(function (fileEntry) {

@@ -449,12 +455,16 @@ QUIRKS:
};

xhr.onerror = function () {
errorCallback && errorCallback(FileError.NOT_READABLE_ERR);
if (errorCallback) {
errorCallback(FileError.NOT_READABLE_ERR);
}
};

xhr.send();
} else {
errorCallback && errorCallback(FileError.NOT_FOUND_ERR);
if (errorCallback) {
errorCallback(FileError.NOT_FOUND_ERR);
}
}

function writeFile(entry) {
@@ -466,7 +476,9 @@ QUIRKS:
}
};
fileWriter.onerror = function () {
errorCallback && errorCallback(FileError.NOT_READABLE_ERR);
if (errorCallback) {
errorCallback(FileError.NOT_READABLE_ERR);
}
};
fileWriter.write(new Blob([xhr.response]));
}, errorCallback);
@@ -640,7 +652,7 @@ QUIRKS:
self.db.onerror = onError;

if (!self.db.objectStoreNames.contains(FILE_STORE_)) {
var store = self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/);
self.db.createObjectStore(FILE_STORE_/*,{keyPath: 'id', autoIncrement: true}*/);
}
};

@@ -660,7 +672,9 @@ QUIRKS:

idb_.get = function(fullPath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -679,7 +693,9 @@ QUIRKS:

idb_.getAllEntries = function(fullPath, storagePath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -689,7 +705,7 @@ QUIRKS:
storagePath = storagePath.substring(0, storagePath.length - 1);
}

range = IDBKeyRange.bound(
var range = IDBKeyRange.bound(
storagePath + DIR_SEPARATOR, storagePath + DIR_OPEN_BOUND, false, true);

var tx = this.db.transaction([FILE_STORE_], 'readonly');
@@ -730,7 +746,9 @@ QUIRKS:

idb_['delete'] = function(fullPath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

@@ -746,7 +764,9 @@ QUIRKS:

idb_.put = function(entry, storagePath, successCallback, errorCallback) {
if (!this.db) {
errorCallback && errorCallback(FileError.INVALID_MODIFICATION_ERR);
if (errorCallback) {
errorCallback(FileError.INVALID_MODIFICATION_ERR);
}
return;
}

0 comments on commit f6d42ae

Please sign in to comment.