UNPKG

833 BJavaScriptView Raw
1/**
2 * Check whether a declaration is standard
3 */
4export function isStandardSyntaxDeclaration (decl /*: Object */) /*: boolean */ {
5 const prop = decl.prop
6 const parent = decl.parent
7
8 // Declarations belong in a declaration block
9
10 if (parent.type === 'root') {
11 return false
12 }
13
14 // Sass var (e.g. $var: x), nested list (e.g. $list: (x)) or nested map (e.g. $map: (key:value))
15 if (prop[0] === '$') {
16 return false
17 }
18
19 // Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
20 if (prop[0] === '@' && prop[1] !== '{') {
21 return false
22 }
23
24 // Sass nested properties (e.g. border: { style: solid; color: red; })
25 if (
26 parent.selector &&
27 parent.selector[parent.selector.length - 1] === ':' &&
28 parent.selector.substring(0, 2) !== '--'
29 ) {
30 return false
31 }
32
33 return true
34}