From bc6166a288cc628602e30740915f4ed7a39a152d Mon Sep 17 00:00:00 2001 From: Pranjal Walia Date: Sat, 16 Apr 2022 04:27:37 +0530 Subject: [PATCH] chore: fixed linter errors in generator - fixed all linter errors produced by new eslint config - pending 140 linter warnings (large change) that can be fixed post approval from project mentors --- generator/{generators => }/.eslintrc | 5 ++++- generator/generators/aws/generator.ts | 3 ++- generator/generators/azure/generator.ts | 5 +++-- generator/generators/do/generator.ts | 3 ++- generator/generators/googleCloud/generator.ts | 7 ++++--- generator/generators/lib/helper.ts | 11 +++++------ generator/main.ts | 5 +++-- generator/test/generators/aws/generator.test.ts | 5 +++-- generator/test/generators/azure/generator.test.ts | 5 +++-- generator/test/generators/do/generator.test.ts | 5 +++-- .../test/generators/googleCloud/generator.test.ts | 3 ++- generator/test/generators/lib/helper.ts | 2 +- generator/test/parsers/aws/parser.test.ts | 3 ++- generator/test/parsers/azure/parser.test.ts | 3 ++- generator/test/parsers/do/parser.test.ts | 3 ++- generator/test/parsers/googleCloud/parser.test.ts | 3 ++- generator/test/transformers/aws/transformer.test.ts | 3 ++- generator/test/transformers/azure/transformer.test.ts | 3 ++- generator/test/transformers/do/transformer.test.ts | 3 ++- .../googleCloud/classBasedTransformer.test.ts | 3 ++- .../googleCloud/clientBasedTransformer.test.ts | 3 ++- generator/test/transformers/lib/helper.ts | 2 +- generator/transformers/aws/transformer.ts | 2 +- generator/transformers/azure/transformer.ts | 2 +- generator/transformers/do/transformer.ts | 2 +- .../transformers/googleCloud/classBasedTransformer.ts | 2 +- .../googleCloud/clientBasedTransformer.ts | 2 +- package.json | 2 +- 28 files changed, 60 insertions(+), 40 deletions(-) rename generator/{generators => }/.eslintrc (64%) diff --git a/generator/generators/.eslintrc b/generator/.eslintrc similarity index 64% rename from generator/generators/.eslintrc rename to generator/.eslintrc index 4f8ba3b6..d04aa91b 100644 --- a/generator/generators/.eslintrc +++ b/generator/.eslintrc @@ -5,5 +5,8 @@ "node_modules/", "dummyClasses/", "generatedClasses/" - ] + ], + "rules": { + "@typescript-eslint/no-empty-function": "warn" + } } diff --git a/generator/generators/aws/generator.ts b/generator/generators/aws/generator.ts index b35fd6ba..b46e1e31 100644 --- a/generator/generators/aws/generator.ts +++ b/generator/generators/aws/generator.ts @@ -1,8 +1,9 @@ import * as fs from "fs"; import { createSourceFile, ScriptTarget, SyntaxKind } from "typescript"; + import { getAST } from "../../parsers/aws/parser"; import { transform } from "../../transformers/aws/transformer"; -import { filters, groupers, printFile, getDir } from "../lib/helper"; +import { filters, getDir,groupers, printFile } from "../lib/helper"; interface FunctionData { functionName: string; diff --git a/generator/generators/azure/generator.ts b/generator/generators/azure/generator.ts index ebba8205..2aa27b60 100644 --- a/generator/generators/azure/generator.ts +++ b/generator/generators/azure/generator.ts @@ -1,8 +1,9 @@ import * as fs from "fs"; -import { SyntaxKind, createSourceFile, ScriptTarget } from "typescript"; +import { createSourceFile, ScriptTarget,SyntaxKind } from "typescript"; + import { getAST } from "../../parsers/azure/parser"; -import { groupers, filters, printFile, getDir } from "../lib/helper"; import { transform } from "../../transformers/azure/transformer"; +import { filters, getDir,groupers, printFile } from "../lib/helper"; interface FunctionData { pkgName: string; diff --git a/generator/generators/do/generator.ts b/generator/generators/do/generator.ts index 89868580..052b13e0 100644 --- a/generator/generators/do/generator.ts +++ b/generator/generators/do/generator.ts @@ -1,8 +1,9 @@ import * as fs from "fs"; import { createSourceFile, ScriptTarget, SyntaxKind } from "typescript"; + import { getAST } from "../../parsers/do/parser"; import { transform } from "../../transformers/do/transformer"; -import { printFile, getDir } from "../lib/helper"; +import { getDir,printFile } from "../lib/helper"; interface FunctionData { functionName: string; diff --git a/generator/generators/googleCloud/generator.ts b/generator/generators/googleCloud/generator.ts index 2a1972c4..9a2702cf 100644 --- a/generator/generators/googleCloud/generator.ts +++ b/generator/generators/googleCloud/generator.ts @@ -1,10 +1,11 @@ import * as fs from "fs"; import * as path from "path"; -import { SyntaxKind, createSourceFile, ScriptTarget } from "typescript"; +import { createSourceFile, ScriptTarget,SyntaxKind } from "typescript"; + import { getAST } from "../../parsers/googleCloud/parser"; -import { filters, groupers, printFile, getDir } from "../lib/helper"; -import { clientBasedTransform } from "../../transformers/googleCloud/clientBasedTransformer"; import { classBasedTransform } from "../../transformers/googleCloud/classBasedTransformer"; +import { clientBasedTransform } from "../../transformers/googleCloud/clientBasedTransformer"; +import { filters, getDir,groupers, printFile } from "../lib/helper"; interface ClassData { name: string; diff --git a/generator/generators/lib/helper.ts b/generator/generators/lib/helper.ts index 44558f3c..31c67b7c 100644 --- a/generator/generators/lib/helper.ts +++ b/generator/generators/lib/helper.ts @@ -1,12 +1,11 @@ import * as fs from "fs"; import { groupAWSMethods } from "../lib/aws/awsHelper"; -import { groupGCPMethods } from "../lib/googleCloud/gcpHelper"; -import { groupAzureMethods } from "../lib/azure/azureHelper"; - import { filterAWSMethods } from "../lib/aws/awsHelper"; -import { filterGCPMethods } from "../lib/googleCloud/gcpHelper"; +import { groupAzureMethods } from "../lib/azure/azureHelper"; import { filterAzureMethods } from "../lib/azure/azureHelper"; +import { groupGCPMethods } from "../lib/googleCloud/gcpHelper"; +import { filterGCPMethods } from "../lib/googleCloud/gcpHelper"; const dirMap = { appServices: ["PaaS"], @@ -38,7 +37,7 @@ const filters = { }; const getDir = (service: string): string => { - for (var dir in dirMap) { + for (let dir in dirMap) { if (dirMap[dir].includes(service)) { return dir; } @@ -46,4 +45,4 @@ const getDir = (service: string): string => { throw new Error("Not a valid service: " + service); }; -export { groupers, filters, getDir }; +export { filters, getDir,groupers }; diff --git a/generator/main.ts b/generator/main.ts index 4246cdd1..5374718c 100644 --- a/generator/main.ts +++ b/generator/main.ts @@ -1,9 +1,10 @@ -import * as yaml from "js-yaml"; import * as fs from "fs"; +import * as yaml from "js-yaml"; + import { generateAWSClass } from "./generators/aws/generator"; import { generateAzureClass } from "./generators/azure/generator"; -import { generateGCPClass } from "./generators/googleCloud/generator"; import { generateDOClass } from "./generators/do/generator"; +import { generateGCPClass } from "./generators/googleCloud/generator"; try { const services = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); diff --git a/generator/test/generators/aws/generator.test.ts b/generator/test/generators/aws/generator.test.ts index 964bb41c..965b9fe0 100644 --- a/generator/test/generators/aws/generator.test.ts +++ b/generator/test/generators/aws/generator.test.ts @@ -1,8 +1,9 @@ import { expect } from "chai"; -import { extractSDKData } from "../../../generators/aws/generator"; -import { readSourceFile, readJsonData } from "../lib/helper"; import { SyntaxKind } from "typescript"; +import { extractSDKData } from "../../../generators/aws/generator"; +import { readJsonData,readSourceFile } from "../lib/helper"; + describe("AWS generator extractSDKData", () => { context("with valid methods and valid AST", () => { it("should return extracted class data", async () => { diff --git a/generator/test/generators/azure/generator.test.ts b/generator/test/generators/azure/generator.test.ts index be036d77..e14197b9 100644 --- a/generator/test/generators/azure/generator.test.ts +++ b/generator/test/generators/azure/generator.test.ts @@ -1,7 +1,8 @@ import { expect } from "chai"; -import { extractSDKData } from "../../../generators/azure/generator"; import { SyntaxKind } from "typescript"; -import { readSourceFile, readJsonData } from "../lib/helper"; + +import { extractSDKData } from "../../../generators/azure/generator"; +import { readJsonData,readSourceFile } from "../lib/helper"; describe("Azure generator extractSDKData", () => { context("with valid methods and valid AST", () => { diff --git a/generator/test/generators/do/generator.test.ts b/generator/test/generators/do/generator.test.ts index a4d8cdd7..ce9de66d 100644 --- a/generator/test/generators/do/generator.test.ts +++ b/generator/test/generators/do/generator.test.ts @@ -1,8 +1,9 @@ import { expect } from "chai"; -import { extractSDKData } from "../../../generators/do/generator"; -import { readSourceFile, readJsonData } from "../lib/helper"; import { SyntaxKind } from "typescript"; +import { extractSDKData } from "../../../generators/do/generator"; +import { readJsonData,readSourceFile } from "../lib/helper"; + describe("Digital Ocean generator extractSDKData", () => { context("with valid methods and valid AST", () => { it("should return extracted class data", async () => { diff --git a/generator/test/generators/googleCloud/generator.test.ts b/generator/test/generators/googleCloud/generator.test.ts index 38b765e2..3b339d3c 100644 --- a/generator/test/generators/googleCloud/generator.test.ts +++ b/generator/test/generators/googleCloud/generator.test.ts @@ -1,10 +1,11 @@ import { expect } from "chai"; +import { SyntaxKind } from "typescript"; + import { extractClassBasedSDKData, extractClientBasedSDKdata } from "../../../generators/googleCloud/generator"; import { readJsonData, readSourceFile } from "../lib/helper"; -import { SyntaxKind } from "typescript"; describe("GCP generator extractClassBasedSDKData", () => { context("with valid methods and valid AST", () => { diff --git a/generator/test/generators/lib/helper.ts b/generator/test/generators/lib/helper.ts index bfb4f66c..deecb432 100644 --- a/generator/test/generators/lib/helper.ts +++ b/generator/test/generators/lib/helper.ts @@ -1,5 +1,5 @@ import * as fs from "fs"; -import { ScriptTarget, createSourceFile } from "typescript"; +import { createSourceFile,ScriptTarget } from "typescript"; export function readSourceFile(datasetName, provider) { return new Promise((resolve, reject) => { diff --git a/generator/test/parsers/aws/parser.test.ts b/generator/test/parsers/aws/parser.test.ts index 444b7208..0c27cc5c 100644 --- a/generator/test/parsers/aws/parser.test.ts +++ b/generator/test/parsers/aws/parser.test.ts @@ -1,7 +1,8 @@ import { expect } from "chai"; -import { getAST } from "../../../parsers/aws/parser"; import { SyntaxKind } from "typescript"; +import { getAST } from "../../../parsers/aws/parser"; + describe("AWS parser getAST", () => { context("with existing file", () => { it("should return Abstract syntax tree of the class", async () => { diff --git a/generator/test/parsers/azure/parser.test.ts b/generator/test/parsers/azure/parser.test.ts index 35d53535..308694be 100644 --- a/generator/test/parsers/azure/parser.test.ts +++ b/generator/test/parsers/azure/parser.test.ts @@ -1,7 +1,8 @@ import { expect } from "chai"; -import { getAST } from "../../../parsers/azure/parser"; import { SyntaxKind } from "typescript"; +import { getAST } from "../../../parsers/azure/parser"; + describe("Azure parser getAST", () => { context("with existing file", () => { it("should return Abstract syntax tree of the class", async () => { diff --git a/generator/test/parsers/do/parser.test.ts b/generator/test/parsers/do/parser.test.ts index 40283a04..d686eb4e 100644 --- a/generator/test/parsers/do/parser.test.ts +++ b/generator/test/parsers/do/parser.test.ts @@ -1,7 +1,8 @@ import { expect } from "chai"; -import { getAST } from "../../../parsers/do/parser"; import { SyntaxKind } from "typescript"; +import { getAST } from "../../../parsers/do/parser"; + describe("Digital Ocean parser getAST", () => { context("With existing file", () => { it("Should return Abstract syntax tree of the class", async () => { diff --git a/generator/test/parsers/googleCloud/parser.test.ts b/generator/test/parsers/googleCloud/parser.test.ts index 83dc8681..ea49e99e 100644 --- a/generator/test/parsers/googleCloud/parser.test.ts +++ b/generator/test/parsers/googleCloud/parser.test.ts @@ -1,7 +1,8 @@ import { expect } from "chai"; -import { getAST } from "../../../parsers/googleCloud/parser"; import { SyntaxKind } from "typescript"; +import { getAST } from "../../../parsers/googleCloud/parser"; + describe("Google cloud parser getAST", () => { context("with existing file, multi:false", () => { it("should return Abstract syntax tree of the class", async () => { diff --git a/generator/test/transformers/aws/transformer.test.ts b/generator/test/transformers/aws/transformer.test.ts index 43d17ca2..c98366ba 100644 --- a/generator/test/transformers/aws/transformer.test.ts +++ b/generator/test/transformers/aws/transformer.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; +import { createSourceFile, isSourceFile,ScriptTarget } from "typescript"; + import { transform } from "../../../transformers/aws/transformer"; -import { createSourceFile, ScriptTarget, isSourceFile } from "typescript"; import { readJsonData, readSourceFile } from "../lib/helper"; interface TestData { diff --git a/generator/test/transformers/azure/transformer.test.ts b/generator/test/transformers/azure/transformer.test.ts index f7156523..02143394 100644 --- a/generator/test/transformers/azure/transformer.test.ts +++ b/generator/test/transformers/azure/transformer.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; +import { createSourceFile, isSourceFile,ScriptTarget } from "typescript"; + import { transform } from "../../../transformers/azure/transformer"; -import { createSourceFile, ScriptTarget, isSourceFile } from "typescript"; import { readJsonData, readSourceFile } from "../lib/helper"; interface TestData { diff --git a/generator/test/transformers/do/transformer.test.ts b/generator/test/transformers/do/transformer.test.ts index c2654c78..6a1b333b 100644 --- a/generator/test/transformers/do/transformer.test.ts +++ b/generator/test/transformers/do/transformer.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; +import { createSourceFile, isSourceFile,ScriptTarget } from "typescript"; + import { transform } from "../../../transformers/do/transformer"; -import { createSourceFile, ScriptTarget, isSourceFile } from "typescript"; import { readJsonData, readSourceFile } from "../lib/helper"; interface TestData { diff --git a/generator/test/transformers/googleCloud/classBasedTransformer.test.ts b/generator/test/transformers/googleCloud/classBasedTransformer.test.ts index ed0cbb47..9724e629 100644 --- a/generator/test/transformers/googleCloud/classBasedTransformer.test.ts +++ b/generator/test/transformers/googleCloud/classBasedTransformer.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; +import { createSourceFile, isSourceFile,ScriptTarget } from "typescript"; + import { classBasedTransform } from "../../../transformers/googleCloud/classBasedTransformer"; -import { createSourceFile, ScriptTarget, isSourceFile } from "typescript"; import { readJsonData, readSourceFile } from "../lib/helper"; interface TestData { diff --git a/generator/test/transformers/googleCloud/clientBasedTransformer.test.ts b/generator/test/transformers/googleCloud/clientBasedTransformer.test.ts index c6c1c3a1..c54d3ac5 100644 --- a/generator/test/transformers/googleCloud/clientBasedTransformer.test.ts +++ b/generator/test/transformers/googleCloud/clientBasedTransformer.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; +import { createSourceFile, isSourceFile,ScriptTarget } from "typescript"; + import { clientBasedTransform } from "../../../transformers/googleCloud/clientBasedTransformer"; -import { createSourceFile, ScriptTarget, isSourceFile } from "typescript"; import { readJsonData, readSourceFile } from "../lib/helper"; interface TestData { diff --git a/generator/test/transformers/lib/helper.ts b/generator/test/transformers/lib/helper.ts index 9cd8c618..886124d5 100644 --- a/generator/test/transformers/lib/helper.ts +++ b/generator/test/transformers/lib/helper.ts @@ -1,5 +1,5 @@ import * as fs from "fs"; -import { ScriptTarget, createSourceFile } from "typescript"; +import { createSourceFile,ScriptTarget } from "typescript"; export function readSourceFile(datasetName, provider) { return new Promise((resolve, reject) => { diff --git a/generator/transformers/aws/transformer.ts b/generator/transformers/aws/transformer.ts index 2fed8599..31230633 100644 --- a/generator/transformers/aws/transformer.ts +++ b/generator/transformers/aws/transformer.ts @@ -1,5 +1,5 @@ -import * as ts from "typescript"; import { cloneDeep } from "lodash"; +import * as ts from "typescript"; const dummyIdentifiers = [ "ClassName", diff --git a/generator/transformers/azure/transformer.ts b/generator/transformers/azure/transformer.ts index bc451897..1c9fd106 100644 --- a/generator/transformers/azure/transformer.ts +++ b/generator/transformers/azure/transformer.ts @@ -1,5 +1,5 @@ -import * as ts from "typescript"; import { cloneDeep } from "lodash"; +import * as ts from "typescript"; const dummyIdentifiers = [ "ClassName", diff --git a/generator/transformers/do/transformer.ts b/generator/transformers/do/transformer.ts index 1e5d05d5..3f063962 100644 --- a/generator/transformers/do/transformer.ts +++ b/generator/transformers/do/transformer.ts @@ -1,5 +1,5 @@ -import * as ts from "typescript"; import { cloneDeep } from "lodash"; +import * as ts from "typescript"; const dummyIdentifiers = [ "ClassName", diff --git a/generator/transformers/googleCloud/classBasedTransformer.ts b/generator/transformers/googleCloud/classBasedTransformer.ts index bcbe001d..a68f9365 100644 --- a/generator/transformers/googleCloud/classBasedTransformer.ts +++ b/generator/transformers/googleCloud/classBasedTransformer.ts @@ -1,5 +1,5 @@ -import * as ts from "typescript"; import { cloneDeep } from "lodash"; +import * as ts from "typescript"; const dummyIdentifiers = [ "ClassName", diff --git a/generator/transformers/googleCloud/clientBasedTransformer.ts b/generator/transformers/googleCloud/clientBasedTransformer.ts index adb5214d..525086dd 100644 --- a/generator/transformers/googleCloud/clientBasedTransformer.ts +++ b/generator/transformers/googleCloud/clientBasedTransformer.ts @@ -1,5 +1,5 @@ -import * as ts from "typescript"; import { cloneDeep } from "lodash"; +import * as ts from "typescript"; const dummyIdentifiers = [ "ClassName", diff --git a/package.json b/package.json index 8afd0eb1..e50b5b8b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "husky": { "hooks": { - "pre-commit": "lerna run test && lerna run prettier", + "pre-commit": "lerna run test && lerna run prettier && lerna run lint", "pre-push": "lerna run test" } }