prettier-grundy-scss-order
v0.2.0
Published
Sorter for properties in scss files
Maintainers
Readme
Prettier-grundy-scss-order ᴿᵁ
A Prettier plugin to sort CSS or SCSS properties. Using postcss-scss for parse source.
Usage
Following the Prettier plugin guidelines, this package depends on Prettier as a peer dependency:
npm install prettier-grundy-scss-order --save-dev
To enable the plugin use the Prettier API, CLI or configuration file. For example using the JS configuration:
{
"plugins": ["prettier-grundy-scss-order"]
}Configuration
This plugin adds next configurable keys to Prettier:
grundyScssSorterGroupsOrder
["@use", "--variable", "$variable", "@if", "decl", "@include", "@mixin", "rule"]grundyScssSorterWithRoot
true
grundyScssSorterSplitGroup
false
grundyScssSorterGroups
define custom groups to sort, extend default groups
grundyScssSorterPreset
predefined properties, for example: csscomb
Presets
Available presets for migrate from other plugins
preset for migrate from csscomb sorter with default preset
preset for migrate from csscomb sorter with yandex preset
preset for migrate from csscomb sorter with zen preset
Predefined groups
@use- scssusestatements@mixin- scss@mixinstatements--variable- css custom properties:$variable- scss variablesdecl- any css properties:color: ...,backgroud: ..., etc.@include- scss@includestatementsrule- css selector rule:.class {...},tag{...},#id{...}, etc.@if- scss@ifwith optionally@else/@else ifstatements@media- css@mediastatements@supports- css@supportsstatements
Custom groups
With option grundyScssSorterGroups possibly add custom groups satisfying the criterias
example, add group @font - in this group select all properties started with font: font, font-size, etc.
"{\"@font\": { \"startsWith\": \"font\" }}";Then possibly use this group in grundyScssSorterGroupsOrder:
["--variable", "$variable", "@font", "decl"];Custom groups criterias
To define custom group available next criterias
startsWith- check name starts with parameteroneOf- check name one of array stringtype- check node type one of predefined type- "use"
- "mixin"
- "include"
- "if"
- "extend"
- "atrule"
- "rule"
- "decl"
- "$variable"
- "variable"
- "media"
- "supports"
Samples
{
"type": "use"
}@use "colors";
@use "colors" as c;{
"startsWith": "font"
}font: "Courier New";
font-size: 10px;
@include fonts;{
"oneOf": ["position", "left"]
}position: relative;
left: 10px;