All files / src/reporter text.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 6/6
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x 1x     1x 3x   1x 3x   2x 3x   3x     2x    
import groupBy from "lodash/groupBy";
import sortBy from "lodash/sortBy";
import { Reporter, ReportMessage } from "./Reporter";
 
export const stringify = ({ line, message, ruleName }: ReportMessage): string =>
  `  ${line}: ${message} (${ruleName})`;
 
export const text: Reporter = async comments => {
  Object.entries(groupBy(comments, ({ file }) => file)).forEach(
    ([file, fileComments]) => {
      console.log("\n" + file);
      sortBy(fileComments, c => c.line)
        .map(stringify)
        .forEach(text => console.log(text));
    }
  );
  console.log(`\n${comments.length} errors found`);
};