Fixed remixd linting errors

standard
ioedeveloper 4 years ago committed by yann300
parent 1af16b14f1
commit 549ff0ef9f
  1. 3
      .circleci/config.yml
  2. 24
      libs/remixd/src/bin/remixd.ts
  3. 4
      libs/remixd/src/serviceList.ts
  4. 24
      libs/remixd/src/services/remixdClient.ts
  5. 4
      libs/remixd/src/utils.ts
  6. 6
      libs/remixd/src/websocket.ts
  7. 3
      package.json
  8. 1
      tsconfig.json

@ -47,6 +47,7 @@ jobs:
- checkout
- run: npm install
- run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs
- run: npm run downloadsolc_root
- run: npm run build
@ -84,6 +85,7 @@ jobs:
- checkout
- run: npm install
- run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs
- run: npm run downloadsolc_root
- run: npm run build
@ -126,6 +128,7 @@ jobs:
- checkout
- run: npm install
- run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs
- run: npm run downloadsolc_root
- run: npm run build

@ -1,7 +1,7 @@
#!/usr/bin/env node
import WebSocket from '../websocket'
import * as servicesList from '../serviceList'
import * as WS from 'ws'
import * as WS from 'ws' // eslint-disable-line
import { getDomain } from '../utils'
import Axios from 'axios'
import * as fs from 'fs-extra'
@ -10,14 +10,14 @@ import * as program from 'commander'
(async () => {
program
.usage('-s <shared folder>')
.description('Provide a two-way connection between the local computer and Remix IDE')
.option('--remix-ide <url>', 'URL of remix instance allowed to connect to this web sockect connection')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
.option('--read-only', 'Treat shared folder as read-only (experimental)')
.on('--help', function(){
console.log('\nExample:\n\n remixd -s ./ --remix-ide http://localhost:8080')
}).parse(process.argv)
.usage('-s <shared folder>')
.description('Provide a two-way connection between the local computer and Remix IDE')
.option('--remix-ide <url>', 'URL of remix instance allowed to connect to this web sockect connection')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
.option('--read-only', 'Treat shared folder as read-only (experimental)')
.on('--help', function () {
console.log('\nExample:\n\n remixd -s ./ --remix-ide http://localhost:8080')
}).parse(process.argv)
// eslint-disable-next-line
const killCallBack: Array<Function> = []
@ -38,7 +38,7 @@ import * as program from 'commander'
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')
try {
const sharedFolderClient = new servicesList['sharedfolder']()
const sharedFolderClient = new servicesList.Sharedfolder()
const websocketHandler = new WebSocket(65520, { remixIdeUrl: program.remixIde }, sharedFolderClient)
websocketHandler.start((ws: WS) => {
@ -47,7 +47,7 @@ import * as program from 'commander'
sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false)
})
killCallBack.push(websocketHandler.close.bind(websocketHandler))
} catch(error) {
} catch (error) {
throw new Error(error)
}
} else {
@ -78,7 +78,7 @@ import * as program from 'commander'
const { data } = await Axios.get(gistUrl)
try {
await fs.writeJSON(path.resolve(__dirname + '/../origins.json'), { data })
await fs.writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data })
} catch (e) {
console.error(e)
}

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

