@zohodesk/codestandard-analytics
Advanced tools
Comparing version 0.0.1-exp-3 to 0.0.1-exp-30
#!/usr/bin/env node | ||
/** | ||
* @author rajasekar 17710 | ||
* @fileoverview This script is a Node.js executable that imports and runs the module `runner` from the `../build/lib/` directory. | ||
@@ -5,0 +6,0 @@ */ |
@@ -13,3 +13,4 @@ "use strict"; | ||
var _getFileUtils = require("./getFileUtils"); | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
// import { checkIfFileExists } from "../../utils/fileUtils"; | ||
/** | ||
@@ -34,3 +35,6 @@ * @function filterLintReportBasedOnImpactLine - Filter Report Based on Impact Line | ||
// To set pipeline status | ||
message["severity"] == 2 ? global.analytics.reportStatus = false : null; | ||
if (message["severity"] == 2) { | ||
global.analytics.status = "FAILURE"; | ||
global.analytics.message = 'Issues are detected, please review and resolve the errors'; | ||
} | ||
return true; | ||
@@ -72,4 +76,5 @@ } | ||
*/ | ||
function filterNotDefinedRule(message, regex) { | ||
return regex.test(message); | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.constructConfigPath = constructConfigPath; | ||
exports.filterExemptionFiles = filterExemptionFiles; | ||
exports.filterFiles = filterFiles; | ||
@@ -16,2 +17,3 @@ exports.getFiles = getFiles; | ||
exports.getStagedFiles_preCommit = getStagedFiles_preCommit; | ||
exports.removeFile = removeFile; | ||
exports.resolvePath = resolvePath; | ||
@@ -22,2 +24,4 @@ var _path = _interopRequireDefault(require("path")); | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
var _fs = require("fs"); | ||
var _cliArgsToObject = require("../../utils/cliArgsToObject"); | ||
/** | ||
@@ -32,4 +36,12 @@ * @function getFilesFromBranchDiff - filter file path From git diff json | ||
const diffFiles = diffJson === null || diffJson === void 0 ? void 0 : diffJson.diffs.map(diff => { | ||
return _path.default.resolve(rootPath, diff === null || diff === void 0 ? void 0 : diff.new_path); | ||
}); | ||
try { | ||
const pathOfFile = _path.default.resolve(rootPath, diff === null || diff === void 0 ? void 0 : diff.new_path); | ||
if ((0, _fileUtils.checkIfFileExists)(pathOfFile)) { | ||
return pathOfFile; | ||
} | ||
return undefined; | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, ` file does not exist. make sure that branch upto date ...`); | ||
} | ||
}).filter(Boolean); | ||
return filterFiles(diffFiles); | ||
@@ -64,2 +76,8 @@ } | ||
} | ||
/** | ||
* @function {getStagedFiles_preCommit} - methods get staged files | ||
* @returns {Array<String>} | ||
*/ | ||
function getStagedFiles_preCommit() { | ||
@@ -107,11 +125,24 @@ const command = "git diff --cached -U0 HEAD --name-only"; | ||
* @param {path} branchDiffPath - path of branch diff json | ||
* @returns {{JsFiles:[],featureFiles:[],branch_diff_json:[]}} | ||
* @returns {{JsFiles:[],cssFiles:[],featureFiles:[],branch_diff_json:[]}} | ||
*/ | ||
function getFiles(env, dir, branchDiffPath = false) { | ||
if (env == 'dev') { | ||
const listOfFiles = dir && (0, _fileUtils.checkIfFileExists)(dir) ? dir : false; | ||
return (0, _fileUtils.getFilesPathFromRootDir)(listOfFiles, []); | ||
const multipleFiles = dir.split(','); | ||
const filesAfterFilter = multipleFiles.map(_dir => { | ||
const listOfFiles = (0, _fileUtils.checkIfFileExists)(_dir) ? _dir : false; | ||
if (!listOfFiles && typeof listOfFiles === 'boolean') { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Given file or directory does not exist ...`); | ||
process.exit(0); | ||
} | ||
return (0, _fileUtils.getFilesPathFromRootDir)(listOfFiles, []); | ||
}); | ||
return (0, _cliArgsToObject.mergeArrayObjects)(filesAfterFilter); | ||
} | ||
if (env == 'ci') { | ||
const _branch_diff_json = branchDiffPath && (0, _fileUtils.checkIfFileExists)(branchDiffPath) ? require(resolvePath(branchDiffPath)) : [{}]; | ||
const _branch_diff_json = branchDiffPath && (0, _fileUtils.checkIfFileExists)(branchDiffPath) ? require(resolvePath(branchDiffPath)) : false; | ||
if (!_branch_diff_json) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `branch diff file does not exists ...`); | ||
process.exit(0); | ||
} | ||
return { | ||
@@ -123,2 +154,8 @@ ...getStagedFiles_CI(_branch_diff_json), | ||
} | ||
/** | ||
* @function {constructConfigPath} - construct path of configuration file | ||
* @returns {string} | ||
*/ | ||
function constructConfigPath() { | ||
@@ -136,12 +173,47 @@ return _path.default.resolve(process.cwd(), "lint.config.js"); | ||
return lintFiles.reduce((files, currentFile) => { | ||
if (currentFile.includes('.feature')) { | ||
if (currentFile.includes('.feature') && (0, _fileUtils.checkIfFileExists)(currentFile)) { | ||
files.featureFiles.push(currentFile); | ||
} else { | ||
} | ||
if (currentFile.includes('.js') || currentFile.includes('.ts') || currentFile.includes('.tsx') || currentFile.includes('.jsx') && (0, _fileUtils.checkIfFileExists)(currentFile)) { | ||
files.JsFiles.push(currentFile); | ||
} | ||
if (currentFile.includes('.css') && (0, _fileUtils.checkIfFileExists)(currentFile)) { | ||
files.CssFiles.push(currentFile); | ||
} | ||
return files; | ||
}, { | ||
featureFiles: [], | ||
JsFiles: [] | ||
JsFiles: [], | ||
CssFiles: [] | ||
}); | ||
} | ||
/** | ||
* @function {removeFile} - this methods remove diff json file | ||
* @returns {void} | ||
*/ | ||
function removeFile(file_path) { | ||
(0, _fileUtils.checkIfFileExists)(file_path) ? (0, _fs.unlinkSync)(file_path) : null; | ||
} | ||
/** | ||
* @function {filterExemptionFiles} - method filter exemption need files | ||
* @param {Array>String>} exemptionFiles - exemption needed files | ||
* @param {Array>String>} actualFiles - actualFiles from git diff | ||
* @returns {Array>String>} | ||
*/ | ||
function filterExemptionFiles(exemptionFiles, actualFiles) { | ||
if (exemptionFiles.length == 0) { | ||
return actualFiles; | ||
} | ||
return actualFiles.filter(filePath => { | ||
const relativePath = _path.default.relative(process.cwd(), filePath); | ||
return !exemptionFiles.includes(relativePath); | ||
// if(exemptionFiles.includes(file)){ | ||
// return false | ||
// } | ||
// return true | ||
}); | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,4 +8,5 @@ value: true | ||
exports.executeLintAnalysis = executeLintAnalysis; | ||
exports.fixEslintIssue = fixEslintIssue; | ||
var _eslint = require("eslint"); | ||
var _path = _interopRequireWildcard(require("path")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
@@ -14,4 +16,5 @@ var _getFileUtils = require("./getFileUtils"); | ||
var _logger = require("../../utils/logger"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var _child_process = require("child_process"); | ||
var _requestUtils = require("../../utils/requestUtils"); | ||
var _getSonarProperties = require("../sonar-dependencies/getSonarProperties"); | ||
/** | ||
@@ -24,3 +27,3 @@ * @function executeLintAnalysis - start lint analysis | ||
async function executeLintAnalysis(cliParams) { | ||
_logger.Logger.start('Start linting ...'); | ||
_logger.Logger.cliLog("success", '\n Start linting ...'); | ||
var { | ||
@@ -43,7 +46,8 @@ env, | ||
JsFiles, | ||
branch_diff_json | ||
branch_diff_json, | ||
CssFiles | ||
} = (0, _getFileUtils.getFiles)(env, dir, branchDiffPath); | ||
cliParams.cmdExecuted == "lint-ci" && (await (0, _requestUtils.isExemptionApplied)()) ? JsFiles = (0, _getFileUtils.filterExemptionFiles)(await (0, _requestUtils.getFilesSonarQube_API)((0, _getSonarProperties.getProjectNameForExemption)()), JsFiles) : null; | ||
const filteredLintReport = await startLint(branch_diff_json, JsFiles, env, impactBased, ruleConfigurationPath); | ||
_logger.Logger.stop(); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, `Linting analysis completed successfully...`); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, `\n Linting analysis completed successfully...`); | ||
(0, _fileUtils.writeFileContents)(reportPath, JSON.stringify(filteredLintReport)); | ||
@@ -105,5 +109,34 @@ } | ||
} catch (err) { | ||
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${err.message}`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Either Lint configuration not found or rule plugin are not installed ..`); | ||
process.exit(0); | ||
} | ||
} | ||
/** | ||
* @function fixEslintIssue - help to fix lint issue | ||
* @param {Array<String>} option - cli commads as array after parsing | ||
* @returns {void} | ||
*/ | ||
function fixEslintIssue(option) { | ||
// if(option.length == 1 && !checkIfFileExists(path.resolve(option))){ | ||
// Logger.log(Logger.FAILURE_TYPE,`check whether given file or directory exist or not`) | ||
// process.exit(0) | ||
// } | ||
const prefix = 'npx'; | ||
const command = ["eslint", "--fix", "--ext", ".js,.jsx", ...option]; | ||
try { | ||
const lint_process = (0, _child_process.spawn)(prefix, command); | ||
lint_process.stdout.on('data', data => { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, data.toString()); | ||
}); | ||
lint_process.stderr.on('error', data => { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, data.toString()); | ||
}); | ||
lint_process.on('close', close => {}); | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.getModifiedLine_PreCommit = getModifiedLine_PreCommit; | ||
exports.getModifiedLines = getModifiedLines; | ||
@@ -83,2 +84,21 @@ const { | ||
}; | ||
} | ||
function getModifiedLine_PreCommit(git_diff) { | ||
const changedLinesArray = git_diff.split('\n').filter(line => line.startsWith('@@')); | ||
let changedLinesStartArray = []; | ||
let changedLinesEndArray = []; | ||
for (var number of changedLinesArray) { | ||
let changesStartLine = parseInt(number.split(' ')[2].split(',')[0]); | ||
changedLinesStartArray.push(changesStartLine); | ||
let changesEndLine = number.split(' ')[2].split(',')[1]; | ||
if (changesEndLine === undefined) { | ||
changedLinesEndArray.push(changesStartLine); | ||
} else { | ||
changedLinesEndArray.push(changesStartLine + parseInt(changesEndLine) - 1); | ||
} | ||
} | ||
return { | ||
_changedLinesStartArray: changedLinesStartArray, | ||
_changedLinesEndArray: changedLinesEndArray | ||
}; | ||
} |
@@ -1,30 +0,33 @@ | ||
"use strict"; | ||
// import { getProjectNameFrmGit, getSpawnOutput } from "./sonar-dependencies/getSonarProperties"; | ||
// import path from "path"; | ||
// function showMsgPopUp(condition) { | ||
// // java -jar ./IDEMessagePluginRecent.jar project_name "BothStagedAndUnstaged" server_url java_version_output | ||
// const command = "java"; | ||
// const params = [ | ||
// "-jar", | ||
// `${getPopupJarPath()}`, | ||
// getProjectNameFrmGit(), | ||
// condition, | ||
// "java version 11" | ||
// ]; | ||
// switch (condition) { | ||
// case "NoIssueFound": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// case "IssueFound": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// case "BothStagedAndUnstaged": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// default: | ||
// break; | ||
// } | ||
// } | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.showMsgPopUp = showMsgPopUp; | ||
var _getSonarProperties = require("./sonar-dependencies/getSonarProperties"); | ||
var _path = _interopRequireDefault(require("path")); | ||
function showMsgPopUp(condition) { | ||
// java -jar ./IDEMessagePluginRecent.jar project_name "BothStagedAndUnstaged" server_url java_version_output | ||
const command = "java"; | ||
const params = ["-jar", `${getPopupJarPath()}`, (0, _getSonarProperties.getProjectNameFrmGit)(), condition, "java version 11"]; | ||
switch (condition) { | ||
case "NoIssueFound": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
case "IssueFound": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
case "BothStagedAndUnstaged": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
function getPopupJarPath() { | ||
return _path.default.resolve(__dirname, "sonar-dependencies", "java-jar", "IDEMessagePluginRecent.jar"); | ||
} | ||
// function getPopupJarPath() { | ||
// return path.resolve(__dirname,"sonar-dependencies","java-jar", "IDEMessagePluginRecent.jar"); | ||
// } | ||
// export { showMsgPopUp }; | ||
"use strict"; |
@@ -1,56 +0,52 @@ | ||
"use strict"; | ||
// import https from 'https'; | ||
// import { cliArgsToObject } from '../utils/cliArgsToObject'; | ||
// import { Logger } from '../utils/logger'; | ||
// import fs from 'fs'; | ||
// import path from 'path'; | ||
// import { spawn } from 'child_process'; | ||
// import { getSonarJarPath } from '../utils/rootPath'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.requestJAR = requestJAR; | ||
var _https = _interopRequireDefault(require("https")); | ||
var _cliArgsToObject = require("../utils/cliArgsToObject"); | ||
var _logger = require("../utils/logger"); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _child_process = require("child_process"); | ||
var _rootPath = require("../utils/rootPath"); | ||
async function requestJAR(cliParams, options = {}) { | ||
const { | ||
pat, | ||
requestUrl | ||
} = (0, _cliArgsToObject.cliArgsToObject)(cliParams); | ||
const endpoint = requestUrl || 'https://zgit.csez.zohocorpin.com/zohodesk/zohodesk/-/raw/master/sonardependencies/lib/sonar-scanner-cli-4.8.0.2856.jar?inline=false'; | ||
const body = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/java-archive', | ||
'PRIVATE-TOKEN': `${pat}` | ||
} | ||
}; | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cloning jar ${(0, _rootPath.getSonarJarPath)()}`); | ||
if (!pat) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `PAT token is Needed ..`); | ||
process.exit(0); | ||
} | ||
return await new Promise(resolve => { | ||
const jarAPI = _https.default.request(endpoint, body, response => { | ||
var responseChunk = ''; | ||
const fileStream = _fs.default.createWriteStream((0, _rootPath.getSonarJarPath)()); | ||
response.on('data', data => { | ||
responseChunk += data; | ||
}); | ||
response.pipe(fileStream); | ||
fileStream.on('finish', finish => { | ||
fileStream.close(); | ||
}); | ||
response.on('error', error => { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error - ${error}`); | ||
}); | ||
response.on('end', end => { | ||
// at end | ||
resolve({ | ||
path: (0, _rootPath.getSonarJarPath)() | ||
}); | ||
}); | ||
}); | ||
jarAPI.end(); | ||
}); | ||
} | ||
// async function requestJAR(cliParams, options = {}) { | ||
// const { pat, requestUrl } = cliArgsToObject(cliParams); | ||
// const endpoint = | ||
// requestUrl || | ||
// 'https://zgit.csez.zohocorpin.com/zohodesk/zohodesk/-/raw/master/sonardependencies/lib/sonar-scanner-cli-4.8.0.2856.jar?inline=false'; | ||
// const body = { | ||
// method: 'GET', | ||
// headers: { | ||
// 'Content-Type': 'application/java-archive', | ||
// 'PRIVATE-TOKEN': `${pat}` | ||
// } | ||
// }; | ||
// Logger.log(Logger.INFO_TYPE, `Cloning jar ${getSonarJarPath()}`); | ||
// if (!pat) { | ||
// Logger.log(Logger.FAILURE_TYPE, `PAT token is Needed ..`); | ||
// process.exit(0); | ||
// } | ||
// return await new Promise(resolve => { | ||
// const jarAPI = https.request(endpoint, body, response => { | ||
// var responseChunk = ''; | ||
// const fileStream = fs.createWriteStream(getSonarJarPath()); | ||
// response.on('data', data => { | ||
// responseChunk += data; | ||
// }); | ||
// response.pipe(fileStream); | ||
// fileStream.on('finish', finish => { | ||
// fileStream.close(); | ||
// }); | ||
// response.on('error', error => { | ||
// Logger.log(Logger.FAILURE_TYPE, `Error - ${error}`); | ||
// }); | ||
// response.on('end', end => { | ||
// // at end | ||
// resolve({ path: getSonarJarPath() }); | ||
// }); | ||
// }); | ||
// jarAPI.end(); | ||
// }); | ||
// } | ||
// export { requestJAR }; | ||
"use strict"; |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.getProjectName = getProjectName; | ||
exports.getProjectNameForExemption = getProjectNameForExemption; | ||
exports.getProjectNameFrmGit = getProjectNameFrmGit; | ||
@@ -23,2 +24,4 @@ exports.getRepoName = getRepoName; | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
var _hash = require("../../utils/hash"); | ||
var _logger = require("../../../build/utils/logger"); | ||
/** | ||
@@ -31,5 +34,5 @@ * @function getSonarHostUrl - get sonar host url from property file | ||
var { | ||
sonar_hostURL | ||
metricServerHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
return sonar_hostURL; | ||
return metricServerHost; | ||
} | ||
@@ -48,27 +51,20 @@ | ||
dir = null, | ||
diffPath = null | ||
cmdExecuted | ||
} = cliArgument; | ||
const { | ||
branchDiffPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const default_project = getProjectNameFrmGit(); | ||
var project_name = dir ? `${default_project}_dev` : diffPath ? `${default_project}_CI` : `${default_project}_dev_${timeSuffix}`; | ||
var project_name = dir ? `${default_project}_Dev_Report` : (0, _fileUtils.checkIfFileExists)(branchDiffPath) && cmdExecuted == 'exemption-report' ? `${default_project}_Exemption-report` : (0, _fileUtils.checkIfFileExists)(branchDiffPath) && cmdExecuted == 'lint-ci' ? `${default_project}_CI-pipeline` : `${default_project}_Dev-pipeline`; | ||
return project_name; | ||
} | ||
function getTestFiles(cliArgument) { | ||
return " "; | ||
} | ||
/** | ||
* @function getLintFiles - filter files based on cli argument | ||
* @param {Object} cliArgument - Object represent cli Argument | ||
* @returns {Array<string>} | ||
* @function getProjectNameForExemption - get project name for ExemptionFiles | ||
* @returns string | ||
*/ | ||
function getLintFiles(cliArgument) { | ||
var { | ||
diffPath = false, | ||
dir = false | ||
} = cliArgument; | ||
const linterFilesDirectory = dir && (0, _fileUtils.checkIfFileExists)(dir) ? dir : false; | ||
if (linterFilesDirectory && !diffPath) { | ||
return (0, _fileUtils.getFilesPathFromRootDir)(linterFilesDirectory); | ||
} | ||
return (0, _getFileUtils.getFilesFromBranchDiff)(require((0, _getFileUtils.resolvePath)(diffPath))); | ||
function getProjectNameForExemption() { | ||
const default_project = getProjectNameFrmGit(); | ||
return `${default_project}_Exemption-report`; | ||
} | ||
@@ -96,10 +92,9 @@ | ||
const sonar_scanner_path = (0, _rootPath.getSonarJarPath)(); | ||
const { | ||
Dlogin, | ||
Dpassword | ||
} = getCredentials(); | ||
const metric_token = getCredentials(); | ||
var project_name = getProjectName(cliObjects); | ||
var resultFilesPath = featureFiles; | ||
var source_directories = JsFiles; | ||
const command = ["-jar", sonar_scanner_path, `-Dsonar.host.url=${sonarqube_host_url}`, `-Dsonar.projectKey=${project_name}`, `-Dsonar.login=${Dlogin}`, `-Dsonar.password=${Dpassword}`, `-Dsonar.sources=${source_directories}`, `-Dsonar.tests=${resultFilesPath}`, "-Dsonar.language=js", `-Dsonar.working.directory=${getSonarArtifactsDir()}`, `-Dsonar.eslint.reportPaths=${(0, _getFileUtils.getLintReportPath)()}`, "-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info"]; | ||
const tsConfigurationPath = getTsConfigurationPath(); | ||
const command = ["-jar", sonar_scanner_path, `-Dsonar.host.url=${sonarqube_host_url}`, `-Dsonar.projectKey=${project_name}`, `-Dsonar.login=${metric_token}`, `-Dsonar.sources=${source_directories}`, `-Dsonar.tests=${resultFilesPath}`, "-Dsonar.language=js", `-Dsonar.working.directory=${getSonarArtifactsDir()}`, `-Dsonar.eslint.reportPaths=${(0, _getFileUtils.getLintReportPath)()}`, "-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info"]; | ||
(0, _fileUtils.checkIfFileExists)(tsConfigurationPath) && command.push(`-Dsonar.typescript.tsconfigPath=${tsConfigurationPath}`); | ||
return command; | ||
@@ -119,2 +114,3 @@ } | ||
} | ||
/** | ||
@@ -126,4 +122,10 @@ * @function getGitUsername - get username from git | ||
function getGitUsername() { | ||
const userName = getSpawnOutput("git", ["config", "user.email"]); | ||
return userName.pop().split("@")[0]; | ||
try { | ||
const userName = getSpawnOutput("git", ["config", "user.email"]); | ||
return userName.pop().split("@")[0]; | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -137,4 +139,10 @@ | ||
function getRepoName() { | ||
const repoName = getSpawnOutput("git", ["remote", "get-url", "origin"]); | ||
return repoName.pop().split("/").pop().split(".")[0]; | ||
try { | ||
const repoName = getSpawnOutput("git", ["remote", "get-url", "origin"]); | ||
return repoName.pop().split("/").pop().split(".")[0]; | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -149,4 +157,10 @@ | ||
// git rev-parse --abbrev-ref HEAD | ||
var branchName = getSpawnOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"]); // to get current branch | ||
return branchName.shift().trim(); | ||
try { | ||
var branchName = getSpawnOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"]); // to get current branch | ||
return branchName.shift().trim(); | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -175,9 +189,5 @@ | ||
const { | ||
loginName, | ||
password | ||
metric_token | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
return { | ||
Dlogin: loginName, | ||
Dpassword: password | ||
}; | ||
return (0, _hash.decrypt)(metric_token, 7); | ||
} | ||
@@ -192,2 +202,8 @@ | ||
return _path.default.resolve(process.cwd(), "lint-report", ".scannerwork"); | ||
} | ||
function getTsConfigurationPath() { | ||
const { | ||
tsConfigurationPath = undefined | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
return tsConfigurationPath && (0, _fileUtils.checkIfFileExists)(tsConfigurationPath) ? tsConfigurationPath : undefined; | ||
} |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _getFileUtils = require("../eslint/getFileUtils"); | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
var _requestUtils = require("../../utils/requestUtils"); | ||
/** | ||
@@ -23,6 +25,9 @@ * @note javascript code to start sonar Server | ||
function executeSonarAnalysis(cliParams) { | ||
var { | ||
env | ||
} = cliParams; | ||
_logger.Logger.createLogFile(); | ||
const command = (0, _getSonarProperties.getSonarProperties)(cliParams); | ||
const child_process = (0, _child_process.spawn)("java", command); | ||
_logger.Logger.start('Sending report to SonarQube ...'); | ||
_logger.Logger.cliLog("success", "\n Sending report to SonarQube ..."); | ||
child_process.stdout.on("data", data => { | ||
@@ -36,15 +41,18 @@ _logger.Logger.emit(data); | ||
child_process.on("error", error => { | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, 'failed to send report to sonarQube ...'); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, '\n failed to send report to sonarQube ...'); | ||
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${error.message}`); | ||
}); | ||
child_process.on("close", code => { | ||
code === 0 ? global.analytics.sonarQubeStatus = false : null; | ||
_logger.Logger.stop(); | ||
const { | ||
branchDiffPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
code === 0 ? global.analytics.sonarQubeStatus = true : null; | ||
(0, _sonarReportSummary.writeSummaryOfLint)(cliParams); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, 'SonarQube analysis completed...'); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, `Report ${code === 0 ? "successfully" : "failed"} sent to the server : Status - ${code === 0 ? "Success" : "Failure"}`); | ||
code === 0 ? _logger.Logger.cliLog(_logger.Logger.PATH_TYPE, `Report URL - ${(0, _sonarReportSummary.getSummaryOfLint)(cliParams).reportUrl}`) : null; | ||
global.analytics.reportStatus ? _logger.Logger.cliLog(_logger.Logger.INFO_TYPE, `JSON report Path - ${(0, _getFileUtils.getLintReportPath)()}`) : null; | ||
code === 0 ? _logger.Logger.cliLog(_logger.Logger.INFO_TYPE, `SonarQube Artifacts Path - ${(0, _getSonarProperties.getSonarArtifactsDir)()}`) : null; | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, '\n SonarQube analysis completed...'); | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, `\n Report ${code === 0 ? "successfully" : "failed"} sent to the server : Status - ${code === 0 ? "Success" : "Failure"}`); | ||
code === 0 ? _logger.Logger.cliLog(_logger.Logger.PATH_TYPE, `\n Report URL - ${(0, _sonarReportSummary.getSummaryOfLint)(cliParams).web_url}`) : null; | ||
_logger.Logger.cliLog(_logger.Logger.INFO_TYPE, `\n JSON report Path - ${(0, _getFileUtils.getLintReportPath)()}`); | ||
code === 0 ? _logger.Logger.cliLog(_logger.Logger.INFO_TYPE, `\n SonarQube Artifacts Path - ${(0, _getSonarProperties.getSonarArtifactsDir)()}`) : null; | ||
env == 'ci' && cliParams.cmdExecuted == "lint-ci" || cliParams.cmdExecuted == "dev-ci" || cliParams.cmdExecuted == "exemption-report" ? (0, _getFileUtils.removeFile)(branchDiffPath) && (0, _getFileUtils.removeFile)((0, _requestUtils.getExemptionFileInfoPath)()) : null; | ||
}); | ||
} |
@@ -23,8 +23,16 @@ "use strict"; | ||
const { | ||
sonar_hostURL | ||
metricServerHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const url = global.analytics.sonarQubeStatus === true ? `${metricServerHost}/dashboard?id=${$projectName}` : metricServerHost; | ||
return { | ||
projectName: $projectName, | ||
reportUrl: global.analytics.sonarQubeStatus === false ? `${sonar_hostURL}/project/issues?id=${$projectName}&resolved=false` : sonar_hostURL, | ||
jsonReportPath: (0, _getFileUtils.getLintReportPath)().toString() | ||
web_url: url, | ||
error: { | ||
code: global.analytics.status == "SUCCESS" ? "No Issue in Code" : "Issue in code detected", | ||
category: "code", | ||
message: `Click the link to view the detailed report - ${url}` | ||
}, | ||
results: [{ | ||
jsonReportPath: (0, _getFileUtils.getLintReportPath)().toString(), | ||
projectName: $projectName | ||
}] | ||
}; | ||
@@ -42,7 +50,10 @@ } | ||
return { | ||
reportStatus: true, | ||
pipelineStatus: 'passed' | ||
status: "SUCCESS", | ||
message: "No issues are found, your code adheres to the required standards." | ||
}; | ||
} | ||
return global.analytics; | ||
return { | ||
status: global.analytics.status, | ||
message: global.analytics.message | ||
}; | ||
} | ||
@@ -61,5 +72,5 @@ | ||
(0, _fileUtils.writeFileContents)(_path.default.resolve(process.cwd(), "lint-report", "lint-summary.json"), JSON.stringify({ | ||
...getSummaryOfLint(cliParams), | ||
...getLintStatus(impactBased) | ||
...getLintStatus(impactBased), | ||
...getSummaryOfLint(cliParams) | ||
})); | ||
} |
@@ -1,27 +0,26 @@ | ||
"use strict"; | ||
/** | ||
* @module Lint and Analytics | ||
*/ | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "EsLint", { | ||
enumerable: true, | ||
get: function () { | ||
return _Eslint.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Execution", { | ||
enumerable: true, | ||
get: function () { | ||
return _Execution.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "SonarQube", { | ||
enumerable: true, | ||
get: function () { | ||
return _SonarQube.default; | ||
} | ||
}); | ||
var _Execution = _interopRequireDefault(require("./core/handlers/libraryInterface/Execution")); | ||
var _Eslint = _interopRequireDefault(require("./core/handlers/libraryInterface/Eslint")); | ||
var _SonarQube = _interopRequireDefault(require("./core/handlers/libraryInterface/SonarQube")); | ||
// import Execution from "./core/handlers/libraryInterface/Execution"; | ||
// import EsLint from "./core/handlers/libraryInterface/Eslint"; | ||
// import SonarQube from "./core/handlers/libraryInterface/SonarQube"; | ||
// /** | ||
// * Execution handler. | ||
// * @type {Execution} | ||
// */ | ||
// export { Execution }; | ||
// /** | ||
// * EsLint handler. | ||
// * @type {EsLint} | ||
// */ | ||
// export { EsLint }; | ||
// /** | ||
// * SonarQube handler. | ||
// * @type {SonarQube} | ||
// */ | ||
// export { SonarQube }; | ||
"use strict"; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _runEslint = require("../core/eslint/runEslint.js"); | ||
var _Eslint = _interopRequireDefault(require("../core/handlers/libraryInterface/Eslint")); | ||
var _Execution = _interopRequireDefault(require("../core/handlers/libraryInterface/Execution")); | ||
var _SonarQube = _interopRequireDefault(require("../core/handlers/libraryInterface/SonarQube")); | ||
var _helper = require("../setup/helper.js"); | ||
var _initialSetup = require("../setup/initialSetup"); | ||
var _cliArgsToObject = require("../utils/cliArgsToObject"); | ||
// import { executeLintAnalysis } from "../lint/eslint/runEslint"; | ||
// import { executeSonarAnalysis } from "../lint/sonar-dependencies/runSonar"; | ||
var _fileUtils = require("../utils/fileUtils.js"); | ||
var _requestUtils = require("../utils/requestUtils.js"); | ||
/** | ||
@@ -21,5 +22,5 @@ * | ||
global.analytics = { | ||
reportStatus: true, | ||
pipelineStatus: 'passed', | ||
sonarQubeStatus: true | ||
status: "SUCCESS", | ||
sonarQubeStatus: false, | ||
message: "No issues are found, your code adheres to the required standards." | ||
}; | ||
@@ -30,4 +31,6 @@ const [,, action, ...option] = process.argv; | ||
{ | ||
(0, _fileUtils.checkConfigurationFileExist)(); | ||
const $cliObjects = (0, _cliArgsToObject.cliArgsToObject)(option); | ||
$cliObjects.env = 'dev'; | ||
$cliObjects.env = "dev"; | ||
$cliObjects.cmdExecuted = action; | ||
const execute = new _Execution.default(_Eslint.default, _SonarQube.default, $cliObjects); | ||
@@ -40,5 +43,10 @@ await execute.executeLintHandler().finally(() => { | ||
case "lint-ci": | ||
case "dev-ci": | ||
case "exemption-report": | ||
{ | ||
(0, _fileUtils.checkConfigurationFileExist)(); | ||
(0, _requestUtils.createBranchDiff)(); | ||
const $cliObjects = (0, _cliArgsToObject.cliArgsToObject)(option); | ||
$cliObjects.env = 'ci'; | ||
$cliObjects.env = "ci"; | ||
$cliObjects.cmdExecuted = action; | ||
const execute = new _Execution.default(_Eslint.default, _SonarQube.default, $cliObjects); | ||
@@ -50,10 +58,26 @@ await execute.executeLintHandler().finally(() => { | ||
} | ||
case "fix": | ||
{ | ||
(0, _runEslint.fixEslintIssue)(option); | ||
break; | ||
} | ||
case "init": | ||
{ | ||
// const $cliObjects = cliArgsToObject(option) | ||
(0, _initialSetup.setupDefaultConfiguration)(); | ||
break; | ||
} | ||
case "check": | ||
{ | ||
(0, _fileUtils.checkConfigurationFileExist)(); | ||
require("../core/eslint/ErrorBetweenBranches"); | ||
break; | ||
} | ||
case "help": | ||
{ | ||
(0, _helper.consoleHelperCommands)(); | ||
break; | ||
} | ||
default: | ||
{ | ||
(0, _helper.consoleHelperCommands)(); | ||
break; | ||
@@ -60,0 +84,0 @@ } |
@@ -20,9 +20,26 @@ "use strict"; | ||
const sampleConfigPath = _path.default.join(__dirname, "sampleLint.config.js"); | ||
if ((0, _fileUtils.checkIfFileExists)(configPath) && typeof require(configPath) == "object") { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `configuration file already exist`); | ||
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `configuration done .. `); | ||
if ((0, _fileUtils.checkIfFileExists)(configPath) && checkBothConfigurationIsSame(configPath, sampleConfigPath)) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `\n configuration file already exist`); | ||
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `\n configuration done .. `); | ||
process.exit(0); | ||
} | ||
// if(!checkIfFileExists(configPath) ){ | ||
// writeFileContents(configPath,readFileContents(sampleConfigPath)) | ||
// Logger.log(Logger.SUCCESS_TYPE, `\n configuration done .. `); | ||
// return; | ||
// } | ||
(0, _fileUtils.writeFileContents)(configPath, (0, _fileUtils.readFileContents)(sampleConfigPath)); | ||
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `configuration done .. `); | ||
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `\n configuration done .. `); | ||
} | ||
/** | ||
* @function checkBothConfigurationIsSame - check both configuration are same | ||
* @param {string} configPath | ||
* @param {string} sampleConfigPath | ||
* @returns | ||
*/ | ||
function checkBothConfigurationIsSame(configPath, sampleConfigPath) { | ||
return JSON.stringify(configPath) == JSON.stringify(sampleConfigPath); | ||
} |
@@ -5,9 +5,15 @@ const path = require("path"); | ||
* Configuration object for linting and reporting. | ||
* @typedef {Object} LintConfiguration | ||
* @property {string} ruleConfigurationPath - The path to the ESLint configuration file. | ||
* @property {boolean} impactBased - Indicates if the linting is impact-based. | ||
* @property {string} lintReportPath - The path to the lint report JSON file. | ||
* @property {string} sonar_host_URL - The URL of the SonarQube server. | ||
* @property {string} loginName - The username for authentication with the SonarQube server. | ||
* @property {string} password - The password for authentication with the SonarQube server. | ||
* @property {string} metricServerHost - The URL of the SonarQube server. | ||
* @property {string} exemptionInstanceHost - This is Exemption running host URL | ||
* @property {string} metric_token - The token for authentication with the SonarQube server. | ||
* @property {string} gitEndPoint - API EndPoint for Git Actions | ||
* @property {string} tsConfigurationPath - The path of the ts configuration Path | ||
* @property {number} projectId - project id of repository | ||
* @property {boolean} impactBasedPrecommit - Indicates if the linting is impact-based in pre commit | ||
* @property {boolean} shouldWarningsAbortCommit - Indicates if eslint warnings should abort the commit | ||
* @property {string} token - Encrypted Authentication Token | ||
* @property {string} compareBranch - Branch to compare diff | ||
*/ | ||
@@ -20,6 +26,14 @@ | ||
lintReportPath: path.resolve(process.cwd(), "lint-report", "lintReport.json"), | ||
sonar_hostURL: "https://serverlinter-np.zohodesk.csez.zohocorpin.com", | ||
loginName: "developer", | ||
password: "developer", | ||
branchDiffPath:path.resolve(process.cwd(),"diffBranch.json") | ||
metricServerHost: "https://client-linters.zohodesk.csez.zohocorpin.com", | ||
exemptionInstanceHost:"", | ||
metric_token: "zxh_9737850jh2l53ml17223929ihii73072j54j2260", | ||
branchDiffPath:path.resolve(process.cwd(),"diffBranch.json"), | ||
gitEndPoint:"https://zgit.csez.zohocorpin.com", | ||
tsConfigurationPath:path.resolve(process.cwd(),'tsconfig.json'), | ||
projectId:`project-id`, | ||
impactBasedPrecommit:true, | ||
shouldWarningsAbortCommit: false, | ||
token:"w-OkG3f5OOM1Rkly8phZ", | ||
compareBranch:'release' | ||
}; | ||
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.cliArgsToObject = cliArgsToObject; | ||
exports.mergeArrayObjects = mergeArrayObjects; | ||
exports.objectToCliArgs = objectToCliArgs; | ||
@@ -51,2 +52,13 @@ /** | ||
return argsArray; | ||
} | ||
function mergeArrayObjects(array) { | ||
return array.reduce((acc, obj) => { | ||
for (const key in obj) { | ||
if (!acc[key]) { | ||
acc[key] = []; | ||
} | ||
acc[key] = acc[key].concat(obj[key]); | ||
} | ||
return acc; | ||
}, {}); | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
}); | ||
exports.checkConfigurationFileExist = checkConfigurationFileExist; | ||
exports.checkIfFileExists = checkIfFileExists; | ||
@@ -16,5 +17,8 @@ exports.deleteFile = deleteFile; | ||
exports.writeFileContents = writeFileContents; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _fs = _interopRequireWildcard(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _getFileUtils = require("../core/eslint/getFileUtils"); | ||
var _logger = require("./logger"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
/** | ||
@@ -118,3 +122,3 @@ * @function checkIfFileExists - checks if a file exists. | ||
if (_fs.default.statSync(absoluteDirPath).isFile()) { | ||
return [absoluteDirPath]; | ||
return (0, _getFileUtils.filterFiles)([absoluteDirPath]); | ||
} | ||
@@ -146,4 +150,4 @@ const fileList = _fs.default.readdirSync(absoluteDirPath); | ||
* @function {isDirectory} - function checks given path is file or directory | ||
* @param {string} path - path of file to check | ||
* @returns {Boolean} | ||
* @param {string} path - path of file to check | ||
* @returns {Boolean} | ||
*/ | ||
@@ -153,2 +157,13 @@ | ||
return _fs.default.statSync(path).isDirectory(); | ||
} | ||
/** | ||
* @function checkConfigurationFileExist - check configuration present or not and console warn | ||
* @returns {void} | ||
*/ | ||
function checkConfigurationFileExist() { | ||
const isConfigPresent = (0, _fs.existsSync)(_path.default.resolve(process.cwd(), "lint.config.js")); | ||
isConfigPresent ? null : _logger.Logger.log(_logger.Logger.INFO_TYPE, `\n configuration file doesn't present kindly following command - npx ZDLintingFramework init`); | ||
return isConfigPresent; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.Logger = void 0; | ||
exports.reportSummaryConsole = reportSummaryConsole; | ||
var _fs = require("fs"); | ||
@@ -13,2 +14,3 @@ var _chalk = _interopRequireDefault(require("chalk")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _sonarReportSummary = require("../core/sonar-dependencies/sonarReportSummary.js"); | ||
class LoggerImpl { | ||
@@ -93,5 +95,4 @@ constructor() { | ||
cliLog(type, message) { | ||
const consolePrefix = type === "success" ? `✔` : type === "failure" ? `✘` : ""; | ||
const color = this.cliColors[type]; | ||
this.consoleLogger.log(color(`${consolePrefix} ${message}`)); | ||
const _console = type === "success" ? _chalk.default.white.green.bold : type === "failure" ? _chalk.default.white.green.bold : _chalk.default.white.bold; | ||
this.consoleLogger.log(_console(`${message}`)); | ||
} | ||
@@ -123,2 +124,27 @@ | ||
} | ||
var Logger = exports.Logger = new LoggerImpl(); | ||
var Logger = exports.Logger = new LoggerImpl(); | ||
function reportSummaryConsole() { | ||
const { | ||
impactBased | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const { | ||
reportStatus, | ||
pipelineStatus | ||
} = (0, _sonarReportSummary.getLintStatus)(impactBased); | ||
const typeOfConsole = reportStatus == false ? Logger.FAILURE_TYPE : Logger.SUCCESS_TYPE; | ||
const messageToConsole = reportStatus == false ? `pipeline is failed. because of rule violation` : null; | ||
messageToConsole && Logger.cliLog(typeOfConsole, messageToConsole); | ||
} | ||
function consoleViolatedRules() { | ||
const { | ||
lintReportPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const rule_object = require(lintReportPath).map(rule => { | ||
return { | ||
file: rule.filePath, | ||
rule_violated: rule.errorCount == 0 ? null : rule.messages.map(message => { | ||
return message.ruleId; | ||
}) | ||
}; | ||
}); | ||
} |
{ | ||
"name": "@zohodesk/codestandard-analytics", | ||
"version": "0.0.1-exp-3", | ||
"version": "0.0.1-exp-30", | ||
"description": "linting tool", | ||
"main": "./build/index.js", | ||
"dependencies": { | ||
"@zohodesk/codestandard-validator": "0.0.2", | ||
"eslint": "8.57.0" | ||
"eslint": "8.57.0", | ||
"@babel/runtime": "7.25.7", | ||
"chalk": "4.1.2", | ||
"commander": "11.1.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.24.3", | ||
"@babel/plugin-transform-runtime": "^7.24.7", | ||
"@babel/preset-env": "^7.24.3", | ||
"chalk": "4.1.0", | ||
"commander": "^12.1.0", | ||
"prettier": "3.2.5", | ||
"postinstall":"node bin/postInstall.js" | ||
"@babel/core": "7.24.3", | ||
"@babel/plugin-transform-runtime": "7.24.7", | ||
"@babel/preset-env": "7.24.3", | ||
"prettier": "3.2.5" | ||
}, | ||
@@ -25,3 +23,3 @@ "scripts": { | ||
"type": "git", | ||
"url": "https://zgit.csez.zohocorpin.com/zohodesk/internal-tools/lint_analysis.git" | ||
"url": "https://zgit.csez.zohocorpin.com/zohodesk/code_standard/client_linter/linter_tools.git" | ||
}, | ||
@@ -31,4 +29,7 @@ "bin": { | ||
}, | ||
"author": "", | ||
"author": { | ||
"name": "rajasekar", | ||
"email": "rajasekar.hm@zohocorp.com" | ||
}, | ||
"license": "ISC" | ||
} |
# Linter Analysis Tool | ||
## Overview | ||
This tool is designed to streamline the linting process for JavaScript projects using ESLint and SonarQube. It automates the configuration of ESLint and facilitates integration with your SonarQube server for comprehensive code analysis. | ||
## Configuration | ||
### ESLint | ||
ESLint configuration can be customized in the `.eslintrc.js` file. Refer to the ESLint documentation for available configuration options and rules. | ||
## SonarQube | ||
### Need to setup Sonar Jar in Java-jar Folder | ||
Configure your SonarQube server settings in the `getSonarProperties` file. Make sure to provide the correct server URL, authentication tokens, and project key. | ||
Configure your SonarQube server settings in the `lint.config.js` file. | ||
## Usage | ||
To lint your code using ESLint, run the following command: | ||
npx ZDLintingFramework lint | ||
## flags | ||
--diff - response of branch diff api | ||
--dir - directory to lint | ||
-** To run locally ** | ||
```bash | ||
npx npx ZDLintingFramework lint -- --dir=path/to/file | ||
``` | ||
--** To run CI ** | ||
```bash | ||
npx ZDLintingFramework lint-ci | ||
``` | ||
## flags | ||
- `--dir` - specify directory to lint |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
735013
4
31
2160
45
1
38
4
13
7
6
+ Added@babel/runtime@7.25.7
+ Addedchalk@4.1.2
+ Addedcommander@11.1.0
+ Added@babel/runtime@7.25.7(transitive)
+ Addedcommander@11.1.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removed@zohodesk/codestandard-validator@0.0.2(transitive)