From 1dbc2d63d105bd3b1579a40f774953568d944ce3 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Sat, 3 Aug 2019 08:53:27 +0200 Subject: [PATCH] Pass working directory to standard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In standard v13 (with ESLint v6), the current working directory is evaluated using `process.cwd()` when ESLint is initialized, see [`config-array-factory.js`][1]. Since we currently change the working directory _after_ standard is required, ESLint will fail to find modules because it’s trying to resolve them from the root directory (as can be seen by the require stack of `/__placeholder__.js`). Using standard’s `cwd` option resolves this issue. Previously, we couldn’t use this option because standard-engine did not pass it through to ESLint, see [`5b05e68`][2] and [standard/standard-engine#189][3]. To maintain compatibility with older standard versions, we still use `process.chdir()` as well. Fixes #231. [1]: https://github.com/eslint/eslint/blob/f5e0cc40795f175692acb05daaadb91e9e5ae5d3/lib/cli-engine/config-array-factory.js#L346 [2]: https://github.com/ricardofbarros/linter-js-standard/commit/5b05e688090e0c4abfa36c1cc2833321dd6a0a10 [3]: https://github.com/standard/standard-engine/pull/189 --- lib/linter-js-standard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linter-js-standard.js b/lib/linter-js-standard.js index a3ca4da..141b069 100644 --- a/lib/linter-js-standard.js +++ b/lib/linter-js-standard.js @@ -49,6 +49,7 @@ module.exports = function (textEditor) { var opts = styleSettings.checkStyleSettings(filePath, textEditor) + opts.cwd = path.dirname(filePath) opts.filename = filePath var style = selectStyle(filePath, {