summaryrefslogtreecommitdiff
path: root/scripts/frontend/stylelint/stylelint-utility-classes.js
blob: 14827145b54b02aa101d7bb594cfd2f07f5d9210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const stylelint = require('stylelint');
const utils = require('./stylelint-utils');
const utilityClasses = require('./utility-classes-map');

const ruleName = 'stylelint-gitlab/utility-classes';

const messages = stylelint.utils.ruleMessages(ruleName, {
  expected: (selector1, selector2) => {
    return `"${selector1}" has the same properties as our BS4 utility class "${selector2}" so please use that instead.`;
  },
});

module.exports = stylelint.createPlugin(ruleName, (enabled) => {
  if (!enabled) {
    return;
  }

  // eslint-disable-next-line consistent-return
  return (root, result) => {
    utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false);
  };
});

module.exports.ruleName = ruleName;
module.exports.messages = messages;