Skip to content

Commit 29a6e11

Browse files
committed
fix: eslint errors
1 parent 17b4445 commit 29a6e11

9 files changed

Lines changed: 733 additions & 1217 deletions

File tree

dist/virtualfs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 662 additions & 1156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
],
3737
"devDependencies": {
3838
"browser-mime": "1.0.1",
39-
"eslint": "5.16.0",
39+
"eslint": "8.19.0",
4040
"filer": "1.4.1",
4141
"http-server": "14.1.0",
4242
"idb": "7.0.1",

src/filerlib_copy.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
const {ERR_CODES, Errors} = require('./errno');
2626
const ERROR_CODES = ERR_CODES.ERROR_CODES;
2727

28-
async function _stat(path) {
29-
return new Promise(async (resolve, reject) => {
28+
function _stat(path) {
29+
return new Promise((resolve, reject) => {
3030
fs.stat(path, async (err, stat) => {
3131
if(err && err.code === ERROR_CODES.ENOENT){
3232
resolve(null);
@@ -39,8 +39,8 @@ async function _stat(path) {
3939
});
4040
}
4141

42-
async function _mkdirIfNotPresent(path) {
43-
return new Promise(async (resolve, reject) => {
42+
function _mkdirIfNotPresent(path) {
43+
return new Promise((resolve, reject) => {
4444
fs.mkdir(path, async (err) => {
4545
err && err.code !== ERROR_CODES.EEXIST?
4646
reject(err):
@@ -49,9 +49,9 @@ async function _mkdirIfNotPresent(path) {
4949
});
5050
}
5151

52-
async function _readDir(path) {
53-
return new Promise(async (resolve, reject) => {
54-
fs.readdir(path, async (err, listing) => {
52+
function _readDir(path) {
53+
return new Promise((resolve, reject) => {
54+
fs.readdir(path, (err, listing) => {
5555
if(err) {
5656
reject(err);
5757
} else {
@@ -61,9 +61,9 @@ async function _readDir(path) {
6161
});
6262
}
6363

64-
async function _copyFileContents(src, dst) {
65-
return new Promise(async (resolve, reject) => {
66-
fs.readFile(src, async (err, data) => {
64+
function _copyFileContents(src, dst) {
65+
return new Promise((resolve, reject) => {
66+
fs.readFile(src, (err, data) => {
6767
if(err) {
6868
reject(err);
6969
} else {

src/fslib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global process, globalObject*/
20+
/*global globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

src/fslib_mounts.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global BroadcastChannel, globalObject*/
20+
/*global globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -162,18 +162,23 @@ function _getNewMountName(handleToMount) {
162162
* @private
163163
*/
164164
function _mountHandle(handleToMount) {
165-
return new Promise(async (resolve, reject) => {
166-
let path = await _getPathIfAlreadyMounted(handleToMount);
167-
if(path){
168-
resolve(path);
169-
} else {
170-
let mountName = _getNewMountName(handleToMount);
171-
if(!mountName) {
172-
reject('Mount name not fount');
165+
return new Promise(async (resolve, reject) => { // eslint-disable-line
166+
// eslint async executors are needed here. we explicitly catch so it's fine.
167+
try{
168+
let path = await _getPathIfAlreadyMounted(handleToMount);
169+
if(path){
170+
resolve(path);
173171
} else {
174-
await MountPointsStore.addMountPoint(mountName, handleToMount);
175-
resolve(`${Constants.MOUNT_POINT_ROOT}/${mountName}`);
172+
let mountName = _getNewMountName(handleToMount);
173+
if(!mountName) {
174+
reject('Mount name not fount');
175+
} else {
176+
await MountPointsStore.addMountPoint(mountName, handleToMount);
177+
resolve(`${Constants.MOUNT_POINT_ROOT}/${mountName}`);
178+
}
176179
}
180+
} catch (e) {
181+
reject(e);
177182
}
178183
});
179184
}

src/fslib_native.js

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global TextDecoder, buffer, globalObject*/
20+
/*global buffer, globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -261,41 +261,46 @@ async function unlink(path, callback) {
261261
}
262262

263263
async function _getDestinationHandleForCopy(dst, srcBaseName, handleKindToCreate) {
264-
return new Promise(async (resolve, reject) => {
265-
dst = globalObject.path.normalize(dst);
266-
let dirPath= globalObject.path.dirname(dst);
267-
let dstBaseName= globalObject.path.basename(dst);
268-
let dstHandle = await Mounts.getHandleFromPathIfPresent(dst);
269-
let dstParentHandle = await Mounts.getHandleFromPathIfPresent(dirPath);
270-
if (dstHandle && dstHandle.kind === Constants.KIND_FILE) {
271-
reject(new Errors.EEXIST(`Destination file already exists: ${dst}`));
272-
} else if (dstHandle && dstHandle.kind === Constants.KIND_DIRECTORY
273-
&& handleKindToCreate === Constants.KIND_FILE) {
274-
const fileHandle = await dstHandle.getFileHandle(srcBaseName, {create: true});
275-
const dstPath = `${dst}/${srcBaseName}`;
276-
resolve({handle: fileHandle, path:dstPath});
277-
} else if (dstHandle && dstHandle.kind === Constants.KIND_DIRECTORY
278-
&& handleKindToCreate === Constants.KIND_DIRECTORY) {
279-
let dstChildHandle = await Mounts.getHandleFromPathIfPresent(`${dst}/${srcBaseName}`);
280-
if(dstChildHandle){
281-
reject(new Errors.EEXIST(`Copy destination already exists: ${dst}/${srcBaseName}`));
282-
return;
264+
return new Promise(async (resolve, reject) => { // eslint-disable-line
265+
// eslint async executors are needed here. we explicitly catch so it's fine.
266+
try{
267+
dst = globalObject.path.normalize(dst);
268+
let dirPath= globalObject.path.dirname(dst);
269+
let dstBaseName= globalObject.path.basename(dst);
270+
let dstHandle = await Mounts.getHandleFromPathIfPresent(dst);
271+
let dstParentHandle = await Mounts.getHandleFromPathIfPresent(dirPath);
272+
if (dstHandle && dstHandle.kind === Constants.KIND_FILE) {
273+
reject(new Errors.EEXIST(`Destination file already exists: ${dst}`));
274+
} else if (dstHandle && dstHandle.kind === Constants.KIND_DIRECTORY
275+
&& handleKindToCreate === Constants.KIND_FILE) {
276+
const fileHandle = await dstHandle.getFileHandle(srcBaseName, {create: true});
277+
const dstPath = `${dst}/${srcBaseName}`;
278+
resolve({handle: fileHandle, path:dstPath});
279+
} else if (dstHandle && dstHandle.kind === Constants.KIND_DIRECTORY
280+
&& handleKindToCreate === Constants.KIND_DIRECTORY) {
281+
let dstChildHandle = await Mounts.getHandleFromPathIfPresent(`${dst}/${srcBaseName}`);
282+
if(dstChildHandle){
283+
reject(new Errors.EEXIST(`Copy destination already exists: ${dst}/${srcBaseName}`));
284+
return;
285+
}
286+
const directoryHandle = await dstHandle.getDirectoryHandle(srcBaseName, {create: true});
287+
const dstPath = `${dst}/${srcBaseName}`;
288+
resolve({handle: directoryHandle, path: dstPath});
289+
} else if (!dstHandle && dstParentHandle && dstParentHandle.kind === Constants.KIND_DIRECTORY
290+
&& handleKindToCreate === Constants.KIND_FILE) {
291+
const fileHandle = await dstParentHandle.getFileHandle(dstBaseName, {create: true});
292+
const dstPath = `${dirPath}/${dstBaseName}`;
293+
resolve({handle: fileHandle, path: dstPath});
294+
} else if (!dstHandle && dstParentHandle && dstParentHandle.kind === Constants.KIND_DIRECTORY
295+
&& handleKindToCreate === Constants.KIND_DIRECTORY) {
296+
const fileHandle = await dstParentHandle.getDirectoryHandle(dstBaseName, {create: true});
297+
const dstPath = `${dirPath}/${dstBaseName}`;
298+
resolve({handle: fileHandle, path: dstPath});
299+
} else {
300+
reject(new Errors.ENOENT(`Copy destination doesnt exist: ${dst}`));
283301
}
284-
const directoryHandle = await dstHandle.getDirectoryHandle(srcBaseName, {create: true});
285-
const dstPath = `${dst}/${srcBaseName}`;
286-
resolve({handle: directoryHandle, path: dstPath});
287-
} else if (!dstHandle && dstParentHandle && dstParentHandle.kind === Constants.KIND_DIRECTORY
288-
&& handleKindToCreate === Constants.KIND_FILE) {
289-
const fileHandle = await dstParentHandle.getFileHandle(dstBaseName, {create: true});
290-
const dstPath = `${dirPath}/${dstBaseName}`;
291-
resolve({handle: fileHandle, path: dstPath});
292-
} else if (!dstHandle && dstParentHandle && dstParentHandle.kind === Constants.KIND_DIRECTORY
293-
&& handleKindToCreate === Constants.KIND_DIRECTORY) {
294-
const fileHandle = await dstParentHandle.getDirectoryHandle(dstBaseName, {create: true});
295-
const dstPath = `${dirPath}/${dstBaseName}`;
296-
resolve({handle: fileHandle, path: dstPath});
297-
} else {
298-
reject(new Errors.ENOENT(`Copy destination doesnt exist: ${dst}`));
302+
} catch (e) {
303+
reject(e);
299304
}
300305
});
301306
}

src/fslib_watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global BroadcastChannel, globalObject, virtualfs*/
20+
/*global globalObject, virtualfs*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

0 commit comments

Comments
 (0)