Skip to content
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
18 changes: 12 additions & 6 deletions src/input/findTSLintConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export const findTSLintConfiguration = async (
config || "./tslint.json",
);

return rawConfiguration instanceof Error
? rawConfiguration
: {
...defaultTSLintConfiguration,
...rawConfiguration,
};
if (rawConfiguration instanceof Error) {
if (rawConfiguration.message.includes("unknown option `--print-config")) {
return new Error("TSLint v5.18 required. Please update your version.");
}

return rawConfiguration;
}

return {
...defaultTSLintConfiguration,
...rawConfiguration,
};
};
16 changes: 16 additions & 0 deletions src/input/findTslintConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ describe("findTSLintConfiguration", () => {
);
});

it("replaces an error with a v5.18 request when the --print-config option is unsupported", async () => {
// Arrange
const stderr = "unknown option `--print-config";
const dependencies = { exec: createStubThrowingExec({ stderr }) };

// Act
const result = await findTSLintConfiguration(dependencies, undefined);

// Assert
expect(result).toEqual(
expect.objectContaining({
message: "TSLint v5.18 required. Please update your version.",
}),
);
});

it("defaults the configuration file when one isn't provided", async () => {
// Arrange
const dependencies = { exec: createStubExec() };
Expand Down