UNPKG

ocrmnav

Version:

DevStack - The Complete Developer Toolkit - Virtual file system, workflow automation, and more than 65+ other development tools / features in one seamless extension. Cutting down dev times never before seen.

415 lines (314 loc) 11.9 kB
"use strict"; exports.id = 24; exports.ids = [24]; exports.modules = { /***/ 1519: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ atRuleAfterIndex: () => (/* binding */ atRuleAfterIndex), /* harmony export */ atRuleAfterNameIndex: () => (/* binding */ atRuleAfterNameIndex), /* harmony export */ atRuleBetweenIndex: () => (/* binding */ atRuleBetweenIndex), /* harmony export */ atRuleParamIndex: () => (/* binding */ atRuleParamIndex), /* harmony export */ declarationBetweenIndex: () => (/* binding */ declarationBetweenIndex), /* harmony export */ declarationValueIndex: () => (/* binding */ declarationValueIndex), /* harmony export */ ruleAfterIndex: () => (/* binding */ ruleAfterIndex), /* harmony export */ ruleBetweenIndex: () => (/* binding */ ruleBetweenIndex) /* harmony export */ }); /* harmony import */ var _getAtRuleParams_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1520); /* harmony import */ var _getRuleSelector_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1521); /* harmony import */ var _validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(579); /** @import {AtRule, Declaration, Rule} from 'postcss' */ /** * @param {AtRule} atRule * @returns {number} */ function atRuleParamIndex(atRule) { const index = atRuleAfterNameIndex(atRule); return index + (atRule.raws.afterName?.length ?? 0); } /** * @param {AtRule} atRule * @returns {number} */ function atRuleAfterIndex(atRule) { // subtract 1 for `}` const endOffset = atRule.source?.end?.offset; if (!endOffset) return atRule.toString().length - 1; const afterLength = atRule.raws?.after?.length; if (!afterLength) return endOffset - 1; return endOffset - (afterLength + 1); } /** * @param {AtRule} atRule * @returns {number} */ function atRuleAfterNameIndex(atRule) { // Initial 1 is for the `@` return 1 + atRule.name.length; } /** * @param {AtRule} atRule * @returns {number} */ function atRuleBetweenIndex(atRule) { return atRuleParamIndex(atRule) + (0,_getAtRuleParams_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(atRule).length; } /** * @param {Declaration} decl * @returns {number} */ function declarationBetweenIndex(decl) { const { prop } = decl.raws; const propIsObject = (0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__.isObject)(prop); return countChars([ propIsObject && 'prefix' in prop && prop.prefix, (propIsObject && 'raw' in prop && prop.raw) || decl.prop, propIsObject && 'suffix' in prop && prop.suffix, ]); } /** * Get the index of a declaration's value * * @param {Declaration} decl * @returns {number} */ function declarationValueIndex(decl) { const { between, value } = decl.raws; return ( declarationBetweenIndex(decl) + countChars([between || ':', value && 'prefix' in value && value.prefix]) ); } /** * @param {Rule} rule * @returns {number} */ function ruleBetweenIndex(rule) { return (0,_getRuleSelector_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(rule).length; } /** * @param {Rule} rule * @returns {number} */ function ruleAfterIndex(rule) { // subtract 1 for `}` const endOffset = rule.source?.end?.offset; if (!endOffset) return rule.toString().length - 1; const afterLength = rule.raws?.after?.length; if (!afterLength) return endOffset - 1; return endOffset - (afterLength + 1); } /** * @param {unknown[]} values * @returns {number} */ function countChars(values) { return values.reduce((/** @type {number} */ count, value) => { if ((0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__.isString)(value)) return count + value.length; return count; }, 0); } /***/ }), /***/ 1520: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ getAtRuleParams) /* harmony export */ }); /** * @param {import('postcss').AtRule} atRule * @returns {string} */ function getAtRuleParams(atRule) { return atRule.raws.params?.raw ?? atRule.params; } /***/ }), /***/ 1521: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ getRuleSelector) /* harmony export */ }); /** * @param {import('postcss').Rule} ruleNode * @returns {string} */ function getRuleSelector(ruleNode) { const raws = ruleNode.raws; return (raws.selector && raws.selector.raw) || ruleNode.selector; } /***/ }), /***/ 1522: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ getDeclarationValue) /* harmony export */ }); /** * @param {import('postcss').Declaration} decl * @returns {string} */ function getDeclarationValue(decl) { const raws = decl.raws; return (raws.value && raws.value.raw) || decl.value; } /***/ }), /***/ 1529: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ setDeclarationValue) /* harmony export */ }); /** @typedef {import('postcss').Declaration} Declaration */ /** * @param {Declaration} decl * @param {string} value * @returns {Declaration} The declaration that was passed in. */ function setDeclarationValue(decl, value) { const raws = decl.raws; if (raws.value) { raws.value.raw = value; } else { decl.value = value; } return decl; } /***/ }), /***/ 1570: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var postcss_value_parser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1514); /* harmony import */ var _utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1519); /* harmony import */ var _utils_getDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1522); /* harmony import */ var _utils_isStandardSyntaxColorFunction_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1571); /* harmony import */ var _utils_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(886); /* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(945); /* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(950); /* harmony import */ var _utils_setDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1529); /* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(873); const ruleName = 'color-function-alias-notation'; const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(ruleName, { expected: (unfixed, fixed) => `Expected "${unfixed}" to be "${fixed}"`, }); const meta = { url: 'https://stylelint.io/user-guide/rules/color-function-alias-notation', fixable: true, }; const WITH_A_FUNCTION_CALL = /\b(?:rgba|hsla)\(/i; const WITHOUT_A_FUNCTION_CALL = /\b(?:rgb|hsl)\(/i; const WITH_A_FUNCTION_NAME = /^(?:rgba|hsla)$/i; const WITHOUT_A_FUNCTION_NAME = /^(?:rgb|hsl)$/i; /** @type {import('stylelint').CoreRules[ruleName]} */ const rule = (primary) => { return (root, result) => { const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(result, ruleName, { actual: primary, possible: ['with-alpha', 'without-alpha'], }); if (!validOptions) return; const targetFunctionCall = primary === 'with-alpha' ? WITHOUT_A_FUNCTION_CALL : WITH_A_FUNCTION_CALL; const targetFunctionName = primary === 'with-alpha' ? WITHOUT_A_FUNCTION_NAME : WITH_A_FUNCTION_NAME; root.walkDecls((decl) => { if (!targetFunctionCall.test(decl.value)) return; const parsedValue = postcss_value_parser__WEBPACK_IMPORTED_MODULE_0__((0,_utils_getDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(decl)); parsedValue.walk((node) => { if (!(0,_utils_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_4__.isValueFunction)(node) || !(0,_utils_isStandardSyntaxColorFunction_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(node)) return; const { value, sourceIndex } = node; if (!targetFunctionName.test(value)) return; const fixed = primary === 'with-alpha' ? `${value}a` : value.slice(0, -1); const fix = () => { node.value = fixed; (0,_utils_setDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(decl, parsedValue.toString()); }; const index = (0,_utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__.declarationValueIndex)(decl) + sourceIndex; const endIndex = index + value.length; (0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])({ message: messages.expected, messageArgs: [value, fixed], node: decl, index, endIndex, result, ruleName, fix: { apply: fix, node: decl, }, }); }); }); }; }; rule.ruleName = ruleName; rule.messages = messages; rule.meta = meta; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule); /***/ }), /***/ 1571: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ isStandardSyntaxColorFunction) /* harmony export */ }); /* harmony import */ var _isStandardSyntaxFunction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1572); /** * Check whether a function is standard syntax color function * * @param {import('postcss-value-parser').FunctionNode} node * @returns {boolean} */ function isStandardSyntaxColorFunction(node) { if (!(0,_isStandardSyntaxFunction_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(node)) return false; // scss can accept a #hex, or $var variables and we need to check all nested fn nodes for (const fnNode of node.nodes) { if (fnNode.type === 'function') return isStandardSyntaxColorFunction(fnNode); if ( fnNode.type === 'word' && (fnNode.value.startsWith('#') || fnNode.value.startsWith('$') || fnNode.value.includes('.$')) ) return false; } return true; } /***/ }), /***/ 1572: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ isStandardSyntaxFunction) /* harmony export */ }); /** * Check whether a function is standard * * @param {import('postcss-value-parser').Node} node * @returns {boolean} */ function isStandardSyntaxFunction(node) { // Function nodes without names are things in parentheses like Sass lists if (!node.value) { return false; } if (node.value.startsWith('#{')) { return false; } // CSS-in-JS interpolation if (node.value.startsWith('${')) { return false; } // CSS-in-JS syntax if (node.value.startsWith('`')) { return false; } return true; } /***/ }) }; ; //# sourceMappingURL=24.extension.js.map