From 2c71bf2661c5e1599de3cb242b5431dce8720137 Mon Sep 17 00:00:00 2001 From: "saloni.saraiya" Date: Tue, 11 Jan 2022 10:06:04 +0530 Subject: [PATCH] fix(eslint formatting): resolved eslint errors affects: @nodejs-code-generator/server --- package.json | 2 +- .../server/usecase/application/generate.js | 1 + .../node-generator/codeGenerator.js | 20 ++++++------- .../createApplication/service/index.js | 28 +++++++++---------- .../application/node-generator/generator.js | 4 +-- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 3ad86f4..0510bfe 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "release_patch": "lerna publish patch --conventional-commits && conventional-github-releaser --preset angular", "release_premajor": "lerna publish premajor --conventional-commits && conventional-github-releaser --preset angular", "release": "lerna publish --conventional-commits && conventional-github-releaser --preset angular", - "lint": "eslint ." + "lint": "eslint . --ext .js --fix" }, "jest": { "modulePathIgnorePatterns": [ diff --git a/packages/server/usecase/application/generate.js b/packages/server/usecase/application/generate.js index 743e203..fefcc55 100644 --- a/packages/server/usecase/application/generate.js +++ b/packages/server/usecase/application/generate.js @@ -521,6 +521,7 @@ const generate = (applicationRepo, schemaRepo, generatorRepo) => async (params) const generatedApps = await generatorRepo.getDetails(query); if (generatedApps.length > 0) { + // eslint-disable-next-line prefer-destructuring generated = generatedApps[0]; // latest App generated.id = generated._id; isReBuild = true; diff --git a/packages/server/usecase/application/node-generator/codeGenerator.js b/packages/server/usecase/application/node-generator/codeGenerator.js index 6591b3f..a19506e 100644 --- a/packages/server/usecase/application/node-generator/codeGenerator.js +++ b/packages/server/usecase/application/node-generator/codeGenerator.js @@ -42,13 +42,13 @@ const { configureMongoAuthTestCases } = require('./createApplication/createTestC const { configureSequelizeAuthTestCases } = require('./createApplication/createTestCases/sequelizeTestCases'); class CodeGenerator { - constructor(projectType) { + constructor (projectType) { this.projectType = projectType; const settingJson = projectSetting.setup(this.projectType); this.setup = settingJson[this.projectType]; } - async createApp(params) { + async createApp (params) { const { steps, templateFolderName, templateRegistry, userDirectoryStructure, } = this.setup; @@ -233,10 +233,10 @@ class CodeGenerator { database: this.jsonData.config.databaseName, port: this.jsonData.config.port, }, - { - socialAuth: _.cloneDeep(this.auth.socialAuth), - env, - }); + { + socialAuth: _.cloneDeep(this.auth.socialAuth), + env, + }); this.env = envs; this.jsonData = jsonData; this.postmanCollection.config = this.jsonData.config; @@ -251,9 +251,9 @@ class CodeGenerator { envs, jsonData, } = await generateService.createEnvFileSequelize(this.setup.templateFolderName, this.jsonData, { - database: this.jsonData.config.databaseName, - port: this.jsonData.config.port, - }, + database: this.jsonData.config.databaseName, + port: this.jsonData.config.port, + }, { socialAuth: this.auth.socialAuth, env, @@ -616,7 +616,7 @@ class CodeGenerator { } // ? create root directory - async createProjectRootDirectory(directory, projectName) { + async createProjectRootDirectory (directory, projectName) { writeOperations.mkdir(directory, projectName); writeOperations.mkdir(`${directory}${path.sep}${projectName}`, 'logs'); return `${directory}${path.sep}${projectName}`; diff --git a/packages/server/usecase/application/node-generator/createApplication/service/index.js b/packages/server/usecase/application/node-generator/createApplication/service/index.js index 953f6ab..5e0bb69 100644 --- a/packages/server/usecase/application/node-generator/createApplication/service/index.js +++ b/packages/server/usecase/application/node-generator/createApplication/service/index.js @@ -16,7 +16,7 @@ const fakeDataMongoose = require('../generateFakeData'); const fakeDataSequelize = require('../generateFakeDataSequelize'); const { removeGivenKeyFromObject } = require('../utils/common'); -async function createMVCBlankFolder(dir, userDirectoryStructure) { +async function createMVCBlankFolder (dir, userDirectoryStructure) { writeOperations.mkdir(dir, userDirectoryStructure.controllerFolderPath); writeOperations.mkdir(dir, userDirectoryStructure.modelFolderPath); writeOperations.mkdir(dir, userDirectoryStructure.configFolderPath); @@ -29,13 +29,13 @@ async function createMVCBlankFolder(dir, userDirectoryStructure) { writeOperations.mkdir(dir, userDirectoryStructure.viewsFolderPath); writeOperations.mkdir(dir, 'postman'); } -function createAppName(Name) { +function createAppName (Name) { return Name .replace(/[^A-Za-z0-9.-]+/g, '-') .replace(/^[-_.]+|-+$/g, '') .toLowerCase(); } -async function createPackageJson({ +async function createPackageJson ({ name, packages, mainJsFile, @@ -94,7 +94,7 @@ async function createPackageJson({ return pkg; } -async function createPackageJsonForSequelize({ +async function createPackageJsonForSequelize ({ name, packages, mainJsFile, @@ -152,7 +152,7 @@ async function createPackageJsonForSequelize({ return pkg; } -async function setUpAppJS(templateFolder, jsonData) { +async function setUpAppJS (templateFolder, jsonData) { const app = writeOperations.loadTemplate(`${templateFolder}/app.js`); app.locals.NO_PLATFORM = false; @@ -188,7 +188,7 @@ async function setUpAppJS(templateFolder, jsonData) { return app; } -async function setDB(dir, adapter = '') { +async function setDB (dir, adapter = '') { const db = writeOperations.loadTemplate(`${dir}/db.js`); if (!isEmpty(adapter)) { db.locals.ADAPTER = adapter; @@ -200,7 +200,7 @@ async function setDB(dir, adapter = '') { } return db; } -async function createEnvFile(templateFolder, jsonData, { +async function createEnvFile (templateFolder, jsonData, { database, port, }, options = {}) { const env = writeOperations.loadTemplate(`${templateFolder}/.env`); @@ -326,7 +326,7 @@ async function createEnvFile(templateFolder, jsonData, { }; } -async function createEnvFileSequelize(templateFolder, jsonData, { +async function createEnvFileSequelize (templateFolder, jsonData, { database, port, }, options = {}) { const env = writeOperations.loadTemplate(`${templateFolder}/.env`); @@ -470,7 +470,7 @@ async function createEnvFileSequelize(templateFolder, jsonData, { }; } -async function createValidationFile(validationFilePath, jsonData, auth, adapter = '', enumData) { +async function createValidationFile (validationFilePath, jsonData, auth, adapter = '', enumData) { const { isAuth, userModel, socialAuth, } = auth; @@ -546,7 +546,7 @@ async function createValidationFile(validationFilePath, jsonData, auth, adapter }); return validatedObj; } -async function createPostmanCollection(pName, postmanCollections, auth) { +async function createPostmanCollection (pName, postmanCollections, auth) { const { isAuth, userModel, userLoginWith, loginAccessPlatform, userRoles, socialAuth, } = auth; @@ -563,7 +563,7 @@ async function createPostmanCollection(pName, postmanCollections, auth) { const envPostman = await postman.generateEnvForPostman(postmanCollections.config); return [jsonCollectionsV20, jsonCollectionsV21, envPostman]; } -async function createCCBlankFolder(dir, userDirectoryStructure) { +async function createCCBlankFolder (dir, userDirectoryStructure) { writeOperations.mkdir(dir, userDirectoryStructure.controllerFolderPath); writeOperations.mkdir(dir, userDirectoryStructure.modelFolderPath); writeOperations.mkdir(dir, userDirectoryStructure.entityFolderPath); @@ -580,7 +580,7 @@ async function createCCBlankFolder(dir, userDirectoryStructure) { writeOperations.mkdir(dir, 'seeders'); } -async function envParser(env) { +async function envParser (env) { const envObj = {}; forEach(env.environments, (value) => { envObj[value] = {}; @@ -591,7 +591,7 @@ async function envParser(env) { return envObj; } -async function addSeederMongoose(jsonData, filePath, authObj) { +async function addSeederMongoose (jsonData, filePath, authObj) { const roles = authObj.userRoles; const { models } = jsonData; const seeder = writeOperations.loadTemplate(`${filePath}/index.js`); @@ -681,7 +681,7 @@ async function addSeederMongoose(jsonData, filePath, authObj) { return [seeder, user]; } -async function addSeederSequelize(jsonData, filePath, authObj) { +async function addSeederSequelize (jsonData, filePath, authObj) { // const roles = commonService.uniqRolesFromRolePermissions(jsonData.rolePermission); const roles = authObj.userRoles; const { models } = jsonData; diff --git a/packages/server/usecase/application/node-generator/generator.js b/packages/server/usecase/application/node-generator/generator.js index 83de320..30d8809 100644 --- a/packages/server/usecase/application/node-generator/generator.js +++ b/packages/server/usecase/application/node-generator/generator.js @@ -6,7 +6,7 @@ const { PROJECT_TYPE } = require('./constants/constant'); global.__basedir = __dirname; const CodeGenerator = require('./codeGenerator'); -function trimModelNameFromInput(models) { +function trimModelNameFromInput (models) { const oldModelNames = _.keys(models); let newModelNames = []; _.forEach(models, (model, modelName) => { @@ -18,7 +18,7 @@ function trimModelNameFromInput(models) { throw new Error('modelName should not contain spaces'); } -async function main(inputFilepath, isReBuild) { +async function main (inputFilepath, isReBuild) { let projectPath; try { const inputData = fs.readFileSync(inputFilepath, { encoding: 'utf8' });