Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
feat: extend order rules
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-lit committed Jan 31, 2021
1 parent 126a836 commit db935e3
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 64 deletions.
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"stylelint-use-nesting": "^3.0.0"
},
"devDependencies": {
"@alexlit/lint-kit": "0.15.0"
"@alexlit/lint-kit": "0.16.0"
}
}
149 changes: 136 additions & 13 deletions plugins/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,110 @@ module.exports = {
rules: {
'order/order': [
/**
* SASS
* SASS Extend
*
* @example
* ```scss
* .my-component {
* @extend: .custom-class;
* }
* ```
*/
{ type: 'at-rule', name: 'extend' },

/**
* SASS Include
*
* @example
* ```scss
* .my-component {
* @include: mixins;
* }
* ```
*/
{ type: 'at-rule', name: 'include' },

/**
* SASS Variables
*
* @example
* ```scss
* .my-component {
* $color: red;
* }
* ```
*/
'dollar-variables',

/**
* LESS
* LESS Variables
*
* @example
* ```scss
* .my-component {
* @color: red;
* }
* ```
*/
'at-variables',

/**
* CSS
*
* @example
* ```scss
* .my-component {
* --color: red;
* }
* ```
*/
'custom-properties',

/**
* Declarations
*
* @example
* ```scss
* .my-component {
* color: red;
* }
* ```
*/
'declarations',

/**
* BEM elements
*
* @example
* ```scss
* .my-component {
* &__element {}
* }
* ```
*/
{ type: 'rule', selector: /__/ },

/**
* BEM modifiers
*
* @example
* ```scss
* .my-component {
* &--modifier {}
* }
* ```
*/
{ type: 'rule', selector: /--/ },

/**
* Pseudo Elements
*
* @example
* ```scss
* .my-component {
* &::before {}
* }
* ```
*/
{ type: 'rule', selector: '::first-line' },
{ type: 'rule', selector: '::first-letter' },
Expand All @@ -36,6 +119,13 @@ module.exports = {

/**
* Pseudo Classes
*
* @example
* ```scss
* .my-component {
* &:empty {}
* }
* ```
*/
{ type: 'rule', selector: ':active' },
{ type: 'rule', selector: ':checked' },
Expand Down Expand Up @@ -71,6 +161,13 @@ module.exports = {

/**
* CSS [attribute*=value] Selector
*
* @example
* ```scss
* .my-component {
* &[class*="custom"] {}
* }
* ```
*/
{ type: 'rule', selector: /\[accept/ },
{ type: 'rule', selector: /\[accept-charset/ },
Expand Down Expand Up @@ -240,28 +337,54 @@ module.exports = {
{ type: 'rule', selector: /\[width/ },
{ type: 'rule', selector: /\[/ },

/**
* BEM modifiers
*/
{ type: 'rule', selector: /--/ },

/**
* Rules
*/
'rules',

/**
* At Rules
*
* @example
* ```scss
* .my-component {
* @media screen and (max-width: 992px) {}
* }
* ```
*/
{ type: 'at-rule', name: 'at-root' },
'at-rules',
{ type: 'at-rule', name: 'media' },
{ type: 'at-rule', name: 'keyframes' },

/**
* ::v-deep
* Rules
*
* @example
* ```scss
* .my-component {
* & + div {}
* }
* ```
*/
{ type: 'rule', selector: /\*/ },
{ type: 'rule', selector: /~/ },
{ type: 'rule', selector: /\+/ },
{ type: 'rule', selector: />\s/ },
{ type: 'rule', selector: /\./ },
{ type: 'rule', selector: /#/ },
'rules',

/**
* Deep Operators
*
* @example
* ```scss
* .my-component {
* & ::v-deep {
* & .child-component {}
* }
* }
* ```
*/
{ type: 'rule', selector: /::v-deep/ },
{ type: 'rule', selector: />>>/ },
{ type: 'rule', selector: /\/deep\// },
],
},
'order/properties-alphabetical-order': true,
Expand Down
Loading

0 comments on commit db935e3

Please sign in to comment.