From 00e0f58598a5123b87fb25588e4ccb6aa088e046 Mon Sep 17 00:00:00 2001 From: Mato Ilic Date: Fri, 10 Mar 2017 21:20:33 +0100 Subject: [PATCH] ensure NODE_PATH environment variable is honored when checking for extraneous dependencies --- packages/eslint-config-react-app/index.js | 3 +++ packages/eslint-config-react-app/package.json | 1 + .../eslint-config-react-app/utils/resolveNodePath.js | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 packages/eslint-config-react-app/utils/resolveNodePath.js diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index dfc4ad0df6d..c9f3640acea 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -9,6 +9,8 @@ 'use strict'; +const resolveNodePath = require('./utils/resolveNodePath'); + // Inspired by https://github.com/airbnb/javascript but less opinionated. // We use eslint-loader so even warnings are very visible. @@ -49,6 +51,7 @@ module.exports = { 'import/resolver': { node: { extensions: ['.js', '.json'], + moduleDirectory: ['node_modules'].concat(resolveNodePath()), }, }, }, diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 855713e4f46..8d6c0714b63 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -8,6 +8,7 @@ "url": "https://github.com/facebookincubator/create-react-app/issues" }, "files": [ + "utils", "index.js" ], "peerDependencies": { diff --git a/packages/eslint-config-react-app/utils/resolveNodePath.js b/packages/eslint-config-react-app/utils/resolveNodePath.js new file mode 100644 index 00000000000..5e9795ae97a --- /dev/null +++ b/packages/eslint-config-react-app/utils/resolveNodePath.js @@ -0,0 +1,11 @@ +'use strict'; + +function resolveNodePath() { + const nodePaths = (process.env.NODE_PATH || '') + .split(process.platform === 'win32' ? ';' : ':') + .filter(Boolean); + + return nodePaths; +} + +module.exports = resolveNodePath;