Skip to content

Make the CLIEngine cwd option available to rules #11218

@haoqunjiang

Description

@haoqunjiang

The version of ESLint you are using.
v5.10.0

The problem you want to solve.
Similar to this one #3974
It was recommended to simply use process.cwd() at that time.
And eslint-plugin-import followed this recommendation. import-js/eslint-plugin-import#602

But later cwd option was introduced to CLIEngine, so there may be an misalignment between it and process.cwd(), which causes confusion when invoking ESLint with Node.js API.

Your take on the correct solution to problem.

Rules' context should have a .getCwd() method which returns CLIEngine#cwd by default and fallbacks to process.cwd().

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionauto closedThe bot closed this issuecoreRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLintevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionneeds designImportant details about this change need to be discussed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions