Skip to content

Commit

Permalink
Add JSDoc for the summary table creator function (#78)
Browse files Browse the repository at this point in the history
* Add JSDoc for the summary table creator function

* Change files

* don't create csv by default

* Change files

---------

Co-authored-by: Anmol Shrestha <[email protected]>
  • Loading branch information
anmolshres98 and anmolshres98 authored Jul 18, 2024
1 parent f6e98ad commit a913c9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Don't create csv report by default and add JSDoc for the summary table creator function",
"packageName": "@itwin/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "patch"
}
19 changes: 17 additions & 2 deletions dist/formatters/utils/no-internal-summary-table-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ const fs = require('fs');
const process = require('process');
const createAsciiTable = require('./create-ascii-table');

module.exports = function(messages, ruleId, createCSV = true) {
/**
* Generates a summary table and optionally a CSV from linting messages for a specific rule.
*
* This function processes an array of linting messages, filters them by a specified rule ID,
* and then generates a summary table and optionally a CSV file based on these messages.
*
* The summary table is always created and returned while the CSV file is created only if the
* `createCSV` flag is set to `true`.
*
* @param {Object[]} messages - An array of linting message objects to be processed.
* @param {string} ruleId - The ID of the linting rule to filter messages by.
* @param {boolean} [createCSV=false] - A boolean flag indicating whether to create a CSV file (`true`)
* or not. Defaults to `false`.
* @returns {string} The generated summary table as a string.
*/
module.exports = function(messages, ruleId, createCSV = false) {
const problemFiles = new Map();
const errorTracker = new Map();
const tagViolationsTracker = new Map();
Expand Down Expand Up @@ -41,7 +56,7 @@ module.exports = function(messages, ruleId, createCSV = true) {
});

if (problemFiles.size === 0 || errorTracker.size === 0 || tagViolationsTracker.size === 0)
return;
return '';

// iterate over the problemFiles and for each value, remove the last comma from locations
for (const [key, value] of problemFiles.entries()) {
Expand Down

0 comments on commit a913c9a

Please sign in to comment.