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.

CLI --config setting not working (prettier-eslint)

See original GitHub issue

Reporting an 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

I’m currently using prettier-eslint and had trouble configuring it to work correctly. (It would be great if this plugin supported that as an option or had directions in the documentation.)

First, I updated the prettier_cli_path to point to prettier-eslint and confirmed that was working correctly. I have an .eslintrc file in the project folder and I set prettier_cli_path to the full path of prettier-eslint and addtional_cli_args with a blank --config option, as #35 #84 suggested.

However, when I formatted a file, I noticed it was breaking lines more than it should (as if printWidth was set lower than my 120). I debugged it step-by-step and found that the issue is that without a .prettierrc file in the project path the JsPrettier settings are being used with --no-config, regardless if additional_cli_args is defined with a --config setting. It seems --config is appended to the end rather than taking over (for --no-config and JsPrettier’s cli settings), which means the documentation using --config as an option is misleading.

I can see this being an issue beyond my use case if people choose to define their config with additional_cli_args according to the documention. I would assume you shouldn’t have to have a .prettierrc file to use additional_cli_args’s --config.

Prettier version

1.12.0

JsPrettier Plug-in Version

1.20.17

Platform Details

I’m on Windows 10 with Sublime Text version 3.0, build 3143.

Generated Prettier command line arguments

Without .prettierrc file (file paths removed):

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

<CLI_PATH>/prettier-eslint 
--stdin 
--no-config 
--print-width 80 
--single-quote false 
--trailing-comma none 
--bracket-spacing true 
--jsx-bracket-same-line false 
--parser babylon 
--semi true 
--require-pragma false 
--prose-wrap preserve 
--arrow-parens avoid 
--tab-width 2 
--use-tabs false 
--stdin-filepath <PATH>\file.js 
--ignore-path <PATH>\.prettierignore 
--config
Prettier reported the following error(s):

Warning: `proseWrap` with boolean value is deprecated. Use "always", "never", or "preserve" instead.
● Validation Warning:

  Unknown option "ignorePath" with value "...\\.prettierignore" was found.
  This is probably a typing mistake. Fixing it will remove this message.

With blank .prettierrc file (file paths removed):

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

<CLI_PATH>/prettier-eslint 
--stdin 
--tab-width 2 
--use-tabs false 
--stdin-filepath <PATH>file.js 
--ignore-path <PATH>\.prettierignore 
--config
Prettier reported the following error(s):

● Validation Warning:

  Unknown option "configPrecedence" with value "cli-override" was found.
  This is probably a typing mistake. Fixing it will remove this message.

● Validation Warning:

  Unknown option "ignorePath" with value "...\\.prettierignore" was found.
  This is probably a typing mistake. Fixing it will remove this message.

Is the same behavior observed when run against Prettier directly?

N/A

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

Full path removed.

{
  "debug": true,
  "prettier_cli_path": "<CLI_PATH>/prettier-eslint",
  "additional_cli_args": {
    "--config": ""
  },
  "allow_inline_formatting": true
}

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

N/A

Steps to reproduce the behavior

The steps one would take to reproduce and observe the problem.

  1. Set up JsPrettier with additional_cli_settings with --config defined as blank "". You can also point it at a config file with a custom name or outside the project path.
  2. In a project folder with .eslintrc, format a file. Debug will show “no config used” and the JsPrettier cli options.
  3. Add a valid .prettierrc file (mine is empty) to the project folder.
  4. Format the file again. Debug will show “config resolved” without the JsPrettier options.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jonlabellecommented, Apr 24, 2018

Thanks @CaitlinWeb. I’ll have a look.

0reactions
lock[bot]commented, Aug 1, 2019

This thread 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

Prettier doesn't format based on my eslint config - Stack Overflow
1 Answer 1 · Install eslint: npm i --save-dev eslint · Init eslint: npx eslint --init. For some options you need choose next:...
Read more >
CLI - Prettier
Use the prettier command to run Prettier from the command line. To run your locally installed version of Prettier, prefix the command with...
Read more >
prettier-eslint-cli - npm
CLI for prettier-eslint. Latest version: 7.1.0, last published: 4 months ago. Start using prettier-eslint-cli in your project by running ...
Read more >
Using Prettier and ESLint to automate formatting and fixing ...
While a big reason to use Prettier is to avoid configuration ... However, ESLint enables developers to discover problems with their code ...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
VSCode + ESLint + Prettier setup. Let's configure VSCode to use ESLint to auto-fix found issues, including Prettier. The workspace settings use ...
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