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

Extension doesn't ignore formatting for gitignored files #3063

Open
SuperchupuDev opened this issue Jul 6, 2023 · 13 comments
Open

Extension doesn't ignore formatting for gitignored files #3063

SuperchupuDev opened this issue Jul 6, 2023 · 13 comments
Labels

Comments

@SuperchupuDev
Copy link

Summary

prettier 3.0 introduced ignoring gitignored files by default, however the vscode extension doesn't ignore them, unlike .prettierignored files. Using the prettier cli to format works fine

Github Repository to Reproduce Issue

https://github.com/h-projects/gasbot/tree/59d05a8df6a72a92a84fd0273e29c23e191eb2e7 (.prettierignore file is still in there)

Steps To Reproduce:

  1. Have a .prettierignore file and a .gitignore file, both with the same contents
  2. Enable formatting on save (with the extension) in vscode
  3. Try to modify and save a file mentioned in .prettierignore (it doesn't get formatted, good)
  4. Delete the .prettierignore file
  5. Try to save the same file

Expected result

The file doesn't get formatted, just like if .prettierignore was present

Actual result

The file gets formatted

Additional information

VS Code Version:
1.79.2

Prettier Extension Version:
9.19.0

OS and version:
Windows 10 22H2, prettier 3.0.0

Prettier Log Output

Before removing `.prettierignore`
["INFO" - 12:36:11 PM] Formatting file:///c%3A/Users/Superchupu/OneDrive/Documentos/Programaci%C3%B3n/discordbot/gasbot/dist/index.js
["INFO" - 12:36:11 PM] Using config file at 'c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierrc.json'
["INFO" - 12:36:11 PM] PrettierInstance:
{
  "modulePath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\node_modules\\prettier\\index.cjs",
  "importResolver": {},
  "callMethodResolvers": {},
  "currentCallMethodId": 48,
  "version": "3.0.0"
}
["INFO" - 12:36:11 PM] Using ignore file (if present) at c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierignore
["INFO" - 12:36:11 PM] File Info:
{
  "ignored": true,
  "inferredParser": null
}
["INFO" - 12:36:11 PM] File is ignored, skipping.
After removing the `.prettierignore` file, but still having the affected file gitignored
["INFO" - 12:32:52 PM] Formatting file:///c%3A/Users/Superchupu/OneDrive/Documentos/Programaci%C3%B3n/discordbot/gasbot/dist/index.js
["INFO" - 12:32:52 PM] Using config file at 'c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierrc.json'
["INFO" - 12:32:52 PM] PrettierInstance:
{
  "modulePath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\node_modules\\prettier\\index.cjs",
  "importResolver": {},
  "callMethodResolvers": {},
  "currentCallMethodId": 41,
  "version": "3.0.0"
}
["INFO" - 12:32:52 PM] Using ignore file (if present) at c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierignore
["INFO" - 12:32:52 PM] File Info:
{
  "ignored": false,
  "inferredParser": "babel"
}
["INFO" - 12:32:52 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 12:32:52 PM] Prettier Options:
{
  "filepath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\dist\\index.js",
  "parser": "babel",
  "arrowParens": "avoid",
  "endOfLine": "auto",
  "printWidth": 120,
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "none"
}
["INFO" - 12:32:52 PM] Formatting completed in 13ms.
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Sep 5, 2023
@niklasholm
Copy link

This is still an issue. The extension should be consistent with the prettier cli.

@github-actions github-actions bot removed the Stale label Sep 6, 2023
@jordanbtucker
Copy link

This is a bigger task than it seems. This extension relies on the Prettier API, but since there were issues integrating with Prettier v3, they had to revert back to Prettier v2. This won't be fixed until Prettier v3 is supported again.

Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Nov 16, 2023
@SuperchupuDev
Copy link
Author

keeping the issue open

@github-actions github-actions bot removed the Stale label Nov 17, 2023
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Jan 16, 2024
@kachkaev
Copy link
Member

not stale

@github-actions github-actions bot removed the Stale label Jan 17, 2024
@SamuelBrucksch
Copy link

i also have the same issue

@ntotten ntotten added the bug label Feb 28, 2024
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Apr 29, 2024
@Den-dp
Copy link

Den-dp commented May 1, 2024

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

still relevant to me

@github-actions github-actions bot removed the Stale label May 2, 2024
@ssbarnea
Copy link

ssbarnea commented May 6, 2024

In my case .prettierignore is a symlink pointing to .gitignore file inside the same directory and based on the errors I seen logged, I suspect that it might not be properly loaded as these filenames are supposed to be ignored.

2024-04-30 12:42:41.822 [error] Error: ENOENT: no such file or directory, stat '/Users/ssbarnea/c/a/ansible-lint/examples/roles/name_prefix/tasks/test.tmp.yml'
	at statSync (node:fs:1692:3)
	at t.statSync (node:electron/js2c/node_init:2:5052)
	at n.statSync (/Users/ssbarnea/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:3435)
	at o.value (/Users/ssbarnea/.vscode/extensions/redhat.ansible-24.4.1783911/out/client/src/extension.js:2:428454)
	at s.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
	at s.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:876)
Copy link

github-actions bot commented Jul 6, 2024

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Jul 6, 2024
@Den-dp
Copy link

Den-dp commented Jul 6, 2024

It looks like for now, we have only 2 options:

  • keep in sync .gitignore and .prettierignore
  • downgrade extension to v10.0.0 (since this is the only version of the prettier-vscode that uses prettier@3 API required to ignore gitignored files)
@github-actions github-actions bot removed the Stale label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8 participants