Skip to content

Instantly share code, notes, and snippets.

@usingthesystem
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save usingthesystem/b1f89b9bf28e0a8c258a to your computer and use it in GitHub Desktop.

Select an option

Save usingthesystem/b1f89b9bf28e0a8c258a to your computer and use it in GitHub Desktop.
csscomb - rules-delimiter.js
// create the following file to insert the extra functionality rules-delimiter.js
// add the following to the configuration of csscomb: "rules-delimiter": 1
// ~/Library/Application Support/Sublime Text 3/Packages/CSScomb/node_modules/csscomb/lib/options/rules-delimiter.js
module.exports = {
name: 'rules-delimiter',
syntax: ['css', 'less', 'sass', 'scss'],
runBefore: "strip-spaces",
setValue: function(value) {
if (typeof value === 'number') {
value = Array(value + 1).join('\n');
}
return value;
},
process: function(nodeType, node) {
var value = this.getValue('rules-delimiter'),
currentNode,
previousNode;
for(var i = node.length; i--;) {
currentNode = node[i];
previousNode = node[i - 1];
if(currentNode[0] === 'ruleset' && previousNode) {
if(previousNode[0] !== 's' || (node[i-2] && node[i-2][0] !== 'commentML' && node[i-2][0] !== 'commentSL')) {
node.splice(i - 1, 0, ['s', value]);
}
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment