Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | const metadata = require('../metadata/metadata.js'); /** * Validate scope * @param {Object[]} arr An array of words from the css custom property * @param {Object} keys An object of keys based on metadata * @returns {Object} Validation object */ const validateScope = (arr, keys) => { const scope = arr[keys.scope]; let isGlobal = false; let isReference = false; let isShared = false; let isComponent = false; if (scope && scope === 'g') isGlobal = true; if (scope && scope === 'r') isReference = true; if (scope && scope === 's') isShared = true; if (scope && scope === 'c') isComponent = true; if (arr.includes(scope)) return { valid: true, scope, isGlobal, isReference, isShared, isComponent }; return { valid: false, expected: metadata.scopes, received: arr[1] }; }; module.exports = validateScope; |