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

prettier.ignorePath setting is not respected #67

Open
kas opened this issue Jun 7, 2020 · 2 comments
Open

prettier.ignorePath setting is not respected #67

kas opened this issue Jun 7, 2020 · 2 comments

Comments

@kas
Copy link

kas commented Jun 7, 2020

Content of coc-settings.json file:

{
  "coc.preferences.formatOnSaveFiletypes": ["*"]
}

or

{
  "coc.preferences.formatOnSaveFiletypes": ["*"],
  "prettier.ignorePath": "./.prettierignore"
}

Repository folder structure:

repository-folder/
--.prettierignore
--subfolder/
----.prettierignore
----index.html

Content of repository-folder/.prettierignore file:

subfolder/

Content of repository-folder/subfolder/.prettierignore file:

(empty)

Repro steps:

  1. Run vim repository-folder/subfolder/index.html
  2. Modify the index.html to make Prettier attempt to format the file when the file is saved
  3. Save the file

Expected:
4. Prettier formats index.html

Actual:
4. Prettier does not format index.html

Issue:
The Readme.md file describes:

prettier.ignorePath (default: .prettierignore)

Supply the path to an ignore file such as .gitignore or .prettierignore.
Files which match will not be formatted. Set to null to not read ignore files. Restart required.

Setting the "prettier.ignorePath" setting to ".prettierignore" (default) or "./.prettierignore" should make Prettier use the .prettierignore file in the same directory as the file that is open.

Visual Studio Code does not have this issue when opening the subfolder folder.

@kas kas changed the title prettier.ignorePath is not respected Prettier.ignorePath setting is not respected Jun 7, 2020
@kas
Copy link
Author

kas commented Jun 7, 2020

I'm only using the .prettierignore file in the repository-folder to make Prettier ignore the subfolder folders of my project. The goal is that using Prettier in the repository-folder folder will only run Prettier on files in that folder, and not subfolders. If anyone else is running into this issue, a mitigation is to modify the Prettier script in your package.json file:

{
  ...
  "scripts": {
    "prettier": "prettier --write . \"!subfolder-1/**\" \"!subfolder-2/**\" \"!subfolder-3/**\"",
  },
  ...
}

@kas kas changed the title Prettier.ignorePath setting is not respected prettier.ignorePath setting is not respected Jun 7, 2020
@el-og
Copy link

el-og commented Jun 9, 2022

Content of coc-settings.json file:

{
  "coc.preferences.formatOnSaveFiletypes": ["*"]
}

or

{
  "coc.preferences.formatOnSaveFiletypes": ["*"],
  "prettier.ignorePath": "./.prettierignore"
}

Repository folder structure:

repository-folder/
--.prettierignore
--subfolder/
----.prettierignore
----index.html

Content of repository-folder/.prettierignore file:

subfolder/

Content of repository-folder/subfolder/.prettierignore file:

(empty)

Repro steps:

  1. Run vim repository-folder/subfolder/index.html
  2. Modify the index.html to make Prettier attempt to format the file when the file is saved
  3. Save the file

Expected: 4. Prettier formats index.html

Actual: 4. Prettier does not format index.html

Issue: The Readme.md file describes:

prettier.ignorePath (default: .prettierignore)

Supply the path to an ignore file such as .gitignore or .prettierignore.
Files which match will not be formatted. Set to null to not read ignore files. Restart required.

Setting the "prettier.ignorePath" setting to ".prettierignore" (default) or "./.prettierignore" should make Prettier use the .prettierignore file in the same directory as the file that is open.

Visual Studio Code does not have this issue when opening the subfolder folder.

if you are still having an issue drop log of :CocCommand prettier.openOutput, because I have been having this issue myself just to realise that I have been using prettier.forceFormatDocument on my binding, rather than just prettier.formatFile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants