Sha256: e11e389f627d8f6547813ee2b7380c52f98073b1d9e429d05b4a21752b2d6240
Contents?: true
Size: 1.4 KB
Versions: 24
Compression:
Stored size: 1.4 KB
Contents
let stylelint = require('stylelint'); let postcssSorting = require('postcss-sorting'); let { namespace, getContainingNode, isRuleWithNodes } = require('../../utils'); let checkNode = require('./checkNode'); let ruleName = namespace('properties-alphabetical-order'); let messages = stylelint.utils.ruleMessages(ruleName, { expected: (first, second) => `Expected ${first} to come before ${second}`, }); function rule(actual, options = {}, context = {}) { return function(root, result) { let validOptions = stylelint.utils.validateOptions( result, ruleName, { actual, possible: Boolean, }, { actual: options, possible: { disableFix: Boolean, }, optional: true, } ); if (!validOptions) { return; } let disableFix = options.disableFix || false; if (context.fix && !disableFix) { postcssSorting({ 'properties-order': 'alphabetical' })(root); return; } let processedParents = []; root.walk(function processRulesAndAtrules(input) { let node = getContainingNode(input); // Avoid warnings duplication, caused by interfering in `root.walk()` algorigthm with `getContainingNode()` if (processedParents.includes(node)) { return; } processedParents.push(node); if (isRuleWithNodes(node)) { checkNode(node, result, ruleName, messages); } }); }; } rule.ruleName = ruleName; rule.messages = messages; module.exports = rule;
Version data entries
24 entries across 24 versions & 1 rubygems