.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isStandardSyntaxDeclaration.js
1 /* @flow */
2 "use strict";
3
4 /**
5  * Check whether a declaration is standard
6  */
7 module.exports = function(decl /*: Object*/) /*: boolean*/ {
8   const prop = decl.prop,
9     parent = decl.parent;
10
11   // Declarations belong in a declaration block
12
13   if (parent.type === "root") {
14     return false;
15   }
16
17   // SCSS var (e.g. $var: x), nested list (e.g. $list: (x)) or nested map (e.g. $map: (key:value))
18   if (prop[0] === "$") {
19     return false;
20   }
21
22   // Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
23   if (prop[0] === "@" && prop[1] !== "{") {
24     return false;
25   }
26
27   // SCSS nested properties (e.g. border: { style: solid; color: red; })
28   if (
29     parent.selector &&
30     parent.selector[parent.selector.length - 1] === ":" &&
31     parent.selector.substring(0, 2) !== "--"
32   ) {
33     return false;
34   }
35
36   return true;
37 };