Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cwd in the top-level CLI #14731

Closed
RainNapper opened this issue Jun 21, 2021 · 5 comments
Closed

Support cwd in the top-level CLI #14731

RainNapper opened this issue Jun 21, 2021 · 5 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion Stale
Projects

Comments

@RainNapper
Copy link

RainNapper commented Jun 21, 2021

The version of ESLint you are using.
7.29.0

The problem you want to solve.
I am working on using eslint as part of an arcanist lint flow. Arcanist runs linters via CLI and translates the output to its own format.

Running eslint via npm requires a specific task to be defined, so we opt to run eslint directly via $repo/node_modules/.bin/eslint, found from utilities like yarn bin

The eslint binary does not accept a --cwd flag, even though the CLIEngine does..

Specifically I am running into an issue with resolving a custom formatter when running outside of the node project directory.

Your take on the correct solution to problem.
Add a CLI flag --cwd which simply forwards that option into CLIEngine.

An example command:

$repo/some-subdir/node_modules/bin/eslint --cwd $repo/some-subdir/ --config '.eslintrc' /$repo/some-subdir/src/index.js

Are you willing to submit a pull request to implement this change?
Yes

@RainNapper RainNapper added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Jun 21, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Jun 21, 2021
@aladdin-add
Copy link
Member

aladdin-add commented Jun 22, 2021

just a reminder: CLIEngine has been deprecated, and can no longer be used in the new coming eslint v8.0. see: #13654

@aladdin-add aladdin-add moved this from Needs Triage to Evaluating in Triage Jun 22, 2021
@aladdin-add aladdin-add added cli Relates to ESLint's command-line interface evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 22, 2021
@btmills
Copy link
Member

btmills commented Jun 28, 2021

The ESLint constructor also supports a cwd option, so I’m not opposed to passing it through the CLI.

In the meantime, you may be able to get this working by passing a path as the --format argument instead of the module name. Here’s the method that loads the formatter, for reference:

getFormatter(format) {

@lishichao1002
Copy link

I use cwd option in mono repo project

@github-actions
Copy link

Oops! It looks like we lost track of this issue. @eslint/eslint-tsc what do we want to do here? This issue will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Oct 15, 2021
Triage automation moved this from Evaluating to Complete Oct 22, 2021
@dietergeerts
Copy link

dietergeerts commented Oct 26, 2021

@lishichao1002 , how can a cwd option be used? I'm adding a linting package to a mono-repo to check all package, and I can't seem to get it to work.

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Apr 21, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion Stale
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

5 participants