From e209a820982e860f014d1576f12716233e9f1aa2 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 7 Jul 2020 16:46:15 +0530 Subject: [PATCH] lint working for remix-url-resolver --- libs/remix-url-resolver/.eslintrc | 16 +++++++++++++++ libs/remix-url-resolver/src/resolve.ts | 8 ++++++-- libs/remix-url-resolver/tsconfig.json | 24 ++++++----------------- libs/remix-url-resolver/tsconfig.lib.json | 16 +++++++++++++++ workspace.json | 18 ++++++----------- 5 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 libs/remix-url-resolver/.eslintrc create mode 100644 libs/remix-url-resolver/tsconfig.lib.json diff --git a/libs/remix-url-resolver/.eslintrc b/libs/remix-url-resolver/.eslintrc new file mode 100644 index 0000000000..a9c68a76de --- /dev/null +++ b/libs/remix-url-resolver/.eslintrc @@ -0,0 +1,16 @@ +{ + "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" + }, + "env": { + "browser": true, + "amd": true, + "node": true, + "es6": true + }, + "ignorePatterns": ["!**/*"] +} \ No newline at end of file diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index adc3f650d1..1868d77c0a 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -27,8 +27,9 @@ export class RemixURLResolver { * @params filePath path of the file in github */ async handleGithubCall(root: string, filePath: string) { + //eslint-disable-next-line no-useless-catch try { - let req: string = 'https://api.github.com/repos/' + root + '/contents/' + filePath + const req: string = 'https://api.github.com/repos/' + root + '/contents/' + filePath const response: AxiosResponse = await axios.get(req) return Buffer.from(response.data.content, 'base64').toString() } catch(e) { @@ -41,6 +42,7 @@ export class RemixURLResolver { * @params cleanURL */ async handleHttp(url: string, _: string) { + //eslint-disable-next-line no-useless-catch try { const response: AxiosResponse = await axios.get(url) return response.data @@ -54,6 +56,7 @@ export class RemixURLResolver { * @params cleanURL */ async handleHttps(url: string, _: string) { + //eslint-disable-next-line no-useless-catch try { const response: AxiosResponse = await axios.get(url) return response.data @@ -71,6 +74,7 @@ export class RemixURLResolver { async handleIPFS(url: string) { // replace ipfs:// with /ipfs/ url = url.replace(/^ipfs:\/\/?/, 'ipfs/') + //eslint-disable-next-line no-useless-catch try { const req = 'https://gateway.ipfs.io/' + url // If you don't find greeter.sol on ipfs gateway use local @@ -112,7 +116,7 @@ export class RemixURLResolver { } public async resolve(filePath: string, customHandlers?: Handler[]): Promise { - var imported: Imported = this.previouslyHandled[filePath] + let imported: Imported = this.previouslyHandled[filePath] if(imported) { return imported } diff --git a/libs/remix-url-resolver/tsconfig.json b/libs/remix-url-resolver/tsconfig.json index 4a075211c5..12516f33dd 100644 --- a/libs/remix-url-resolver/tsconfig.json +++ b/libs/remix-url-resolver/tsconfig.json @@ -1,21 +1,9 @@ { - "compileOnSave": false, - "include": ["./src"], + "extends": "../../tsconfig.json", "compilerOptions": { - "baseUrl": "./src", - "outDir": "./dist", - "sourceMap": true, - "declaration": true, + "types": ["node"], "module": "commonjs", - "strict": true, - "noImplicitAny": false, - "strictPropertyInitialization": false, - "experimentalDecorators": true, - "target": "es5", - "typeRoots": ["node_modules/@types"], - "lib": ["dom", "es2018"], - "paths": { - "remix-url-resolver": ["./"] - } - } -} \ No newline at end of file + "esModuleInterop": true + }, + "include": ["**/*.ts"] +} diff --git a/libs/remix-url-resolver/tsconfig.lib.json b/libs/remix-url-resolver/tsconfig.lib.json new file mode 100644 index 0000000000..ea82c38ae0 --- /dev/null +++ b/libs/remix-url-resolver/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": [ + "**/*.spec.ts", + "tests/" + ], + "include": ["**/*.ts"] + } + \ No newline at end of file diff --git a/workspace.json b/workspace.json index a165f9b6f0..f9c8a6eab8 100644 --- a/workspace.json +++ b/workspace.json @@ -354,23 +354,20 @@ "schematics": {}, "architect": { "lint": { - "builder": "@nrwl/workspace:run-commands", + "builder": "@nrwl/linter:lint", "options": { - "commands": [ - { - "command": "./../../node_modules/.bin/npm-run-all lint" - } + "linter": "eslint", + "config": "libs/remix-url-resolver/.eslintrc", + "tsConfig": [ + "libs/remix-url-resolver/tsconfig.lib.json" ], - "cwd": "libs/remix-url-resolver" + "exclude": ["**/node_modules/**", "libs/remix-url-resolver/tests/**/*"] } }, "test": { "builder": "@nrwl/workspace:run-commands", "options": { "commands": [ - { - "command": "rm -rf ../../dist" - }, { "command": "./../../node_modules/.bin/npm-run-all test" } @@ -382,9 +379,6 @@ "builder": "@nrwl/workspace:run-commands", "options": { "commands": [ - { - "command": "rm -rf ../../dist" - }, { "command": "./../../node_modules/.bin/npm-run-all build" }