Fixed linting error

pull/454/head
ioedeveloper 4 years ago
parent 5b7f9a2577
commit 7dc8360a09
  1. 11
      .eslintrc.json
  2. 121
      package-lock.json
  3. 4
      package.json
  4. 2
      src/serviceList.ts
  5. 8
      src/services/remixdClient.ts
  6. 6
      src/utils.ts
  7. 14
      src/websocket.ts

@ -5,16 +5,17 @@
"es6": true "es6": true
}, },
"extends": [ "extends": [
"standard" "plugin:@typescript-eslint/recommended"
], ],
"globals": { "globals": {
"Atomics": "readonly", "Atomics": "readonly",
"SharedArrayBuffer": "readonly" "SharedArrayBuffer": "readonly"
}, },
"parserOptions": { "parser": "@typescript-eslint/parser",
"ecmaVersion": 2018 "plugins": ["@typescript-eslint"],
},
"rules": { "rules": {
"standard/no-callback-literal": 0 "standard/no-callback-literal": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/ban-types": 0
} }
} }

121
package-lock.json generated

@ -133,6 +133,18 @@
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ=="
}, },
"@types/eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
"dev": true
},
"@types/json-schema": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz",
"integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==",
"dev": true
},
"@types/node": { "@types/node": {
"version": "14.0.5", "version": "14.0.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.5.tgz",
@ -148,6 +160,106 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@typescript-eslint/eslint-plugin": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.2.0.tgz",
"integrity": "sha512-t9RTk/GyYilIXt6BmZurhBzuMT9kLKw3fQoJtK9ayv0tXTlznXEAnx07sCLXdkN3/tZDep1s1CEV95CWuARYWA==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "3.2.0",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"regexpp": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"@typescript-eslint/experimental-utils": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.2.0.tgz",
"integrity": "sha512-UbJBsk+xO9dIFKtj16+m42EvUvsjZbbgQ2O5xSTSfVT1Z3yGkL90DVu0Hd3029FZ5/uBgl+F3Vo8FAcEcqc6aQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "3.2.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz",
"integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
}
}
},
"@typescript-eslint/parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.2.0.tgz",
"integrity": "sha512-Vhu+wwdevDLVDjK1lIcoD6ZbuOa93fzqszkaO3iCnmrScmKwyW/AGkzc2UvfE5TCoCXqq7Jyt6SOXjsIlpqF4A==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "3.2.0",
"@typescript-eslint/typescript-estree": "3.2.0",
"eslint-visitor-keys": "^1.1.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.2.0.tgz",
"integrity": "sha512-uh+Y2QO7dxNrdLw7mVnjUqkwO/InxEqwN0wF+Za6eo3coxls9aH9kQ/5rSvW2GcNanebRTmsT5w1/92lAOb1bA==",
"dev": true,
"requires": {
"debug": "^4.1.1",
"eslint-visitor-keys": "^1.1.0",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dev": true,
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -3522,6 +3634,15 @@
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true "dev": true
}, },
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"type-check": { "type-check": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",

@ -10,7 +10,7 @@
"test": "echo \"Error: no test specified\"", "test": "echo \"Error: no test specified\"",
"start": "./lib/bin/remixd.js -s ./shared --remix-ide http://127.0.0.1:8080", "start": "./lib/bin/remixd.js -s ./shared --remix-ide http://127.0.0.1:8080",
"npip": "npip", "npip": "npip",
"lint": "eslint ./src", "lint": "eslint ./src --ext .ts",
"build": "tsc -p ./ && chmod +x ./lib/bin/remixd.js", "build": "tsc -p ./ && chmod +x ./lib/bin/remixd.js",
"dev": "nodemon" "dev": "nodemon"
}, },
@ -49,6 +49,8 @@
"devDependencies": { "devDependencies": {
"@types/node": "^14.0.5", "@types/node": "^14.0.5",
"@types/ws": "^7.2.4", "@types/ws": "^7.2.4",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"eslint": "6.8.0", "eslint": "6.8.0",
"eslint-config-standard": "14.1.1", "eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.20.2", "eslint-plugin-import": "2.20.2",

@ -1,3 +1,3 @@
import { RemixdClient as sharedfolder } from './services/remixdClient' import { RemixdClient as sharedfolder } from './services/remixdClient'
export { sharedfolder } export { sharedfolder }

@ -21,7 +21,7 @@ export class RemixdClient extends PluginClient {
this.readOnly = readOnly this.readOnly = readOnly
} }
list (args: SharedFolderArgs): Filelist { list (): Filelist {
try { try {
return utils.walkSync(this.currentSharedFolder, {}, this.currentSharedFolder) return utils.walkSync(this.currentSharedFolder, {}, this.currentSharedFolder)
} catch (e) { } catch (e) {
@ -97,7 +97,7 @@ export class RemixdClient extends PluginClient {
fs.mkdirp(path).then(() => resolve()).catch((e: Error) => reject(e)) fs.mkdirp(path).then(() => resolve()).catch((e: Error) => reject(e))
} else { } else {
fs.ensureFile(path).then(() => { fs.ensureFile(path).then(() => {
fs.writeFile(path, args.content, 'utf8', (error: Error, data: string) => { fs.writeFile(path, args.content, 'utf8', (error: Error) => {
if (error) { if (error) {
console.log(error) console.log(error)
reject(error) reject(error)
@ -124,7 +124,7 @@ export class RemixdClient extends PluginClient {
const newpath = utils.absolutePath(args.newPath, this.currentSharedFolder) const newpath = utils.absolutePath(args.newPath, this.currentSharedFolder)
if (!isRealPath(oldpath)) return if (!isRealPath(oldpath)) return
fs.move(oldpath, newpath, (error: Error, data: string) => { fs.move(oldpath, newpath, (error: Error) => {
if (error) { if (error) {
console.log(error) console.log(error)
reject(error.message) reject(error.message)
@ -145,7 +145,7 @@ export class RemixdClient extends PluginClient {
if (!fs.existsSync(path)) reject('File not found ' + path) if (!fs.existsSync(path)) reject('File not found ' + path)
if (!isRealPath(path)) return if (!isRealPath(path)) return
return fs.remove(path, (error: Error, data: string) => { return fs.remove(path, (error: Error) => {
if (error) { if (error) {
console.log(error) console.log(error)
reject('Failed to remove file/directory: ' + error) reject('Failed to remove file/directory: ' + error)

@ -45,12 +45,14 @@ function walkSync (dir: string, filelist: Filelist, sharedFolder: string): Filel
filelist = filelist || {} filelist = filelist || {}
files.forEach(function (file) { files.forEach(function (file) {
var subElement = path.join(dir, file) const subElement = path.join(dir, file)
if (!fs.lstatSync(subElement).isSymbolicLink()) { if (!fs.lstatSync(subElement).isSymbolicLink()) {
if (fs.statSync(subElement).isDirectory()) { if (fs.statSync(subElement).isDirectory()) {
filelist = walkSync(subElement, filelist, sharedFolder) filelist = walkSync(subElement, filelist, sharedFolder)
} else { } else {
var relative = relativePath(subElement, sharedFolder) const relative = relativePath(subElement, sharedFolder)
filelist[relative] = isbinaryfile.sync(subElement) filelist[relative] = isbinaryfile.sync(subElement)
} }
} }

@ -11,9 +11,7 @@ export default class WebSocket {
constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {} constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {}
start (callback?: Function) { start (callback?: Function): void {
const obj = this
this.server = http.createServer((request, response) => { this.server = http.createServer((request, response) => {
console.log((new Date()) + ' Received request for ' + request.url) console.log((new Date()) + ' Received request for ' + request.url)
response.writeHead(404) response.writeHead(404)
@ -35,16 +33,16 @@ export default class WebSocket {
done(true) done(true)
} }
}) })
this.wsServer.on('connection', function connection(ws, request) { this.wsServer.on('connection', (ws) => {
const { sharedFolder } = obj const { sharedFolder } = this
obj.connection = ws this.connection = ws
buildWebsocketClient(ws, sharedFolder) buildWebsocketClient(ws, sharedFolder)
if(callback) callback(ws) if(callback) callback(ws)
}) })
} }
close () { close (): void {
if (this.wsServer) { if (this.wsServer) {
this.wsServer.close(() => { this.wsServer.close(() => {
this.server.close() this.server.close()
@ -53,6 +51,6 @@ export default class WebSocket {
} }
} }
function originIsAllowed (origin: string, self: WebSocket) { function originIsAllowed (origin: string, self: WebSocket): boolean {
return origin === self.opt.remixIdeUrl return origin === self.opt.remixIdeUrl
} }

Loading…
Cancel
Save