Solution:

In order to allow single-line blocks in VSCode using Prettier - Code formatter extension, please take the following steps:

  1. Enable stylelint integration by adding this in the VSCode Settings (JSON): "prettier.stylelintIntegration": true
  2. Install stylelint and stylelint-prettier npm modules in your project directory. npm install stylelint stylelint-prettier --save-dev
  3. Add a .stylelintrc.json file at the root of your project directory with the following code:
    {
        "plugins": ["stylelint-prettier"],
        "rules": {
            "block-closing-brace-newline-after": "always-multi-line",
            "block-closing-brace-empty-line-before": "never",
            "block-closing-brace-space-before": "always",
            "block-opening-brace-space-after": "always",
            "block-opening-brace-space-before": "always",
            "block-closing-brace-newline-before": "always-multi-line",
            "block-opening-brace-newline-after": "always-multi-line",
            "indentation": 4
        }
    }

You can add/customize more stylelint rules, see the entire list of rules here.

Took me a while to understand how to configure these options, if you're starting out with stylelint, I highly recommend you read its guidelines first.

Answer from Arslan Akram on Stack Overflow
🌐
GitHub
github.com › prettier › stylelint-config-prettier-scss
GitHub - prettier/stylelint-config-prettier-scss: Turns off all CSS and SCSS rules that are unnecessary or might conflict with prettier.
Turns off all CSS and SCSS rules that are unnecessary or might conflict with prettier. - prettier/stylelint-config-prettier-scss
Starred by 25 users
Forked by 3 users
Languages   JavaScript 98.1% | SCSS 1.9% | JavaScript 98.1% | SCSS 1.9%
🌐
npm
npmjs.com › package › stylelint-config-prettier-scss
stylelint-config-prettier-scss - npm
Turns off all SCSS rules that are unnecessary or might conflict with Prettier.. Latest version: 1.0.0, last published: 3 years ago. Start using stylelint-config-prettier-scss in your project by running `npm i stylelint-config-prettier-scss`. ...
      » npm install stylelint-config-prettier-scss
    
Published   May 11, 2023
Version   1.0.0
Author   Shannon Moeller
🌐
Prettier
prettier.io › docs › configuration
Configuration File · Prettier
Here’s an annotated description of how different properties map to Prettier’s behavior: # Stop the editor from looking for .editorconfig files in the parent directories # root = true [*] # Non-configurable Prettier behaviors charset = utf-8 insert_final_newline = true # Caveat: Prettier won’t trim trailing whitespace inside template strings, but your editor might.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
SCSS Formatter - Visual Studio Marketplace
Extension for Visual Studio Code - A Visual Studio Code Extension to format SCSS
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 117
Prettier doesn't format *.css and *.scss files. · Issue #117 · prettier/prettier-vscode
Here are my settings: "prettier.eslintIntegration": true, "prettier.singleQuote": true, "prettier.printWidth": 80, "prettier.trailingComma": "all", "prettier.cssEnable": [ "css", "less", "sass" ], But there is no "Format document" option...
Author   ghost
🌐
Prettier
prettier.io › blog › 2017 › 06 › 03 › 1.4.0.html
Prettier 1.4: TypeScript and CSS support · Prettier
June 3, 2017 - We are using postcss by @ai as the underlying parser which is able to parse CSS, Less and SCSS. We also depend on postcss-values-parser, postcss-selector-parser by @ben-eb postcss-media-query-parser by @dryoma. Unfortunately, postcss right now doesn't parse Sass nor Stylus. We'd be happy to support them if someone is willing to do the work of printing them. Note that prettier is currently just formatting the code, it does not respect any options yet such as singleQuote nor is doing any color or number normalization like we do for JavaScript.
🌐
JetBrains
jetbrains.com › help › webstorm › prettier.html
Prettier | WebStorm Documentation
With the default pattern, Prettier will wake up and process any updated and saved JavaScript, TypeScript, JSX, TSX, HTML, Vue, Astro, .ml, or CSS file. To reformat files of other types or files stored in specific folders, use glob patterns to update the default pattern. For example, to automatically reformat sass and .scss files as well, add sass, scss to the default pattern as follows:
Find elsewhere
🌐
GitHub
github.com › prettier › prettier-atom › issues › 291
Different config options for CSS vs JS · Issue #291 · prettier/prettier-atom
April 24, 2017 - I may be completely in the minority here (feel free to close this if I am), but I prefer different config options when using prettier for JS compared to CSS. Specifically, I prefer single quotes in JS, but double quotes in CSS. I would l...
Author   keithjgrant
🌐
GitHub
github.com › prettier › prettier › issues › 3202
SCSS configuration · Issue #3202 · prettier/prettier
September 3, 2017 - Hi folks, Prettier 1.8.1 Playground link # Options (if any): --parser scss --single-quote --tab-width 4 Input: $transparent: .8; .foo { opacity:$transparent; } $grid-breakpoints-unitless: ( // Extra small screen / phone xs: 0, // Small s...
Author   iGitScor
🌐
GitHub
github.com › prettier › stylelint-config-prettier-scss › blob › main › RELEASE.md
stylelint-config-prettier-scss/RELEASE.md at main · prettier/stylelint-config-prettier-scss
Turns off all CSS and SCSS rules that are unnecessary or might conflict with prettier. - prettier/stylelint-config-prettier-scss
Author   prettier
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
Try It OnlineInstall Prettier · Limited edition tshirts are now available to buy! $10 per tshirt goes to maintain the project. An opinionated code formatter · Supports many languages · Integrates with most editors · Has few options » · Your code is formatted on save · No need to discuss style in code review · Saves you time and energy · And more » · JavaScript · JSX · Flow · TypeScript · JSON · CSS · Less · SCSS ·
🌐
Reddit
reddit.com › r/vscode › prettier not formatting css
r/vscode on Reddit: Prettier not formatting css
September 24, 2024 -

