Skip to content

Added an explicit error message for TSLint versions too low #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2019
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