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.
369 lines (287 loc) • 10.6 kB
JavaScript
exports.id = 47;
exports.ids = [47];
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;
}
/***/ }),
/***/ 1533:
/***/ ((__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 */ });
/**
* Contains helpers for working with vendor prefixes.
*
* Copied from https://github.com/postcss/postcss/commit/777c55b5d2a10605313a4972888f4f32005f5ac2
*
* @namespace vendor
*/
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
/**
* Returns the vendor prefix extracted from an input string.
*
* @param {string} prop String with or without vendor prefix.
*
* @returns {string} vendor prefix or empty string
*
* @example
* vendor.prefix('-moz-tab-size') //=> '-moz-'
* vendor.prefix('tab-size') //=> ''
*/
prefix(prop) {
const match = prop.match(/^(-\w+-)/);
if (match) {
return match[0] || '';
}
return '';
},
/**
* Returns the input string stripped of its vendor prefix.
*
* @param {string} prop String with or without vendor prefix.
*
* @returns {string} String name without vendor prefixes.
*
* @example
* vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
*/
unprefixed(prop) {
return prop.replace(/^-\w+-/, '');
},
});
/***/ }),
/***/ 1564:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ validateObjectWithArrayProps)
/* harmony export */ });
/* harmony import */ var _validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(579);
/**
* Check whether the variable is an object and all its properties are one or more values
* that satisfy the specified validator(s):
*
* @example
* ignoreProperties = {
* value1: ["item11", "item12", "item13"],
* value2: "item2",
* };
* validateObjectWithArrayProps(isString)(ignoreProperties);
* //=> true
*
* @typedef {(value: unknown) => boolean} Validator
* @param {...Validator} validators
* @returns {Validator}
*/
function validateObjectWithArrayProps(...validators) {
return (value) => {
if (!(0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(value)) {
return false;
}
return Object.values(value)
.flat()
.every((item) => validators.some((v) => v(item)));
};
}
/***/ }),
/***/ 1629:
/***/ ((__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 _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(579);
/* harmony import */ var _utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1519);
/* harmony import */ var _utils_matchesStringOrRegExp_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(870);
/* harmony import */ var _utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(869);
/* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(945);
/* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(950);
/* harmony import */ var _utils_validateObjectWithArrayProps_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1564);
/* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(873);
/* harmony import */ var _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1533);
const ruleName = 'declaration-property-value-allowed-list';
const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])(ruleName, {
rejected: (property, value) => `Unexpected value "${value}" for property "${property}"`,
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/declaration-property-value-allowed-list',
};
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary) => {
return (root, result) => {
const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(result, ruleName, {
actual: primary,
possible: [(0,_utils_validateObjectWithArrayProps_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isRegExp)],
});
if (!validOptions) {
return;
}
const propKeys = Object.keys(primary);
root.walkDecls((decl) => {
const { prop, value } = decl;
const unprefixedProp = _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_8__["default"].unprefixed(prop);
const propPatterns = propKeys.filter((key) => (0,_utils_matchesStringOrRegExp_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(unprefixedProp, key));
if (propPatterns.length === 0) {
return;
}
if (propPatterns.some((pattern) => (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(primary, pattern, value))) {
return;
}
const index = (0,_utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__.declarationValueIndex)(decl);
const endIndex = index + decl.value.length;
(0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])({
message: messages.rejected,
messageArgs: [prop, value],
node: decl,
index,
endIndex,
result,
ruleName,
});
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule);
/***/ })
};
;
//# sourceMappingURL=47.extension.js.map
;