Hey everyone, for the life of me I can't figure out why prettier won't format css. I have gone over all of my setting, format on save, setting prettier as the default format, and checked the setting.json file. Still can't figure out what is going on. Any help would be appreciated!

🌐
GitHub
github.com › prettier › prettier-vscode › issues › 851
Missing configuration file for scss · Issue #851 · prettier/prettier-vscode
April 7, 2019 - When I use the prettier-stylelint option, I have an ✖️next to prettier in the status bar and I get the following console message: No configuration provided for [path to file] This is the case regardless of whether its a css or an scss fi...
Author   pattiereaves
🌐
Mashup Garage
mashupgarage.com › playbook › tools › prettier.html
Prettier setup | Mashup Garage Playbook
This configuration roughly mimics the styling rules of Standard JS. { "semi": false, "singleQuote": true, "jsxSingleQuote": true } Add these scripts to package.json. Be sure to change the path globs. "scripts": { "prettier:check": "prettier --list-different 'styles/**/*.scss' 'scripts/**/*.{js,jsx,ts,tsx}'", "prettier:fix": "prettier --write 'styles/**/*.scss' 'scripts/**/*.{js,jsx,ts,tsx}'" } Add prettier:check to CI.
🌐
Stack Overflow
stackoverflow.com › questions › 51410503 › prettier-doesnt-work-for-css
format - Prettier doesn't work for CSS - Stack Overflow
I just implemented ESLint and Prettier in my project. Linting of JavaScript files works perfectly. However, for CSS files, things like adding missing semicolon don't work. Isn't it that Prettier sh...
🌐
CodeSandbox
codesandbox.io › examples › package › stylelint-config-prettier-scss
stylelint-config-prettier-scss examples - CodeSandbox
Use this online stylelint-config-prettier-scss playground to view and fork stylelint-config-prettier-scss example apps and templates on CodeSandbox.
🌐
GitHub
github.com › prettier › prettier › issues › 3012
CSS/SCSS indenting · Issue #3012 · prettier/prettier
September 9, 2017 - Would you be open to accepting a patch to indent CSS/SCSS blocks based on the previous selector? I think the formatting rule could be that if the previous selector is a prefix of the current selector then we consider that to be nesting and the block is nested a level. Any name that doesn't match would be formatted as Prettier currently does it (pushed left-most).
Author   holloway