Skip to content

resolveConfig(cwd) fails to find config file  #15879

@mbeckem

Description

@mbeckem

Environments:

  • Prettier Version: 3.1.1
  • Running Prettier via: Node
  • Runtime: Node 18
  • Operating System: Linux
  • Prettier plugins (if any): None

Steps to reproduce:

  1. Open https://stackblitz.com/edit/node-37bnjb?file=test.js
  2. Run node ./test.js

Expected behavior:

The script prints the parsed contents of the .prettierrc inside that directory, since cwd is an explicitly supported input parameter (see https://prettier.io/docs/en/api.html#prettierresolveconfigfileurlorpath--options)

Actual behavior:

The script prints null.

Notes:

  • Downgrade prettier to version 2 by editing the package.json followed by running npm install.
    • node ./test.js will print the expected output
  • The resolveConfig function in prettier v3 appears to start its search in dirname(cwd) instead of cwd, thus never testing for the existence of .prettierrc in the project directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:docsIssues about adding or improving documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions