eslint-plugin-grouped-css-declarations
v1.2.1
Published
- Requires ESLint `>=8`
Downloads
1,420
Maintainers
Readme
Identifies @linaria/core CSS-in-JS tags and ensures that a standardised grouping of declarations is enforced using the PostCSS parser.
A group
is identified as a logical set of declarations separated by either an empty line or a comment.
Issues will, whereever possible, be reported inline at violating CSS lines to allow developers to easily digest issues. However, in some cases such reports have not been implemented.
In practice the reports exist simply to improve DX-experience. The actual auto-fix relies upon comparing the original AST with an AST that fully respects the configured ordering, prioritised as follows:
- Declaration grouping will be considered in scopes. AtRule and Rule creates new scopes.
- The root scope will be positioned before other scopes. Then Rule scopes will follow and finally AtRules.
- Inside each scope declarations will be sorted based on the provided grouping.
- In case a group of declarations begins with a comment, then these will be taken out of the ordering flow and positioned at the end of the scope. Ordering will not be performed for this group.
- If a declaration does not match any provided grouping then it will be added to a final group after all other groups. Inside declarations will be sorted alphabetically.
Installation
- Requires ESLint
>=8
yarn add --dev eslint-plugin-grouped-css-declarations
npm install --save-dev eslint-plugin-grouped-css-declarations
Usage
To include the recommended eslint-plugin-grouped-css-declarations
to your ruleset add the following to your .eslintrc
configuration:
{
"extends": [
"plugin:grouped-css-declarations/recommended"
]
}