Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Fix findup when file found in subdirectory #2765

Merged
merged 1 commit into from
May 19, 2017
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
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function findup(filename: string, directory: string): string | undefined {
while (true) { // tslint:disable-line strict-boolean-expressions
const res = findFile(directory);
if (res !== undefined) {
return res;
return path.join(directory, res);
}

const parent = path.dirname(directory);
Expand Down
18 changes: 18 additions & 0 deletions test/configurationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as path from "path";
import {
convertRuleOptions,
extendConfigurationFile,
findConfigurationPath,
IConfigurationFile,
loadConfigurationFromPath,
parseConfigFile,
Expand Down Expand Up @@ -194,6 +195,23 @@ describe("Configuration", () => {
});
});

describe("findConfigurationPath", () => {
it("finds the closest tslint.json", () => {
assert.strictEqual(
findConfigurationPath(null, "./test/files/config-findup/contains-config"),
path.resolve("test/files/config-findup/contains-config/tslint.json"),
);
assert.strictEqual(
findConfigurationPath(null, "./test/files/config-findup/no-config"),
path.resolve("./test/files/config-findup/tslint.json"),
);
assert.strictEqual(
findConfigurationPath(null, "./test/files/config-findup"),
path.resolve("./test/files/config-findup/tslint.json"),
);
});
});

describe("loadConfigurationFromPath", () => {
it("extends with relative path", () => {
const config = loadConfigurationFromPath("./test/config/tslint-extends-relative.json");
Expand Down
1 change: 1 addition & 0 deletions test/files/config-findup/contains-config/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file.
1 change: 1 addition & 0 deletions test/files/config-findup/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}