linting for remix-url-resolver done

pull/861/head
aniket-engg 4 years ago
parent 2877354871
commit dfbd140af8
  1. 7
      libs/remix-url-resolver/.eslintrc
  2. 10
      libs/remix-url-resolver/src/resolve.ts
  3. 2
      package.json

@ -1,11 +1,6 @@
{
"extends": "../../.eslintrc",
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"rules": {},
"env": {
"browser": true,
"amd": true,

@ -1,3 +1,4 @@
// eslint-disable-next-line no-unused-vars
import axios, { AxiosResponse } from 'axios'
import { BzzNode as Bzz } from '@erebos/bzz-node'
@ -29,7 +30,7 @@ export class RemixURLResolver {
constructor (gistToken?: string, protocol = 'http:') {
this.previouslyHandled = {}
this.gistAccessToken = gistToken ? gistToken : ''
this.gistAccessToken = gistToken || ''
this.protocol = protocol
}
@ -39,15 +40,12 @@ export class RemixURLResolver {
* @param filePath path of the file in github
*/
async handleGithubCall (root: string, filePath: string): Promise<HandlerResponse> {
let param = '?'
param += this.gistAccessToken ? 'access_token=' + this.gistAccessToken : ''
const regex = filePath.match(/blob\/([^/]+)\/(.*)/)
let reference = 'master'
if (regex) {
// if we have /blob/master/+path we extract the branch name "master" and add it as a parameter to the github api
// the ref can be branch name, tag, commit id
reference = regex[1]
param += '&ref=' + reference
filePath = filePath.replace(`blob/${reference}/`, '')
}
// eslint-disable-next-line no-useless-catch
@ -93,7 +91,7 @@ export class RemixURLResolver {
async handleSwarm (url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch
try {
const bzz = new Bzz({url: this.protocol + '//swarm-gateways.net'});
const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' })
const url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' })
const response: AxiosResponse = await axios.get(url)
return { content: response.data, cleanUrl }
@ -184,7 +182,7 @@ export class RemixURLResolver {
const { content, cleanUrl } = await handler.handle(match)
imported = {
content,
cleanUrl : cleanUrl ? cleanUrl : filePath,
cleanUrl: cleanUrl || filePath,
type: handler.type
}
this.previouslyHandled[filePath] = imported

@ -41,7 +41,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,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui",
"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-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui",
"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",

Loading…
Cancel
Save