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 20, 2016
1 parent 414206c commit 7854109
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/config/config-file.js
Expand Up @@ -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);

Expand All @@ -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);
}
Expand All @@ -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) {
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 7854109

Please sign in to comment.