UNPKG

768 BJavaScriptView Raw
1'use strict';
2
3const hasInterpolation = require('../utils/hasInterpolation');
4
5/**
6 * Check whether a value is standard
7 *
8 * @param {string} value
9 * @returns {boolean}
10 */
11module.exports = function (value) {
12 let normalizedValue = value;
13
14 // Ignore operators before variables (example -$variable)
15 if (/^[-+*/]/.test(value[0])) {
16 normalizedValue = normalizedValue.slice(1);
17 }
18
19 // SCSS variable (example $variable)
20 if (normalizedValue.startsWith('$')) {
21 return false;
22 }
23
24 // SCSS namespace (example namespace.$variable)
25 if (/^.+\.\$/.test(value)) {
26 return false;
27 }
28
29 // Less variable
30 if (normalizedValue.startsWith('@')) {
31 return false;
32 }
33
34 // SCSS or Less interpolation
35 if (hasInterpolation(normalizedValue)) {
36 return false;
37 }
38
39 return true;
40};