fixing remix-url-resolver lint errors

pull/4771/head
lianahus 6 months ago
parent ca4ac3abf3
commit 4fe4b7f97e
  1. 13
      libs/remix-url-resolver/src/resolve.ts
  2. 8
      libs/remix-url-resolver/tests/test.ts

@ -64,7 +64,7 @@ export class RemixURLResolver {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}` const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}`
const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) const response: AxiosResponse = await axios.get(req, { transformResponse: []})
return { content: response.data, cleanUrl: root + '/' + filePath } return { content: response.data, cleanUrl: root + '/' + filePath }
} catch (e) { } catch (e) {
throw e throw e
@ -79,7 +79,7 @@ export class RemixURLResolver {
async handleHttp(url: string, cleanUrl: string): Promise<HandlerResponse> { async handleHttp(url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) const response: AxiosResponse = await axios.get(url, { transformResponse: []})
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -94,7 +94,7 @@ export class RemixURLResolver {
async handleHttps(url: string, cleanUrl: string): Promise<HandlerResponse> { async handleHttps(url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) const response: AxiosResponse = await axios.get(url, { transformResponse: []})
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -106,7 +106,7 @@ export class RemixURLResolver {
try { 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 url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' })
const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) const response: AxiosResponse = await axios.get(url, { transformResponse: []})
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -125,7 +125,7 @@ export class RemixURLResolver {
const req = 'https://jqgt.remixproject.org/' + url const req = 'https://jqgt.remixproject.org/' + url
// If you don't find greeter.sol on ipfs gateway use local // If you don't find greeter.sol on ipfs gateway use local
// const req = 'http://localhost:8080/' + url // const req = 'http://localhost:8080/' + url
const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) const response: AxiosResponse = await axios.get(req, { transformResponse: []})
return { content: response.data, cleanUrl: url.replace('ipfs/', '') } return { content: response.data, cleanUrl: url.replace('ipfs/', '') }
} catch (e) { } catch (e) {
throw e throw e
@ -190,7 +190,7 @@ export class RemixURLResolver {
for (let i = 0; i < npm_urls.length; i++) { for (let i = 0; i < npm_urls.length; i++) {
try { try {
const req = npm_urls[i] + url const req = npm_urls[i] + url
const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) const response: AxiosResponse = await axios.get(req, { transformResponse: []})
content = response.data content = response.data
break break
} catch (e) { } catch (e) {
@ -201,7 +201,6 @@ export class RemixURLResolver {
if (!content) throw new Error('Unable to load ' + url) if (!content) throw new Error('Unable to load ' + url)
return { content, cleanUrl: url } return { content, cleanUrl: url }
} }
getHandlers (): Handler[] { getHandlers (): Handler[] {
return [ return [

@ -109,7 +109,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => { it('should return contract content of given github path', () => {
const expt: object = { const expt: object = {
cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol',
content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}), content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }),
type: 'github' type: 'github'
} }
assert.deepEqual(results, expt) assert.deepEqual(results, expt)
@ -139,7 +139,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => { it('should return contract content of given github path', () => {
const expt: object = { const expt: object = {
cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol',
content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) + '\n', content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }) + '\n',
type: 'github' type: 'github'
} }
assert.deepEqual(results, expt) assert.deepEqual(results, expt)
@ -169,7 +169,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => { it('should return contract content of given github path', () => {
const expt: object = { const expt: object = {
cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol',
content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}), content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }),
type: 'github' type: 'github'
} }
assert.deepEqual(results, expt) assert.deepEqual(results, expt)
@ -257,7 +257,7 @@ describe('testRunner', () => {
assert.equal(Object.keys(results).length, 3) assert.equal(Object.keys(results).length, 3)
}) })
it('should return contract content from IPFS url', () => { it('should return contract content from IPFS url', () => {
const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' })
const expt: object = { const expt: object = {
content: content, content: content,
cleanUrl: 'QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M', cleanUrl: 'QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M',

Loading…
Cancel
Save