Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSDoc for the summary table creator function #78

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading