Skip to content

Commit f85373b

Browse files
authored
chore!: removed old platform code & lint cleanup (apache#519)
* style: apply lint fix * test: remove old windows related platform code * test: remove old blackberry related platform code * test: remove old amazon-fireos related platform code * style: remove eslint-disable-line no-undef & add globals * chore!: remove old windows8 code * chore!: remove old windowsphone code
1 parent e97fe90 commit f85373b

File tree

11 files changed

+35
-38
lines changed

11 files changed

+35
-38
lines changed

.eslintrc.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ root: true
22
extends: '@cordova/eslint-config/browser'
33
globals:
44
cordova: true
5+
LocalFileSystem: true
6+
FileError: true
7+
DirectoryEntry: true
8+
FileWriter: true
9+
Flags: true
10+
Metadata: true
11+
FileSystem: true
12+
resolveLocalFileSystemURL: true
513

614
overrides:
715
- files: [tests/**/*.js]
816
extends: '@cordova/eslint-config/node-tests'
9-
globals:
10-
cordova: true

tests/tests.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports.defineAutoTests = function () {
2929
var isIE = isBrowser && (window.msIndexedDB);
3030
var isIndexedDBShim = isBrowser && !isChrome; // Firefox and IE for example
3131

32-
var isWindows = (cordova.platformId === 'windows' || cordova.platformId === 'windows8');
32+
var isWindows = cordova.platformId === 'windows';
3333
/* eslint-enable no-undef */
3434
var MEDIUM_TIMEOUT = 15000;
3535

@@ -417,7 +417,7 @@ exports.defineAutoTests = function () {
417417
});
418418

419419
it('file.spec.11 should error (NOT_FOUND_ERR) when resolving (non-existent) invalid file name', function (done) {
420-
var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'this.is.not.a.valid.file.txt' : joinURL(root.toURL(), 'this.is.not.a.valid.file.txt'); // eslint-disable-line no-undef
420+
var fileName = joinURL(root.toURL(), 'this.is.not.a.valid.file.txt');
421421
var fail = function (error) {
422422
expect(error).toBeDefined();
423423
if (isChrome) {
@@ -2453,7 +2453,7 @@ exports.defineAutoTests = function () {
24532453
// FileReader
24542454
describe('Read method', function () {
24552455
it('file.spec.82 should error out on non-existent file', function (done) {
2456-
var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'somefile.txt' : 'somefile.txt'; // eslint-disable-line no-undef
2456+
var fileName = 'somefile.txt';
24572457
var verifier = function (evt) {
24582458
expect(evt).toBeDefined();
24592459
if (isChrome) {
@@ -3440,8 +3440,6 @@ exports.defineAutoTests = function () {
34403440
if (cordova.platformId === 'android') {
34413441
// Starting from Cordova-Android 10.x, the app content is served from the https scheme
34423442
pathExpect = 'https://';
3443-
} else if (cordova.platformId === 'windowsphone') {
3444-
pathExpect = '//nativ';
34453443
} else if (isChrome) {
34463444
pathExpect = 'filesystem:http://';
34473445
}
@@ -3788,14 +3786,12 @@ exports.defineAutoTests = function () {
37883786
it('file.spec.129 cordova.file.*Directory are set', function () {
37893787
var expectedPaths = ['applicationDirectory', 'applicationStorageDirectory', 'dataDirectory', 'cacheDirectory'];
37903788
/* eslint-disable no-undef */
3791-
if (cordova.platformId === 'android' || cordova.platformId === 'amazon-fireos') {
3789+
if (cordova.platformId === 'android') {
37923790
if (cordova.file.externalApplicationStorageDirectory !== null) {
37933791
// https://issues.apache.org/jira/browse/CB-10411
37943792
// If external storage can't be mounted, the cordova.file.external* properties are null.
37953793
expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory');
37963794
}
3797-
} else if (cordova.platformId === 'blackberry10') {
3798-
expectedPaths.push('externalRootDirectory', 'sharedDirectory');
37993795
} else if (cordova.platformId === 'ios') {
38003796
expectedPaths.push('syncedDataDirectory', 'documentsDirectory', 'tempDirectory');
38013797
} else if (cordova.platformId === 'osx') {
@@ -3817,10 +3813,10 @@ exports.defineAutoTests = function () {
38173813
var cdvfileApplicationDirectoryFsRootNameURL;
38183814
if (cordova.platformId === 'android') {
38193815
cdvfileApplicationDirectoryFsRootName = 'assets';
3820-
cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/'
3816+
cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/';
38213817
} else if (cordova.platformId === 'ios') {
38223818
cdvfileApplicationDirectoryFsRootName = 'bundle';
3823-
cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/'
3819+
cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/';
38243820
} else {
38253821
pending();
38263822
}
@@ -4206,7 +4202,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
42064202
ios: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private',
42074203
osx: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private',
42084204
android: 'files,files-external,documents,sdcard,cache,cache-external,assets,root',
4209-
'amazon-fireos': 'files,files-external,documents,sdcard,cache,cache-external,root',
42104205
windows: 'temporary,persistent'
42114206
};
42124207

www/Entry.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallba
117117
if (successCallback) {
118118
// create appropriate Entry object
119119
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
120-
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
120+
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' });
121121
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
122122
successCallback(result);
123123
}
@@ -159,7 +159,7 @@ Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallba
159159
if (successCallback) {
160160
// create appropriate Entry object
161161
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
162-
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
162+
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' });
163163
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
164164
successCallback(result);
165165
}

www/FileReader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function readSuccessCallback (readType, encoding, offset, totalSize, accumulate,
137137
if (readType === 'readAsDataURL') {
138138
// Windows proxy does not support reading file slices as Data URLs
139139
// so read the whole file at once.
140-
CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize // eslint-disable-line no-undef
140+
CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize
141141
: (
142142
// Calculate new chunk size for data URLs to be multiply of 3
143143
// Otherwise concatenated base64 chunks won't be valid base64 data

www/FileWriter.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ FileWriter.prototype.write = function (data, isPendingBlobReadResult) {
112112
var that = this;
113113
var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');
114114
/* eslint-disable no-undef */
115-
var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows');
115+
var isProxySupportBlobNatively = cordova.platformId === 'windows';
116116
var isBinary;
117117

118118
// Check to see if the incoming data is a blob
@@ -154,10 +154,6 @@ FileWriter.prototype.write = function (data, isPendingBlobReadResult) {
154154

155155
// Mark data type for safer transport over the binary bridge
156156
isBinary = supportsBinary && (data instanceof ArrayBuffer);
157-
if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef
158-
// create a plain array, using the keys from the Uint8Array view so that we can serialize it
159-
data = Array.apply(null, new Uint8Array(data));
160-
}
161157

162158
// Throw an exception if we are already writing a file
163159
if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) {

www/android/Entry.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
*/
2121

2222
module.exports = {
23-
/**
23+
/**
2424
* Return a URL that can be used to identify this entry.
2525
* Use a URL that can be used to as the src attribute of a <video> or
2626
* <audio> tag. If that is not possible, construct a http(s)://(localhost) URL.
2727
*/
28-
toURL: function () {
29-
return window.location.origin.includes('file://')
30-
? this.nativeURL
31-
: this.toInternalURL();
32-
}
28+
toURL: function () {
29+
return window.location.origin.includes('file://')
30+
? this.nativeURL
31+
: this.toInternalURL();
32+
}
3333
};

www/android/FileSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
// doesn't match the string for which permission was originally granted.
3131
path = nativeUrl.substring(contentUrlMatch[0].length - 1);
3232
} else {
33-
path = FileSystem.encodeURIPath(fullPath); // eslint-disable-line no-undef
33+
path = FileSystem.encodeURIPath(fullPath);
3434
if (!/^\//.test(path)) {
3535
path = '/' + path;
3636
}

www/browser/FileSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ FILESYSTEM_PREFIX = 'file:///';
2525

2626
module.exports = {
2727
__format__: function (fullPath) {
28-
return (FILESYSTEM_PREFIX + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath)); // eslint-disable-line no-undef
28+
return (FILESYSTEM_PREFIX + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath));
2929
}
3030
};

www/browser/Preparing.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
var channel = require('cordova/channel');
3131
var FileError = require('./FileError');
3232
var PERSISTENT_FS_QUOTA = 5 * 1024 * 1024;
33-
var filePluginIsReadyEvent = new Event('filePluginIsReady'); // eslint-disable-line no-undef
33+
var filePluginIsReadyEvent = new Event('filePluginIsReady');
3434

3535
var entryFunctionsCreated = false;
3636
var quotaWasRequested = false;
@@ -75,8 +75,8 @@
7575
For example, filesystem:file:///persistent/somefile.txt,
7676
filesystem:http://localhost:8080/persistent/somefile.txt. */
7777
var prefix = 'filesystem:file:///';
78-
if (location.protocol !== 'file:') { // eslint-disable-line no-undef
79-
prefix = 'filesystem:' + location.origin + '/'; // eslint-disable-line no-undef
78+
if (location.protocol !== 'file:') {
79+
prefix = 'filesystem:' + location.origin + '/';
8080
}
8181

8282
var result;
@@ -146,10 +146,10 @@
146146
var originalWrite = writer.write;
147147
var writerProto = Object.getPrototypeOf(writer);
148148
writerProto.write = function (blob) {
149-
if (blob instanceof Blob) { // eslint-disable-line no-undef
149+
if (blob instanceof Blob) {
150150
originalWrite.apply(this, [blob]);
151151
} else {
152-
var realBlob = new Blob([blob]); // eslint-disable-line no-undef
152+
var realBlob = new Blob([blob]);
153153
originalWrite.apply(this, [realBlob]);
154154
}
155155
};

www/requestFileSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(function () {
2323
// For browser platform: not all browsers use this file.
2424
function checkBrowser () {
25-
if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
25+
if (cordova.platformId === 'browser' && require('./isChrome')()) {
2626
module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
2727
return true;
2828
}

0 commit comments

Comments
 (0)