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.

.prettier.yaml Config File Not Detected At Project Level - User Settings Being Applied Instead

See original GitHub issue

When reporting an issue, please include the following information in your post:

  • Explain the Issue and Expected Behavior
  • Prettier version
  • JsPrettier Plug-in Version
  • Platform Details
  • Generated Prettier command line arguments
  • Is the same behavior observed when run against Prettier directly?
  • The contents of your User/JsPrettier.sublime-settings file
  • The contents of your <project_name>.sublime-project file (if applicable)
  • Steps to reproduce the behavior

Explain the Issue and Expected Behavior

When I have a .prettier.yaml file in my project’s root level it is not being detected on save settings.

What happens is that my default settings from my JsPrettier.sublime-settings is applied instead.

image

Prettier version

To show the currently installed prettier version, run the following command:

$ prettier --version
2.1.2

JsPrettier Plug-in Version

{
  "name": "sublime-js-prettier",
  "version": "1.34.1",
  "description": "JsPrettier is a Sublime Text Plug-in for Prettier, the opinionated code formatter.",
  "author": "Jon LaBelle",
  "license": "MIT",
  "dependencies": {
    "prettier": "latest"
  },
  "repository": "jonlabelle/SublimeJsPrettier",
  "keywords": [
    "sublime",
    "sublimetext",
    "plugin",
    "prettier",
    "jsprettier",
    "formatter",
    "javascript",
    "css"
  ],
  "files": [
    "*.md",
    ".no-sublime-package",
    "Context.sublime-menu",
    "JsPrettier.py",
    "JsPrettier.sublime-commands",
    "jsprettier/**",
    "Main.sublime-menu",
    "messages.json",
    "messages/*.txt"
  ],
  "bugs": {
    "url": "https://github.com/jonlabelle/SublimeJsPrettier/issues"
  },
  "homepage": "https://github.com/jonlabelle/SublimeJsPrettier"
}

Platform Details

Sublime Text Version: 3.2.2 Sublime Text Build: 3211 OS: OSX OS Version: Catalina 10.15.7 OS Architecture: Unknown

Generated Prettier command line arguments

-----------------------------------------
 JsPrettier DEBUG - Prettier CLI Command 
-----------------------------------------

/Users/lknecht/.nvm/versions/node/v12.17.0/bin/prettier --no-config --print-width 120 --tab-width 4 --single-quote false --trailing-comma none --bracket-spacing true --jsx-bracket-same-line false --parser babel --semi true --require-pragma false --prose-wrap preserve --arrow-parens always --html-whitespace-sensitivity css --quote-props as-needed --vue-indent-script-and-style false --embedded-language-formatting auto --jsx-single-quote false --use-tabs false --stdin-filepath /Users/lknecht/Repositories/project-api/test/unit/testruns_controller.test.js --loglevel debug --cursor-offset 10603

Prettier reported the following output:

[debug] normalized argv: {"_":[],"bracket-spacing":true,"color":true,"editorconfig":true,"jsx-bracket-same-line":false,"jsx-single-quote":false,"require-pragma":false,"semi":true,"single-quote":false,"use-tabs":false,"vue-indent-script-and-style":false,"config":false,"print-width":120,"tab-width":4,"trailing-comma":"none","parser":"babel","prose-wrap":"preserve","arrow-parens":"always","html-whitespace-sensitivity":"css","quote-props":"as-needed","embedded-language-formatting":"auto","stdin-filepath":"/Users/lknecht/Repositories/project-api/test/unit/testruns_controller.test.js","loglevel":"debug","cursor-offset":10603,"config-precedence":"cli-override","debug-repeat":0,"ignore-path":".prettierignore","plugin":[],"plugin-search-dir":[]}
[debug] '--no-config' option found, skip loading config file.
[debug] applied config-precedence (cli-override): {"filepath":"/Users/lknecht/Repositories/project-api/test/unit/testruns_controller.test.js","arrowParens":"always","bracketSpacing":true,"cursorOffset":10603,"embeddedLanguageFormatting":"auto","htmlWhitespaceSensitivity":"css","jsxBracketSameLine":false,"jsxSingleQuote":false,"parser":"babel","printWidth":120,"proseWrap":"preserve","quoteProps":"as-needed","requirePragma":false,"semi":true,"singleQuote":false,"tabWidth":4,"trailingComma":"none","useTabs":false,"vueIndentScriptAndStyle":false}

Is the same behavior observed when run against Prettier directly?

Unknown

The contents of your User/JsPrettier.sublime-settings file

{
    "debug": "true",
    "prettier_cli_path": "/Users/lknecht/.nvm/versions/node/v12.17.0/bin/prettier",
    "auto_format_on_save": true,
    "custom_file_extensions": ["sublime-keymap", "sublime-settings", "yaml"],
    "prettier_options": {
        "printWidth": 120,
        "tabWidth": 4,
        "trailingComma": "none"
    }
}

The contents of your <project_name>.sublime-project file (if applicable)

N/A

Steps to reproduce the behavior

  1. Make Project
  2. Add .prettierrc.yaml
  3. Add Configurations
  4. Save

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
klchoicommented, Nov 22, 2020

@loganknecht have you try restart ST? For me, after checkout the debug message, I find that --no-config param was passed to prettier. I guess it happen because I created .prettierrc after I ran prettier. Restart ST fix that issue for me.

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

This issue has been automatically locked due to inactivity. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration File - Prettier
The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a...
Read more >
Prettier vscode extension ignoring config files - Stack Overflow
It seems that the VSCode prettier extension uses the config file in the VSCode settings over the local one, even if that config...
Read more >
Location detection logic differs between .prettierignore and ...
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...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
You can configure JavaScript code auto-formatting with Prettier to work per-project. This allows you to get a consistent formatting without ...
Read more >
Settings | JetBrains Fleet Documentation
Workspace settings take precedence over user settings. For this reason, it is recommended to only use them for configuration that makes sense ...
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