How to use the table function in table

To help you get started, we’ve selected a few table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajus / canonical / src / formatters / tableFormatter.js View on Github external
export default (report: ReportType): string => {
    let result;

    result = '';

    if (report.errorCount || report.warningCount) {
        result = drawReport(report.results);
    }

    result += '\n' + table([
        [
            chalk.red(pluralize('Error', report.errorCount, true))
        ],
        [
            chalk.yellow(pluralize('Warning', report.warningCount, true))
        ]
    ], {
        columns: {
            0: {
                width: 110,
                wrapWord: true
            }
        },
        drawHorizontalLine: _.constant(true)
    });
github gajus / canonical / src / formatters / tableFormatter.js View on Github external
if (message.fatal || message.severity === 2) {
            messageType = chalk.red('error');
        } else {
            messageType = chalk.yellow('warning');
        }

        rows.push([
            message.line || 0,
            message.column || 0,
            messageType,
            message.message.replace(/\.$/, ''),
            message.ruleId || ''
        ]);
    });

    return table(rows, {
        columns: {
            0: {
                width: 8,
                wrapWord: true
            },
            1: {
                width: 8,
                wrapWord: true
            },
            2: {
                width: 8,
                wrapWord: true
            },
            3: {
                paddingRight: 5,
                width: 50,
github flow-typed / flow-typed / cli / src / commands / search.js View on Github external
export function _formatDefTable(defs: Array): string {
  const formatted = [['Name', 'Package Version', 'Flow Version']].concat(
    defs.map(def => {
      return [
        def.pkgName,
        def.pkgVersionStr,
        flowVersionToSemver(def.flowVersion),
      ];
    }),
  );
  if (formatted.length === 1) {
    return 'No definitions found, sorry!';
  } else {
    return '\nFound definitions:\n' + table(formatted);
  }
}