Skip to content

Commit

Permalink
Pass working directory to standard
Browse files Browse the repository at this point in the history
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]: 5b05e68
[3]: standard/standard-engine#189
  • Loading branch information
sonicdoe committed Aug 3, 2019
1 parent ad23c9a commit 1dbc2d6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/linter-js-standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 1dbc2d6

Please sign in to comment.