Skip to content

Commit

Permalink
feat: Print offending members in red (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-zhong authored May 9, 2021
1 parent bd16856 commit 26227f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ const cliConfig = yargs(process.argv.slice(2))
.options({
project: {
type: "string",
describe: "Path to the project config file (tsconfig.json)",
describe: "Path to the project's tsconfig.json",
},
fix: { type: "boolean", describe: "Auto fix offending members" },
path: { type: "string", describe: "Path to the directory or file to scan" },
path: {
type: "string",
describe: "Path to a single directory/file to scan",
},
ignoreFileRegex: {
type: "string",
describe: "Regex for checking if a file should be ignored",
describe: "Regex pattern for excluding files",
},
})
.help().argv;
Expand Down
7 changes: 4 additions & 3 deletions src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ export const printProgress = (progress: string) => {
};

export const printResults = (results: IOffendingMembers[]) => {
const logRed = (str: string) => console.log("\x1b[31m%s\x1b[0m", str);
const groupedByFile = groupBy(results, (entry) => entry.file.getFilePath());

Object.entries(groupedByFile).forEach(([filePath, results]) => {
console.log();
console.log(filePath);
logRed(filePath);

const groupedByClass = groupBy(results, (entry) => entry.class.getName());

Object.entries(groupedByClass).forEach(([className, results]) => {
console.log(className);
logRed(className);

results.forEach(({ declaration, reason }) => {
console.log(`- ${declaration.getName()}: ${reason}`);
logRed(`- ${declaration.getName()}: ${reason}`);
});
});

Expand Down

0 comments on commit 26227f7

Please sign in to comment.