CLIEngine API to resolve config name to absolute path
See original GitHub issueEdit to clarify:
In XO, I accept similar options like ESLint does in package.json
. One of these are extends
. When a user specifies "xo": {"extends": "react"}
in package.json, XO reads it, adds it to baseConfig.extends
and passes it to ESLint. The problem is that the user expects react
to be resolved from their package.json’s location, but baseConfig.extends
is resolved from __dirname
, which is the folder of XO, not the user’s project. I’ve worked around this until now by manually resolving to an absolute path first, but my resolution logic is buggy. I would like to use the same logic ESLint uses internally to resolve the path of a config with a custom cwd
.
The baseConfig
option is very useful, but it seems to resolve using __dirname
and not the cwd
option for the extends
config property. This problematic as I need to take a user-supplied array of configs to extend and pass them to baseConfig.extends
, but they wouldn’t be resolved correctly, as I need to resolve from process.cwd()
, not __dirname
. So I first need to resolve them to absolute paths. I currently do that using a naive and buggy implementation. It would be very helpful if I could use the same machinery as ESLint uses internally.
I’m thinking:
eslint.CLIEngine.resolveConfigPath(name, [cwd]);
With cwd
being process.cwd()
by default.
ESLint 3.7.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (9 by maintainers)
Top GitHub Comments
I’ll see if I can find some time to look into this. If anyone else can get to it first, please feel free!
Sorry about the delay. I’ve edited the original issue text to make it clearer. Let me know if there’s anything else I need to clarify.