@ -1,6 +1,6 @@
import { PluginClient } from '@remixproject/plugin'
import { SharedFolderArgs, TrackDownStreamUpdate, Filelist, ResolveDirectory, FileContent } from '../types'
import * as WS from 'ws'
import { SharedFolderArgs, TrackDownStreamUpdate, Filelist, ResolveDirectory, FileContent } from '../types' // eslint-disable-line
import * as WS from 'ws' // eslint-disable-line
import * as utils from '../utils'
import * as chokidar from 'chokidar'
import * as fs from 'fs-extra'
@ -51,7 +51,7 @@ export class RemixdClient extends PluginClient {
const path = utils.absolutePath(args.path, this.currentSharedFolder)
if (!fs.existsSync(path)) {
return reject('File not found ' + path)
return reject(new Error('File not found ' + path))
}
if (!isRealPath(path)) return
isbinaryfile(path, (error: Error, isBinary: boolean) => {
@ -76,7 +76,7 @@ export class RemixdClient extends PluginClient {
const path = utils.absolutePath(args.path, this.currentSharedFolder)
return fs.existsSync(path)
} catch(error) {
} catch (error) {
throw new Error(error)
}
}
@ -84,15 +84,15 @@ export class RemixdClient extends PluginClient {
set (args: SharedFolderArgs): Promise<void> {
try {
return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot write file: read-only mode selected')
if (this.readOnly) reject(new Error('Cannot write file: read-only mode selected'))
const isFolder = args.path.endsWith('/')
const path = utils.absolutePath(args.path, this.currentSharedFolder)
const exists = fs.existsSync(path)
if (exists && !isRealPath(path)) reject()
if (exists && !isRealPath(path)) reject(new Error(''))
if (args.content === 'undefined') { // no !!!!!
console.log('trying to write "undefined" ! stopping.')
reject('trying to write "undefined" ! stopping.')
reject(new Error('trying to write "undefined" ! stopping.'))
}
this.trackDownStreamUpdate[path] = path
if (isFolder) {
@ -130,11 +130,11 @@ export class RemixdClient extends PluginClient {
rename (args: SharedFolderArgs): Promise<boolean> {
try {
return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot rename file: read-only mode selected')
if (this.readOnly) reject(new Error('Cannot rename file: read-only mode selected'))
const oldpath = utils.absolutePath(args.oldPath, this.currentSharedFolder)
if (!fs.existsSync(oldpath)) {
reject('File not found ' + oldpath)
reject(new Error('File not found ' + oldpath))
}
const newpath = utils.absolutePath(args.newPath, this.currentSharedFolder)
@ -156,15 +156,15 @@ export class RemixdClient extends PluginClient {
remove (args: SharedFolderArgs): Promise<boolean> {
try {
return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot remove file: read-only mode selected')
if (this.readOnly) reject(new Error('Cannot remove file: read-only mode selected'))
const path = utils.absolutePath(args.path, this.currentSharedFolder)
if (!fs.existsSync(path)) reject('File not found ' + path)
if (!fs.existsSync(path)) reject(new Error('File not found ' + path))
if (!isRealPath(path)) return
return fs.remove(path, (error: Error) => {
if (error) {
console.log(error)
reject('Failed to remove file/directory: ' + error)
reject(new Error('Failed to remove file/directory: ' + error))
}
this.emit('fileRemoved', args.path)
resolve(true)

@ -1,4 +1,4 @@
import { ResolveDirectory, Filelist } from './types'
import { ResolveDirectory, Filelist } from './types' // eslint-disable-line
import * as fs from 'fs-extra'
import * as isbinaryfile from 'isbinaryfile'
import * as pathModule from 'path'
@ -79,7 +79,7 @@ function resolveDirectory (dir: string, sharedFolder: string): ResolveDirectory
* @param {String} url - Remix-IDE URL instance
* @return {String} extracted domain name from url
*/
function getDomain(url: string) {
function getDomain (url: string) {
// eslint-disable-next-line
const domainMatch = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/img)

@ -1,13 +1,13 @@
import * as WS from 'ws'
import * as http from 'http'
import { WebsocketOpt, SharedFolderClient } from './types'
import { WebsocketOpt, SharedFolderClient } from './types' // eslint-disable-line
import { getDomain } from './utils'
import { createClient } from '@remixproject/plugin-ws'
export default class WebSocket {
server: http.Server
wsServer: WS.Server
constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {}
constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {} //eslint-disable-line
start (callback?: (ws: WS) => void): void {
this.server = http.createServer((request, response) => {
@ -35,7 +35,7 @@ export default class WebSocket {
const { sharedFolder } = this
createClient(ws, sharedFolder as any)
if(callback) callback(ws)
if (callback) callback(ws)
})
}

@ -43,7 +43,7 @@
"workspace-schematic": "nx workspace-schematic",
"dep-graph": "nx dep-graph",
"help": "nx help",
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-debugger-ui,remix-ui-utils,remix-ui-clipboard",
"build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"publish:libs": "npm run build:libs; lerna publish --skip-git; npm run bumpVersion:libs",
@ -182,7 +182,6 @@
"@types/axios": "^0.14.0",
"@types/chai": "^4.2.11",
"@types/fs-extra": "^9.0.1",
"@types/jest": "25.1.4",
"@types/mocha": "^7.0.2",
"@types/nightwatch": "^1.1.6",
"@types/node": "~8.9.4",

@ -25,7 +25,6 @@
"@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"],
"@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"],
"@remix-project/remixd": ["dist/libs/remixd/index.js"],
"@remix-project/debugger-ui": ["libs/debugger-ui/src/index.ts"],
"@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"],
"@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"],
"@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"],

Loading…
Cancel
Save