diff --git a/lib/config/config-file.js b/lib/config/config-file.js index e68591874c0..035a644c5b4 100644 --- a/lib/config/config-file.js +++ b/lib/config/config-file.js @@ -313,7 +313,7 @@ function write(config, filePath) { function getBaseDir(configFilePath) { // calculates the path of the project including ESLint as dependency - var projectPath = path.resolve(__dirname, "../../../"); + var projectPath = path.resolve(__dirname, "../../../../"); if (configFilePath && pathIsInside(configFilePath, projectPath)) { 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 00000000000..ad711c30b2c --- /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 bfb80f562c8..4925ff44922 100644 --- a/tests/lib/config/config-file.js +++ b/tests/lib/config/config-file.js @@ -34,7 +34,7 @@ proxyquire = proxyquire.noCallThru().noPreserveCache(); * fine for the purposes of testing because the tests are just relative to an * ancestor location. */ -var PROJECT_PATH = path.resolve(__dirname, "../../../../"), +var PROJECT_PATH = path.resolve(__dirname, "../../../../../"), PROJECT_DEPS_PATH = path.join(PROJECT_PATH, "node_modules"); /** @@ -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() {