question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLIEngine API to resolve config name to absolute path

See original GitHub issue

Edit 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:closed
  • Created 7 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jan 10, 2017

I’ll see if I can find some time to look into this. If anyone else can get to it first, please feel free!

1reaction
sindresorhuscommented, Nov 2, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

There was trouble creating the ESLint CLIEngine
A current UNIX workaround: use $PWD , i.e. $ npx prettier-eslint $PWD/'**/*.js'. This produced correct files as output.
Read more >
How to format ESLint output. Playing with CLIEngine API
Let's create our own module that will act like normal ESLint but will be able to format the output. npm init{ "name": "formatted-linting",...
Read more >
Node.js API - ESLint - Pluggable JavaScript Linter
It resolves the parser setting to absolute paths. It normalizes the plugins setting to align short names. (e.g., eslint-plugin-foo → foo ); It...
Read more >
How to use the eslint.CLIEngine function in eslint - Snyk
CLIEngine (); let eslintConfig; try { eslintConfig = eslintCli.getConfigForFile(paths.appIndexJs); } catch (e) { // A config couldn't be found. } // We allow ......
Read more >
Node.js API - ESLint - Pluggable JavaScript ... - GitHub Pages
The purpose of the Node.js API is to allow plugin and tool authors to use the ... settings from CLIEngine to resolve non-glob...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found