From a8d09c02bfdce78ca9c8a9f57ddcc05120a73679 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 5 Mar 2016 14:42:21 +0700 Subject: [PATCH] add a temp fix for #71 and update dependencies --- options-manager.js | 19 ++++++++++++++++++- package.json | 11 +++++++---- test/cli.js | 2 +- .../eslint-config-custom/config.json | 7 +++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/options-manager.js b/options-manager.js index d0dde462..f86edd8f 100644 --- a/options-manager.js +++ b/options-manager.js @@ -6,6 +6,8 @@ var deepAssign = require('deep-assign'); var objectAssign = require('object-assign'); var homeOrTmp = require('home-or-tmp'); var multimatch = require('multimatch'); +var resolveFrom = require('resolve-from'); +var pathExists = require('path-exists'); var DEFAULT_IGNORE = [ '**/node_modules/**', @@ -98,7 +100,22 @@ function buildConfig(opts) { } if (opts.extends && opts.extends.length > 0) { - config.baseConfig.extends = config.baseConfig.extends.concat(opts.extends); + // TODO: this logic needs to be improved, preferably use the same code as ESLint + // user's configs must be resolved to their absolute paths + var configs = opts.extends.map(function (name) { + // don't do anything if it's a filepath + if (pathExists.sync(name)) { + return name; + } + + if (name.indexOf('eslint-config-') === -1) { + name = 'eslint-config-' + name; + } + + return resolveFrom(opts.cwd, name); + }); + + config.baseConfig.extends = config.baseConfig.extends.concat(configs); } return config; diff --git a/package.json b/package.json index 44b003a4..41b1a8e6 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,15 @@ ], "dependencies": { "arrify": "^1.0.0", - "babel-eslint": "^5.0.0", + "babel-eslint": "^6.0.0-beta.1", "debug": "^2.2.0", "deep-assign": "^1.0.0", - "eslint": "^2.0.0", - "eslint-config-xo": "^0.10.1", - "eslint-plugin-babel": "^3.0.0", + "eslint": "^2.3.0", + "eslint-config-xo": "^0.12.0", + "eslint-plugin-babel": "^3.1.0", "eslint-plugin-no-empty-blocks": "0.0.2", "eslint-plugin-no-use-extend-native": "^0.3.2", + "estraverse-fb": "^1.3.1", "get-stdin": "^5.0.0", "globby": "^4.0.0", "has-flag": "^1.0.0", @@ -76,8 +77,10 @@ "meow": "^3.4.2", "multimatch": "^2.1.0", "object-assign": "^4.0.1", + "path-exists": "^2.1.0", "pkg-conf": "^1.0.1", "resolve-cwd": "^1.0.0", + "resolve-from": "^2.0.0", "update-notifier": "^0.6.0", "xo-init": "^0.3.0" }, diff --git a/test/cli.js b/test/cli.js index 43ca7cc1..811162e4 100644 --- a/test/cli.js +++ b/test/cli.js @@ -32,7 +32,7 @@ test.skip('ignores fixture', async t => { t.throws(execa('../../../cli.js', ['--no-local'], {cwd})); }); -test('supports shareable config', async () => { +test('supports being extended with a shareable config', async () => { const cwd = path.join(__dirname, 'fixtures/project'); await execa('../../../cli.js', ['--no-local'], {cwd}); }); diff --git a/test/fixtures/project/node_modules/eslint-config-custom/config.json b/test/fixtures/project/node_modules/eslint-config-custom/config.json index de624671..c7cd6733 100644 --- a/test/fixtures/project/node_modules/eslint-config-custom/config.json +++ b/test/fixtures/project/node_modules/eslint-config-custom/config.json @@ -1,6 +1,5 @@ { - "object-curly-spacing": [ - 2, - "always" - ] + "rules": { + "babel/object-curly-spacing": [2, "always"] + } }