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

@ -109,7 +109,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => {
const expt: object = {
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'
}
assert.deepEqual(results, expt)
@ -139,7 +139,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => {
const expt: object = {
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'
}
assert.deepEqual(results, expt)
@ -169,7 +169,7 @@ describe('testRunner', () => {
it('should return contract content of given github path', () => {
const expt: object = {
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'
}
assert.deepEqual(results, expt)
@ -257,7 +257,7 @@ describe('testRunner', () => {
assert.equal(Object.keys(results).length, 3)
})
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 = {
content: content,
cleanUrl: 'QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M',

Loading…
Cancel
Save