Skip to content

Commit

Permalink
chore: fixed linter errors in generator
Browse files Browse the repository at this point in the history
- fixed all linter errors produced by new eslint config

- pending 140 linter warnings (large change) that can be fixed post approval from
project mentors
  • Loading branch information
pranjalwalia committed Apr 15, 2022
1 parent 6996c7f commit bc6166a
Show file tree
Hide file tree
Showing 28 changed files with 60 additions and 40 deletions.
5 changes: 4 additions & 1 deletion generator/generators/.eslintrc → generator/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"node_modules/",
"dummyClasses/",
"generatedClasses/"
]
],
"rules": {
"@typescript-eslint/no-empty-function": "warn"
}
}
3 changes: 2 additions & 1 deletion generator/generators/aws/generator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 3 additions & 2 deletions generator/generators/azure/generator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion generator/generators/do/generator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 4 additions & 3 deletions generator/generators/googleCloud/generator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 5 additions & 6 deletions generator/generators/lib/helper.ts
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down Expand Up @@ -38,12 +37,12 @@ const filters = {
};

const getDir = (service: string): string => {
for (var dir in dirMap) {
for (let dir in dirMap) {
if (dirMap[dir].includes(service)) {
return dir;
}
}
throw new Error("Not a valid service: " + service);
};

export { groupers, filters, getDir };
export { filters, getDir,groupers };
5 changes: 3 additions & 2 deletions generator/main.ts
Original file line number Diff line number Diff line change
@@ -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"));
Expand Down
5 changes: 3 additions & 2 deletions generator/test/generators/aws/generator.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
5 changes: 3 additions & 2 deletions generator/test/generators/azure/generator.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
5 changes: 3 additions & 2 deletions generator/test/generators/do/generator.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/generators/googleCloud/generator.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion generator/test/generators/lib/helper.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/parsers/aws/parser.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/parsers/azure/parser.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/parsers/do/parser.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/parsers/googleCloud/parser.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/transformers/aws/transformer.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/transformers/azure/transformer.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion generator/test/transformers/do/transformer.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion generator/test/transformers/lib/helper.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion generator/transformers/aws/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import { cloneDeep } from "lodash";
import * as ts from "typescript";

const dummyIdentifiers = [
"ClassName",
Expand Down
2 changes: 1 addition & 1 deletion generator/transformers/azure/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import { cloneDeep } from "lodash";
import * as ts from "typescript";

const dummyIdentifiers = [
"ClassName",
Expand Down
2 changes: 1 addition & 1 deletion generator/transformers/do/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import { cloneDeep } from "lodash";
import * as ts from "typescript";

const dummyIdentifiers = [
"ClassName",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import { cloneDeep } from "lodash";
import * as ts from "typescript";

const dummyIdentifiers = [
"ClassName",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import { cloneDeep } from "lodash";
import * as ts from "typescript";

const dummyIdentifiers = [
"ClassName",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down

0 comments on commit bc6166a

Please sign in to comment.