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

indent size is 2 instead of 4 - Failed to resolve config - No local configuration detected #1082

Closed
wassim-azirar opened this issue Nov 20, 2019 · 6 comments
Labels
bug locked Please open a new issue and fill out the template instead of commenting.

Comments

@wassim-azirar
Copy link

wassim-azirar commented Nov 20, 2019

Summary

My .prettierrc file is not used to format my files.

Expected result

I expect the file to be formatted with 4 spaces

Actual result

The file gets formatted with 2 spaces

Screenshot

image

VS Code Version: 1.40.1

Prettier & Prettier Plugin Version:
"prettier": "^1.19.1"
"prettier plugin": [3.8.0]

OS and version:
Windows 10 Pro

.editorconfig

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

.prettierrc

{
    "bracketSpacing": true,
    "bracesSpacing": true,
    "jsxBracketSameLine": true,
    "jsxSingleQuote": true,
    "noSemi": true,
    "printWidth": 120,
    "singleQuote": true,
    "tabWidth": 4,
    "trailingComma": "none",
    "useTabs": false
}

.prettierignore

.vscode/*
package.json
yarn.lock

I tried to delete the .prettierignore file, but I keep seeing this log :

Resolved ignore file to c:\repos\project\.prettierignore

I restared VSCode many times, and everytime I use the format commande I see this message. 😠

settings.json

{
  "editor.tabSize": 4,
  "editor.detectIndentation": false,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

Prettier Log Output

[INFO - 3:14:35 PM] Formatting c:\repos\project\Components\Order.jsx.
[INFO - 3:14:35 PM] Loaded module 'prettier@1.19.1' from 'c:\repos\project\node_modules\prettier\index.js'.
[INFO - 3:14:35 PM] Resolved ignore file to c:\repos\project\.prettierignore.
[INFO - 3:14:35 PM] File Info:
{
  "ignored": false,
  "inferredParser": "babel"
}
[ERROR - 3:14:35 PM] Failed to resolve config for c:\repos\project\Components\Order.jsx. Falling back to the default config settings.
[INFO - 3:14:35 PM] No local configuration detected, using VS Code configuration.
[INFO - 3:14:35 PM] Prettier Options:
{
  "arrowParens": "avoid",
  "bracketSpacing": true,
  "endOfLine": "auto",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "none",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "filepath": "c:\\repos\\project\\Components\\Order.jsx",
  "parser": "babel"
}
[INFO - 3:14:35 PM] Formatting completed in 31.861999ms.
@ntotten
Copy link
Member

ntotten commented Nov 21, 2019

Resolved ignore file to c:\repos\project.prettierignore
This doesn't mean anything, it just means that is the location that it looks for the ignore file. If the file is not there, then it isn't used.

Is your .prettierrc file located at c:\repos\project\.prettierrc? What about your .editorconfig, where is that located?

This extension uses prettier to resolve configuration files which is:

"The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found."

It sounds like your configuration files are not in the same tree as the file being formatted so they wouldnt be discovered.

@wassim-azirar
Copy link
Author

wassim-azirar commented Nov 26, 2019

@ntotten my .prettierrc is located at the root folder c:\repos\project\
I also tried to move .prettierrc at the same level of my components c:\repos\project\Components\

But I still get that error Failed to resolve config for c:\repos\project\Components\Order.jsx. Falling back to the default config settings.

To be sure that EditorConfig is not causing any conflicts. I removed .editorconfig from my root folder but It still doesn't work.

EDIT 1:
I have the same problem with VSCode Insider v1.41.0 with only Prettier extension installed

EDIT 2:
I have created a sample repo https://github.com/wassim-azirar/prettier-problem

EDIT 3:
With WebStorm everything works fine. I get my 4 spaces instead of 2.

@anvinjain
Copy link

anvinjain commented Nov 26, 2019

Seeing the same problem as @wassim-azirar
I have .prettierrc.yaml in repository root but settings inside that are not being respected when vs code runs prettier.

VS Code

Version: 1.40.1
Commit: 8795a9889db74563ddd43eb0a897a2384129a619
Date: 2019-11-13T16:47:44.719Z
Electron: 6.1.2
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 18.6.0

Prettier Extension 3.9.0

wassim-azirar pushed a commit to wassim-azirar/prettier-problem that referenced this issue Nov 26, 2019
@ntotten
Copy link
Member

ntotten commented Nov 27, 2019

I think I have somewhat figured out what is going on here. It appears to be a text encoding issue with the .prettierrc file. I added some additional logging in v3.11.0 (just released). When using the provided repo I noticed the following error:

image

The immediate fix is to change the encoding of the .prettierrc file to utf8. I will try to see if there is a better fix later, but this should unblock you at the moment.

@ntotten
Copy link
Member

ntotten commented Dec 14, 2019

Closing as this issue seems to be resolved.

@ntotten ntotten closed this as completed Dec 14, 2019
@github-actions
Copy link

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.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants