@zohodesk/codestandard-analytics
Advanced tools
Comparing version 0.0.1-exp-14 to 0.0.1-exp-15
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.executeLintAnalysis = executeLintAnalysis; | ||
exports.fixEslintIssue = fixEslintIssue; | ||
var _eslint = require("eslint"); | ||
@@ -15,2 +16,3 @@ var _path = _interopRequireDefault(require("path")); | ||
var _logger = require("../../utils/logger"); | ||
var _child_process = require("child_process"); | ||
/** | ||
@@ -106,2 +108,23 @@ * @function executeLintAnalysis - start lint analysis | ||
} | ||
} | ||
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); | ||
} | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _runEslint = require("../core/eslint/runEslint.js"); | ||
var _Eslint = _interopRequireDefault(require("../core/handlers/libraryInterface/Eslint")); | ||
@@ -53,15 +54,7 @@ var _Execution = _interopRequireDefault(require("../core/handlers/libraryInterface/Execution")); | ||
} | ||
// case "check-local":{ | ||
// checkConfigurationFileExist(); | ||
// createBranchDiff(); | ||
// const $cliObjects = cliArgsToObject(option); | ||
// $cliObjects.cmdExecuted = action; | ||
// const execute = new Execution(EsLint, SonarQube, $cliObjects); | ||
// await execute.executeLintHandler().finally(() => { | ||
// execute.executeMetricHandler(); | ||
// }); | ||
// break; | ||
// } | ||
case "fix": | ||
{ | ||
(0, _runEslint.fixEslintIssue)(option); | ||
break; | ||
} | ||
case "init": | ||
@@ -68,0 +61,0 @@ { |
@@ -5,3 +5,3 @@ const path = require("path"); | ||
* Configuration object for linting and reporting. | ||
* @typedef {Object} LintConfiguration | ||
* @typedef {Object} LintConfiguration | ||
* @property {string} ruleConfigurationPath - The path to the ESLint configuration file. | ||
@@ -14,2 +14,3 @@ * @property {boolean} impactBased - Indicates if the linting is impact-based. | ||
* @property {string} gitEndPoint - API EndPoint for Git Actions | ||
* @property {number} projectId - project id of repository | ||
* @property {string} token - Encrypted Authentication Token | ||
@@ -16,0 +17,0 @@ * @property {string} compareBranch - Branch to compare diff |
@@ -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 { | ||
@@ -122,2 +124,27 @@ constructor() { | ||
} | ||
var Logger = exports.Logger = new LoggerImpl(); | ||
var Logger = exports.Logger = new LoggerImpl(); | ||
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; | ||
}) | ||
}; | ||
}); | ||
} | ||
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); | ||
} |
@@ -93,8 +93,7 @@ "use strict"; | ||
command = (0, _child_process.execSync)(`curl --header "PRIVATE-TOKEN:${(0, _hash.decrypt)(token, 12)}" "${endPoint}"`); | ||
console.log(JSON.parse(command.toString()).pop().id); | ||
return JSON.parse(command.toString()).pop().id; | ||
} catch (err) { | ||
console.log(err); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that you have access to this repository ${(0, _getSonarProperties.getRepoName)()}`); | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, err); | ||
} | ||
} |
{ | ||
"name": "@zohodesk/codestandard-analytics", | ||
"version": "0.0.1-exp-14", | ||
"version": "0.0.1-exp-15", | ||
"description": "linting tool", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
729099
2049
15
9