.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isStandardSyntaxRule.js
1 /* @flow */
2 "use strict";
3
4 const _ = require("lodash");
5 const isCustomPropertySet = require("../utils/isCustomPropertySet");
6
7 /**
8  * Check whether a Node is a standard rule
9  */
10 module.exports = function(rule /*: Object*/) /*: boolean*/ {
11   // Get full selector
12   const selector = _.get(rule, "raws.selector.raw", rule.selector);
13
14   // Custom property set (e.g. --custom-property-set: {})
15   if (isCustomPropertySet(rule)) {
16     return false;
17   }
18
19   // Called Less mixin (e.g. a { .mixin() })
20   if (rule.mixin) {
21     return false;
22   }
23
24   // Less detached rulesets
25   if (selector.slice(0, 1) === "@" && selector.slice(-1) === ":") {
26     return false;
27   }
28
29   // Ignore Less &:extend rule
30   if (rule.extend) {
31     return false;
32   }
33
34   // Ignore mixin or &:extend rule
35   // https://github.com/shellscape/postcss-less/blob/master/lib/less-parser.js#L52
36   if (rule.params && rule.params[0]) {
37     return false;
38   }
39
40   // Non-outputting Less mixin definition (e.g. .mixin() {})
41   if (_.endsWith(selector, ")") && !_.includes(selector, ":")) {
42     return false;
43   }
44
45   // Less guards
46   if (/when\s+(not\s+)*\(/.test(selector)) {
47     return false;
48   }
49
50   // Ignore Scss nested properties
51   if (selector.slice(-1) === ":") {
52     return false;
53   }
54
55   return true;
56 };