diff --git a/lib/config/config-file.js b/lib/config/config-file.js index e68591874c0b..4e25887fd47a 100644 --- a/lib/config/config-file.js +++ b/lib/config/config-file.js @@ -495,7 +495,6 @@ function resolve(filePath, relativeTo) { function load(filePath, applyEnvironments, relativeTo) { var resolvedPath = resolve(filePath, relativeTo), dirname = path.dirname(resolvedPath.filePath), - basedir = getBaseDir(dirname), lookupPath = getLookupPath(dirname), config = loadConfigFile(resolvedPath); @@ -514,7 +513,7 @@ function load(filePath, applyEnvironments, relativeTo) { // include full path of parser if present if (config.parser) { if (isFilePath(config.parser)) { - config.parser = path.resolve(basedir || "", config.parser); + config.parser = path.resolve(dirname || "", config.parser); } else { config.parser = resolver.resolve(config.parser, lookupPath); } @@ -528,7 +527,7 @@ function load(filePath, applyEnvironments, relativeTo) { * a "parent". Load the referenced file and merge the configuration recursively. */ if (config.extends) { - config = applyExtends(config, filePath, basedir); + config = applyExtends(config, filePath, dirname); } if (config.env && applyEnvironments) { diff --git a/tests/fixtures/config-file/extends-chain-2/relative.eslintrc.json b/tests/fixtures/config-file/extends-chain-2/relative.eslintrc.json new file mode 100644 index 000000000000..ad711c30b2ce --- /dev/null +++ b/tests/fixtures/config-file/extends-chain-2/relative.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/eslint-config-a/index.js" +} diff --git a/tests/lib/config/config-file.js b/tests/lib/config/config-file.js index bfb80f562c86..2cb050b6876f 100644 --- a/tests/lib/config/config-file.js +++ b/tests/lib/config/config-file.js @@ -657,6 +657,21 @@ describe("ConfigFile", function() { }); }); + it("should load information from `extends` chain with relative path.", function() { + var config = ConfigFile.load(getFixturePath("extends-chain-2/relative.eslintrc.json")); + + assert.deepEqual(config, { + env: {}, + extends: "./node_modules/eslint-config-a/index.js", + globals: {}, + parserOptions: {}, + rules: { + a: 2, // from node_modules/eslint-config-a/index.js + relative: 2 // from node_modules/eslint-config-a/relative.js + } + }); + }); + describe("Plugins", function() { it("should load information from a YML file and load plugins", function() {