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

Add support for stylelint as formatter #25

Closed
fisker opened this issue Dec 27, 2019 · 14 comments · Fixed by #200
Closed

Add support for stylelint as formatter #25

fisker opened this issue Dec 27, 2019 · 14 comments · Fixed by #200
Assignees
Labels
type: enhancement a new feature that isn't related to rules
Milestone

Comments

@fisker
Copy link

fisker commented Dec 27, 2019

Like ESLint do https://github.com/microsoft/vscode-eslint#release-notes

Formatter support: ESLint can now be used as a formatter. To enable this feature use the eslint.format.enable setting.

@ux-engineer
Copy link

Yes please, came by this need myself yesterday.

@ux-engineer
Copy link

How many rules are there in Stylelint, and how many of them have autofix logic built for them?

@BPScott
Copy link
Contributor

BPScott commented Dec 28, 2019

@ux-engineer https://stylelint.io/user-guide/rules is your big list of rules that are built into stylelint. Autofixable ones are denoted with an "(Autofixable)".

@ux-engineer
Copy link

ux-engineer commented Dec 28, 2019

Ah, sorry - someone mentioned earlier there would be many that don't have autofix... It seems he was incorrect, or meant about an another project which extends Stylelint.

Great work you've done. Now, if we would get Stylelint as a proper formatter for VS Code, that would be super! :)

Also to support Vue Single-Page Component's style blocks: #19

PS. In Vue ecosystem, I already got to ditch Prettier now that ESLint acts as an formatter...but still needing to find proper setup with Stylelint to format SCSS.

@GollyJer
Copy link

GollyJer commented Jan 4, 2020

Came looking for this today as well. Thought I had configured something wrong. 👍

@francois-pasquier
Copy link

Here is my workaround with multiCommand:

keybindings.json

[
    {
        "key": "ctrl+shift+i",
        "command": "extension.multiCommand.execute",
        "args": {
            "command": "multiCommand.formatJavascript"
        },
        "when": "editorLangId == javascript && editorTextFocus && !editorReadonly"
    },
]

settings.json

    "eslint.format.enable": true,
    "[javascript]": {
        "editor.defaultFormatter": "dbaeumer.vscode-eslint",
    },
    "multiCommand.commands": [
        {
            "command": "multiCommand.formatJavascript",
            "sequence": [
                "editor.action.formatDocument",
                "stylelint.executeAutofix"
            ]
        }
    ]

@kanlukasz
Copy link

My solution - just add specific shortcuts

	{
		"key": "alt+shift+f",
		"command": "stylelint.executeAutofix",
		"when": "editorTextFocus && editorLangId == 'css'"
	},
	{
		"key": "alt+shift+f",
		"command": "stylelint.executeAutofix",
		"when": "editorTextFocus && editorLangId == 'scss'"
	},
	{
		"key": "alt+shift+f",
		"command": "stylelint.executeAutofix",
		"when": "editorTextFocus && editorLangId == 'less'"
	}

@jeddy3
Copy link
Member

jeddy3 commented Mar 12, 2020

Is this resolved by pull request #18 or is enabling stylelint as a formatter something else?

@jeddy3 jeddy3 changed the title Feature request: support stylelint as formatter Add support for stylelint as formatter Mar 12, 2020
@jeddy3 jeddy3 added the status: needs clarification triage needs clarification from author label Mar 12, 2020
@GollyJer
Copy link

@jeddy3

This is separate from #18. Here we're talking about the ability to format without having to save.

Here is the command in vscode.

@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules and removed status: needs clarification triage needs clarification from author labels Mar 31, 2020
@mcdado
Copy link

mcdado commented Jun 3, 2020

I think to achieve this goal, this is the way: https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices

@mbacalan
Copy link

I'm surprised this is still pending as it would improve the extension by large. Would love to see this support added for all the lazy developers out there that rely on formatting on save.

@adalinesimonian
Copy link
Member

An update for anyone looking forward to this functionality: I merged my implementation of the formatter from #200 a little over a week ago. However, I had reservations about how thoroughly the code I wrote was being tested, so I didn't want to cut a release yet at the time.

Over the past week, I've worked on improving testing for this extension, creating a Jest runner for testing VS Code extensions and revamping the testing and CI setup for this extension. Funny enough, this work paid off and identified a bug in the formatter that wasn't caught before, which I've now patched.

I'm looking forward to pushing out a new release of this extension with the document formatting support soon. I'm done for the day but I'll share once there's an update.

@adalinesimonian adalinesimonian self-assigned this Sep 23, 2021
@adalinesimonian adalinesimonian removed the status: ready to implement is ready to be worked on by someone label Sep 23, 2021
@adalinesimonian adalinesimonian added this to the v0.87.0 milestone Sep 27, 2021
@adalinesimonian
Copy link
Member

v0.87.1 has been released with document formatting support! 🚀🎉

@yukulele
Copy link

yukulele commented Nov 3, 2022

It doesn't work for scss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement a new feature that isn't related to rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.