From af817b64c64a35fde2b5cae4ed7344300ce726fd Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Mon, 19 Jun 2023 11:54:20 +0530 Subject: [PATCH] fix: review comments --- .eslintrc | 82 +++++++++++++++++++------------- package-lock.json | 2 - package.json | 2 - src/core/content-type/compare.ts | 2 +- src/utils/index.ts | 10 ++-- 5 files changed, 55 insertions(+), 43 deletions(-) diff --git a/.eslintrc b/.eslintrc index b90069f..dffeb7e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,37 +1,51 @@ -{ +{ "extends": [ - "oclif", - "oclif-typescript" - ], - "rules": { + // "oclif", + "oclif-typescript", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], + "semi": "off", + "@typescript-eslint/type-annotation-spacing": "error", + "@typescript-eslint/no-redeclare": "off", + "eqeqeq": [ + "error", + "smart" + ], + "id-match": "error", + "no-eval": "error", + "no-var": "error", + "quotes": "off", + "indent": "off", + "camelcase": "off", + "comma-dangle": "off", + "arrow-parens": "off", + "operator-linebreak": "off", + "object-curly-spacing": "off", + "node/no-missing-import": "off", + "padding-line-between-statements": "off", + "@typescript-eslint/ban-ts-ignore": "off", "unicorn/no-abusive-eslint-disable": "off", + "unicorn/consistent-function-scoping": "off", "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/ban-ts-ignore": "off", - "object-curly-spacing": "off", - "no-useless-constructor": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "args": "none" - } - ], - "@typescript-eslint/prefer-namespace-keyword": "error", - "@typescript-eslint/quotes": [ - "error", - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": true - } - ], - "semi": "off", - "indent": "off", - "comma-dangle": "off", - "unicorn/consistent-function-scoping": "off", - "max-params": "off", - "no-return-await":"off", - "no-process-exit":"off", - "no-trailing-spaces":"off", - "unicorn/no-process-exit":"off" - } - } \ No newline at end of file + "@typescript-eslint/camelcase": "off", + "no-process-exit":"off", + "unicorn/no-process-exit": "off", + "@typescript-eslint/no-var-requires": "off" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ce11c17..e9c4f79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,8 +11,6 @@ "dependencies": { "@contentstack/cli-command": "^1.2.8", "@contentstack/cli-utilities": "^1.4.4", - "@oclif/command": "^1.8.0", - "@oclif/config": "^1.17.0", "@types/diff2html": "^3.0.0", "@types/git-diff": "^2.0.2", "@types/hogan.js": "^3.0.0", diff --git a/package.json b/package.json index cdf236e..968d42a 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,6 @@ "dependencies": { "@contentstack/cli-command": "^1.2.8", "@contentstack/cli-utilities": "^1.4.4", - "@oclif/command": "^1.8.0", - "@oclif/config": "^1.17.0", "@types/diff2html": "^3.0.0", "@types/git-diff": "^2.0.2", "@types/hogan.js": "^3.0.0", diff --git a/src/core/content-type/compare.ts b/src/core/content-type/compare.ts index 22cda06..6963351 100644 --- a/src/core/content-type/compare.ts +++ b/src/core/content-type/compare.ts @@ -5,7 +5,7 @@ import * as Diff2html from 'diff2html' import gitDiff from 'git-diff' import {BuildOutput} from '../../types' -export default async function buildOutput(contentTypeName: string, previous: any, current: any): Promise { +export default async function buildOutput(contentTypeName: string, previous: any, current: any): Promise { const diffString = buildDiffString(previous, current) const diffTree = Diff2html.parse(diffString) const diffHtml = Diff2html.html(diffTree, { diff --git a/src/utils/index.ts b/src/utils/index.ts index 870effd..9c58d2c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -20,13 +20,14 @@ export async function getStack(managementSdk: any, apiKey: string, spinner: any) } export async function getUsers(managementSdk: any, apiKey: string, spinner: any) { - return await managementSdk + const users = await managementSdk .stack({ api_key: apiKey }) .users() .then((data: any) => data) .catch((error: any) => { handleErrorMsg(error, spinner) }) + return users } export async function getContentTypes( @@ -49,7 +50,7 @@ export async function getContentTypes( if (ct?.items?.length > 0) { contentTypes = [...contentTypes, ...ct.items] skip += config.limit - if (skip < ct.count) return await getContentTypes(managementSdk, apiKey, spinner, skip, contentTypes) + if (skip < ct.count) return getContentTypes(managementSdk, apiKey, spinner, skip, contentTypes) } return contentTypes } @@ -74,7 +75,7 @@ export async function getGlobalFields( if (gf?.items?.length > 0) { globalFields = [...globalFields, ...gf.items] skip += config.limit - if (skip < gf.count) return await getGlobalFields(managementSdk, apiKey, spinner, skip, globalFields) + if (skip < gf.count) return getGlobalFields(managementSdk, apiKey, spinner, skip, globalFields) } return globalFields } @@ -88,7 +89,7 @@ export async function getContentType(params: { }) { const { managementSdk, apiKey, ctVersion, spinner, uid } = params const param = ctVersion ? { version: ctVersion } : {} - return await managementSdk + const ct = await managementSdk .stack({ api_key: apiKey }) .contentType(uid) .fetch(param) @@ -96,6 +97,7 @@ export async function getContentType(params: { .catch((error: any) => { handleErrorMsg(error, spinner) }) + return ct } function handleErrorMsg(err: any, spinner: any) {