Skip to content

Commit

Permalink
feat(checker): Do not output anything if there are no conflicting rul…
Browse files Browse the repository at this point in the history
…es (#134)
  • Loading branch information
astorije authored and ikatyang committed Apr 19, 2018
1 parent b5d8504 commit ae07ea7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions tools/__snapshots__/checker.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ exports[`should be able to check multiple config files 1`] = `
[error] trailing-comma
[error] typedef-whitespace
[error] whitespace
[log] No conflict rule detected in <cwd>/fixtures/tslint.empty.json
[error] Unexpected number in JSON at position 1 in <cwd>/fixtures/tslint.error.json"
`;
exports[`should show success message for conflict rules that is disabled 1`] = `"[log] No conflict rule detected in <cwd>/fixtures/tslint.false.json"`;
exports[`should show nothing for conflict rules that is disabled 1`] = `""`;
exports[`should show success message for non-conflict rules 1`] = `"[log] No conflict rule detected in <cwd>/fixtures/tslint.empty.json"`;
exports[`should show nothing for non-conflict rules 1`] = `""`;
exports[`should show usage if there is no filePath 1`] = `"[log] Usage: tslint-config-prettier-check <pathToConfigFile> ..."`;
Expand Down
4 changes: 2 additions & 2 deletions tools/checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ it("should throw parsing error for invalid config", () => {
expect(process.exitCode).toBe(1);
});

it("should show success message for non-conflict rules", () => {
it("should show nothing for non-conflict rules", () => {
checkFixture("empty");
expect(getMessage()).toMatchSnapshot();
expect(process.exitCode).toBe(0);
});

it("should show success message for conflict rules that is disabled", () => {
it("should show nothing for conflict rules that is disabled", () => {
checkFixture("false");
expect(getMessage()).toMatchSnapshot();
expect(process.exitCode).toBe(0);
Expand Down
5 changes: 1 addition & 4 deletions tools/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export const check = (configFilePaths: string[]) => {
configFilePaths.forEach((configFilePath) => {
try {
const conflictRules = getConflictRules(configFilePath);
if (conflictRules.length === 0) {
// tslint:disable-next-line:no-console
console.log(`No conflict rule detected in ${configFilePath}`);
} else {
if (conflictRules.length) {
// tslint:disable-next-line:no-console
console.error(
`Conflict rule(s) detected in ${configFilePath}:\n${conflictRules
Expand Down

0 comments on commit ae07ea7

Please sign in to comment.