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

How to add brace-style rules to prettier? #26

Closed
psyanite opened this issue Aug 20, 2017 · 10 comments
Closed

How to add brace-style rules to prettier? #26

psyanite opened this issue Aug 20, 2017 · 10 comments

Comments

@psyanite
Copy link

psyanite commented Aug 20, 2017

So I want to use stroustrup for my brace-style, I updated my .eslintrc file as per below but prettier keeps complaining and I can only suppress the prettier/prettier rule in WebStorm.

  rules: {

    ...

    'brace-style': [
      'error',
      'stroustrup',
      {
        'allowSingleLine': true
      }
    ],

    'prettier/prettier': [
      'error',
      {
        singleQuote: true,
        trailingComma: 'all',
      },
    ],
  },

It keeps complaining about this:

  if (isMeow()) {
    meow();
  }
  else {
    bork();
  }

Thanks for reading my question 👍

🍰

@lydell
Copy link
Member

lydell commented Aug 20, 2017

There are two ways of using Prettier and ESLint at the same time:

  1. Let Prettier handle the formatting of your code, and turn off all stylistic rules in ESLint (because they mostly conflict with Prettier, like in your case). eslint-config-prettier helps doing this.

  2. Use prettier-eslint. This runs Prettier first, and then eslint --fix. This is if you disagree with some code formatting choice that Prettier has made, and want ESLint to automatically adjust that.

It looks like you are currently using method 1, but actually want method 2. So try out prettier-eslint!

@lydell lydell closed this as completed Aug 20, 2017
@psyanite
Copy link
Author

psyanite commented Aug 20, 2017

@lydell Thanks for taking the time and effort to respond to my question. I really appreciate it. Things are much more clear from your explanation now thank you so much.

🍰

@cybermerlin
Copy link

cybermerlin commented Oct 1, 2020

still doesn't work
image

.prettierrc
"breakBeforeElse": true

.eslintrc.js

    'brace-style': [
      'error',
      'stroustrup',
      {
        'allowSingleLine': true
      }
    ],

@romerobrjp
Copy link

The same problem still occurs here, even with the suggested configurations...

Any further ideas of how to solve this issue?

image
image
image

@ItsCubeTime
Copy link

ItsCubeTime commented Jul 3, 2022

Could we see this being added? What solution do other people use for this? Would like to have simple allman case formatting in CSS & Javascript

@JounQin
Copy link
Member

JounQin commented Jul 3, 2022

This is no such option for prettier at all.

prettier/prettier#840

@ocsoares
Copy link

any solution?

@ony3000
Copy link

ony3000 commented Jun 19, 2023

Hello everyone!

Today I released a prettier plugin, maybe this will help.

@dockleryxk
Copy link

@ony3000 I was about to write my own plugin, how convenient

@xNevrroXx
Copy link

Hello everyone!

Today I released a prettier plugin, maybe this will help.

Thanks a lot)

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

10 participants