Created
January 13, 2019 06:35
-
-
Save amalitsky/53e6abb0f7d173eb28447eeb11f46d2c to your computer and use it in GitHub Desktop.
Extensive Stylelint config file for LESS syntax based on config-recommended with rules and declarations ordering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const orderedPropertyHash = require('css-property-sort-order-smacss'); | |
/** @type {string[]} List of CSS properties */ | |
const orderedPropertyList = []; | |
Object.values(orderedPropertyHash).forEach(listOrListOfLists => { | |
listOrListOfLists.forEach(propertyOrList => { | |
if (Array.isArray(propertyOrList)) { | |
orderedPropertyList.push(...propertyOrList); | |
} else { | |
orderedPropertyList.push(propertyOrList); | |
} | |
}); | |
}); | |
const always = 'always'; | |
const never = 'never'; | |
const alwaysSingleLine = 'always-single-line'; | |
const typeOrder = [ | |
'at-variables', | |
'dollar-variables', | |
'custom-properties', | |
'declarations', | |
'rules' | |
//'at-rules' - doesn't work well with less mixins | |
]; | |
/** @type {Object} Stylelint config object */ | |
const config = { | |
extends: 'stylelint-config-recommended', | |
plugins: [ | |
'stylelint-order' | |
], | |
ignoreFiles: [], | |
rules: { | |
'at-rule-no-unknown': null, | |
'at-rule-empty-line-before': [ | |
'always', { | |
except: ['first-nested'], | |
ignore: ['after-comment', 'blockless-after-blockless'], | |
ignoreAtRules: ['if', 'else'] | |
} | |
], | |
indentation: [ | |
4, { | |
ignore: ['inside-parens'] | |
} | |
], | |
'order/order': typeOrder, | |
'order/properties-order': orderedPropertyList, | |
'string-quotes': null, //single is breaking CSS syntax for some reason | |
'length-zero-no-unit': true, | |
'max-empty-lines': 2, | |
'max-line-length': 120, | |
'no-eol-whitespace': true, | |
'no-missing-end-of-source-newline': true, | |
'unit-case': 'lower', | |
'color-hex-case': 'upper', | |
'color-hex-length': 'short', | |
linebreaks: 'unix', | |
'selector-type-no-unknown': null, | |
'no-descending-specificity': null, | |
'font-family-name-quotes': null, | |
'function-url-quotes': never, | |
'declaration-colon-space-after': always, | |
'declaration-colon-space-before': never, | |
//'declaration-block-semicolon-newline-after': always, - buggy | |
'block-closing-brace-newline-after': always, | |
'selector-combinator-space-before': always, | |
'selector-combinator-space-after': always, | |
'no-empty-first-line': true, | |
'rule-empty-line-before': [ | |
'always-multi-line', { | |
except: ['first-nested'], | |
ignore: ['after-comment'] | |
} | |
], | |
'value-no-vendor-prefix': true, | |
'at-rule-no-vendor-prefix': true, | |
'block-opening-brace-space-before': always, | |
'declaration-block-semicolon-newline-before': 'never-multi-line', | |
'value-list-comma-space-after': alwaysSingleLine, | |
'selector-list-comma-space-before': never, | |
'selector-list-comma-space-after': alwaysSingleLine, | |
'function-comma-space-after': alwaysSingleLine | |
} | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment