Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
stylelint-order
Advanced tools
The stylelint-order npm package is a plugin for stylelint that provides order related linting rules for CSS properties within declaration blocks. It helps in enforcing a consistent order for CSS properties, which can make code easier to read and maintain.
Specifying the order of content within declaration blocks
This feature allows you to define the order in which different types of content within a declaration block should appear. For example, you can specify that custom properties should be declared before any other declarations.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/order": [
"custom-properties",
"declarations"
],
"order/properties-order": [
"position",
"top",
"right",
"bottom",
"left"
]
}
}
Specifying the order of properties within declaration blocks
This feature allows you to define a specific order for CSS properties within a declaration block. You can list the properties in the order you want them to be linted. This can be a custom order or alphabetical order.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/properties-order": [
"position",
"z-index",
"top",
"right",
"bottom",
"left"
],
"order/properties-alphabetical-order": {}
}
}
Grouping and separating properties
This feature allows you to group related properties together and enforce an empty line before the group or between groups. This can improve readability and organization of CSS rules.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/properties-order": [
[
"position",
"z-index"
],
{
"emptyLineBefore": "always",
"properties": [
"color",
"font-size",
"font-weight"
]
}
]
}
}
CSScomb is a coding style formatter for CSS. Similar to stylelint-order, it can sort CSS properties in a specific order. However, CSScomb is not a plugin for stylelint and has its own configuration and usage patterns.
postcss-sorting is a PostCSS plugin that sorts CSS properties according to specified order. It is similar to stylelint-order in functionality but is used within the PostCSS ecosystem, which is a tool for transforming CSS with JavaScript plugins.
sass-lint is a tool to help you enforce consistent conventions and avoid errors in your stylesheets. It is similar to stylelint-order in that it can enforce property order, but it is specifically designed for linting Sass files, not standard CSS.
A plugin pack of order-related linting rules for Stylelint. Every rule supports autofixing (stylelint --fix
).
npm install stylelint --save-dev
stylelint-order
:npm install stylelint-order --save-dev
Add stylelint-order
to your Stylelint config plugins
array, then add rules you need to the rules list. All rules from stylelint-order need to be namespaced with order
.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/order": [
"custom-properties",
"declarations"
],
"order/properties-order": [
"width",
"height"
]
}
}
order
: Specify the order of content within declaration blocks.properties-order
: Specify the order of properties within declaration blocks.properties-alphabetical-order
: Specify the alphabetical order of properties within declaration blocks.Every rule supports autofixing with stylelint --fix
. postcss-sorting is used internally for order autofixing.
Automatic sorting has some limitations that are described for every rule, if any. Please, take a look at how comments are handled by postcss-sorting
.
CSS-in-JS styles with template interpolation could be ignored by autofixing to avoid style corruption.
Autofixing in Less syntax may work but isn't officially supported.
All these configs have properties-order
configured with logical properties groups:
stylelint-config-idiomatic-order
stylelint-config-hudochenkov/order
stylelint-config-recess-order
stylelint-config-property-sort-order-smacss
stylelint-config-clean-order
properties-order
and properties-alphabetical-order
code and README were based on the declaration-block-properties-order
rule which was a core rule prior to Stylelint 8.0.0.
6.0.4
FAQs
A collection of order related linting rules for Stylelint.
The npm package stylelint-order receives a total of 1,393,916 weekly downloads. As such, stylelint-order popularity was classified as popular.
We found that stylelint-order demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.