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.

[Need help] Use Prettier 3 with stylelint

See original GitHub issue

Can someone show me how it works or how should I install it? To be honest, I donā€™t understand the documentation or I miss something. It drives me crazy šŸ™„

Steps that i did:

  1. Installed VSCode
  2. Installed Prettier Vs Code plugin
  3. Opened simply project with couple files (html, css)
  4. Installed stylelint with npm install --save-dev stylelint
  5. Installed stylelint-prettier with npm install --save-dev stylelint-prettier prettier
  6. Created .stylelintrc with content:
{
  "plugins": ["stylelint-prettier"],
  "rules": {
    "prettier/prettier": true,
	"comment-empty-line-before": "always",
  }
}   

And what now? Prettier in VSCode didnā€™t fix anything in css files Or maybe I do it completely wrong? I donā€™t understand this

Sorry, i know, itā€™s repository, not a help page, but please help me if you can

Iā€™m working on Windows 10 machine

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
joemallercommented, Dec 3, 2019

For the sake of sanity and memorializing hours lost to this, some confusion about this is justified.

Additionally, like prettier-vscode, stylelint-prettier is a Prettier project and relatively active, while prettier-stylelint is independent and hasnā€™t been updated since September 2017. (I could quibble about the names too, Prettierā€™s project name start with ā€œstylelintā€?)

All that aside, prettier-stylelint (the independent one) works as described.

Here is a simplified, working example. (vscode 1.40.2, prettier-vscode 3.11.0, macOS 10.15.1)

Note: You might need to reload the VS Code window to get this working.

package.json

{
  [name, description, etc...],
  "devDependencies": {
    "prettier": "^1.19.1",
    "prettier-stylelint": "^0.4.2",
    "stylelint": "^12.0.0"
  },
  "stylelint": {
    "rules": {
      "comment-empty-line-before": "always"
    }
  }
}

Ugly input css

.a {color:       tomato;
  /* comment */
 padding: 2px; margin: 4px;}

Resulting CSS after running Format Document (alt-shift-f):

.a {
  color: tomato;

  /* comment */
  padding: 2px;
  margin: 4px;
}
1reaction
ntottencommented, Nov 13, 2019

As was mentioned above, you need to install prettier-stylelint. stylelint-prettier is a completely different thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to integrate Prettier with ESLint and stylelint
Install prettier-eslint, which is a tool that formats your JavaScript using Prettier followed by eslint --fix . The --fix is an ESLint featureĀ ......
Read more >
Integrating with Linters - Prettier
Most stylistic rules are unnecessary when using Prettier, but worse ā€“ they might conflict with Prettier! Use Prettier for code formatting concerns, and...
Read more >
How to use VSCode Prettier 3 formatting with stylelint
Installed VSCode; Installed Prettier plugin; Opened simply project with couple files (html, css); Installed stylelint with npm install --save-Ā ...
Read more >
stylelint-config-prettier - npm
stylelint -config-prettier is shipped with a little CLI tool to help you check if your configuration contains any rules that are in conflict...
Read more >
prettier-stylelint | Yarn - Package Manager
prettier -stylelint attempts to create a prettier config based on the stylelint config, then format with prettier followed by stylelint --fix.
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