Skip to content

Commit

Permalink
Fix: wrong baseDir (fixes #6450)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jun 17, 2016
1 parent 414206c commit 4c80417
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/config/config-file.js
Expand Up @@ -315,6 +315,10 @@ function getBaseDir(configFilePath) {
// calculates the path of the project including ESLint as dependency
var projectPath = path.resolve(__dirname, "../../../");

if (path.basename(projectPath) === "node_modules") {
projectPath = path.dirname(projectPath);
}

if (configFilePath && pathIsInside(configFilePath, projectPath)) {

// be careful of https://github.com/substack/node-resolve/issues/78
Expand Down
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/eslint-config-a/index.js"
}
15 changes: 15 additions & 0 deletions tests/lib/config/config-file.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 4c80417

Please sign in to comment.