stylelint-config-rational-declaration
v2.0.0
Published
Stylelint config that sorts related property declarations by grouping together following the order: Positioning, Structure, Grid, Dimension, Definition, Typography, Visual, Animation, Other.
Downloads
9
Maintainers
Readme
stylelint-config-rational-declaration
Stylelint config that sorts related property declarations by grouping together following the order:
- Positioning
- Structure
- Dimension
- Definition
- Typography
- Visual
- Animation
- Misc
.declaration-order {
/* Positioning */
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 10;
/* Structure */
display: flex;
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
float: right;
/* Grid */
display: grid;
grid-template-columns: 40px 50px auto 50px 40px;
grid-template-rows: 25% 100px auto;
/* Dimension */
width: 100px;
height: 100px;
/* Definition */
padding: 10px;
border: 1px solid #888;
border-radius: 4px;
margin: 10px;
/* Typography */
font: normal 16px Helvetica, sans-serif;
color: #888;
line-height: 1.3;
text-align: center;
/* Visual */
background-color: #eee;
opacity: 1;
/* Animation */
transition: all 1s;
/* Misc */
user-select: none;
}
Usage
- Add
stylelint
,stylelint-order
and this package to your project:
npm install --save-dev stylelint stylelint-order stylelint-config-rational-declaration
# or, if you prefer yarn over npm:
yarn add --dev stylelint stylelint-order stylelint-config-rational-declaration
- Add this package to the end of your extends array inside Stylelint configuration (.stylelintrc for example):
{
"extends": [
// "stylelint-config-standard",
"stylelint-config-rational-declaration"
]
}
This shareable config contains the following:
{
"plugins": [
"stylelint-order",
"stylelint-config-rational-declaration/plugin"
],
"rules": {
"order/properties-order": [],
"plugin/rational-declaration": [true, {
"empty-line-between-groups": false,
}]
}
}
Since it adds stylelint-order
and stylelint-config-rational-declaration
to plugins and also adds required rules, you don't have to do this yourself when extending this config.
Optional options / rules
empty-line-between-groups
If true
adds an empty line between groups. The default value is false
.
FAQ
The pros and cons of both ways in detail:
Credits
https://github.com/constverum/stylelint-config-rational-order/packages