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.

Location detection logic differs between .prettierignore and .prettierrc

See original GitHub issue

Summary

I have one directory where I put all my Git projects. Let’s say it’s called workspace. I open this in VS Code using File > Open Folder. Then any repo I git clone into that folder automatically gets added to my VS Code workspace.

Whenever I use this plugin, it appropriately finds the .prettierrc in the folder of the specific git repo. So if the git repo is named prettier-test:

Using config file at '/home/user/workspace/prettier-test/.prettierrc'

However it only looks for .prettierignore at the root level of the entire VS Code workspace:

Using ignore file (if present) at /home/user/workspace/.prettierignore

So any .prettierignore files in my Git repos are completely ignored.

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.requireConfig": true,

Expected result

I would’ve expected .prettierignore in /home/user/workspace/prettier-test/ to be used, as this seems to be the behaviour for .prettierrc

Actual result

The plugin looked for .prettierignore in /home/user/workspace/ which seems to be inconsistent behaviour

Additional information

VS Code Version: 1.51.1

Prettier Extension Version: 5.8.0

OS and version: Ubuntu 20.04

Prettier Log Output

["INFO" - 3:38:58 p.m.] Formatting /home/user/workspace/prettier-test/test.yaml
["INFO" - 3:38:58 p.m.] Using ignore file (if present) at /home/user/workspace/.prettierignore
["INFO" - 3:38:58 p.m.] Using bundled version of prettier.
["INFO" - 3:38:58 p.m.] File Info:
{
  "ignored": false,
  "inferredParser": "yaml"
}
["INFO" - 3:38:58 p.m.] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 3:38:58 p.m.] Using config file at '/home/user/workspace/prettier-test/.prettierrc'
["INFO" - 3:38:58 p.m.] Prettier Options:
{
  "filepath": "/home/user/workspace/prettier-test/test.yaml",
  "parser": "yaml"
}
["INFO" - 3:38:58 p.m.] Formatting completed in 19.610672ms.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bmaupincommented, Jan 5, 2021

I originally didn’t create a git repo since it doesn’t fully replicate my situation. But it seems whether a particular directory is a git repo seems to bet seems to be irrelevant in this case so I went ahead and created a test repo here: https://github.com/bmaupin/prettier-vscode-1694

So for this test:

  • prettier-vscode-1694 (this would mimic the parent directory on my workstation, which is not a git repo)
    • project1 (on my workstation this would be a Git repo in a subdirectory)
    • project2 (on my workstation this would be a Git repo in a subdirectory)

Steps to reproduce:

  1. git clone https://github.com/bmaupin/prettier-vscode-1694.git

  2. In vscode, go to File > Open Folder and browse to prettier-vscode-1694

  3. Open project1/test.yaml

  4. Save the file and observe that the single quotes are changed to double quotes

  5. Open the prettier log and observe that inconsistent logic is used in determining the location of .prettierignore vs .prettierrc:

    Using ignore file (if present) at /home/user/Desktop/prettier-vscode-1694/.prettierignore
    Using config file at '/home/user/Desktop/prettier-vscode-1694/project1/.prettierrc'
    

The same behaviour can also be observed if the folder is added to the current workspace using File > Add Folder to Workspace

0reactions
github-actions[bot]commented, Oct 25, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Location detection logic differs between ... - Bountysource
I have one directory where I put all my Git projects. Let's say it's called workspace . I open this in VS Code...
Read more >
Configuration File - Prettier
cjs file that exports an object using module.exports . A .prettierrc.toml file. The configuration file will be resolved starting from the location of...
Read more >
vscode prettier ignore not working - You.com | The AI Search ...
I have a ignore rule in a .prettierignore (located at the root workspace too) which ... Detected local configuration (i.e. .prettierrc or .editorconfig), ......
Read more >
How to Build Scalable Architecture for your Next.js Project
All code from this tutorial as a complete package is available in this repository. If you find this... Tagged with nextjs, webdev, ...
Read more >
Relay
The simplest way to fetch query data is to directly call loadQuery . Later, you can read the data from the store in...
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