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.
360 lines (274 loc) • 12.1 kB
JavaScript
;
exports.id = 88;
exports.ids = [88];
exports.modules = {
/***/ 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;
}
/***/ }),
/***/ 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)));
};
}
/***/ }),
/***/ 1814:
/***/ ((__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 _csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(889);
/* harmony import */ var _csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1647);
/* harmony import */ var _csstools_media_query_list_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1710);
/* harmony import */ var _utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1519);
/* harmony import */ var _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(579);
/* harmony import */ var _utils_regexes_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1535);
/* harmony import */ var _utils_getAtRuleParams_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1520);
/* harmony import */ var _utils_getDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1522);
/* harmony import */ var _utils_hasDimension_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1815);
/* harmony import */ var _utils_isUnicodeRangeDescriptor_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1816);
/* harmony import */ var _utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(869);
/* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(945);
/* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(950);
/* harmony import */ var _utils_validateObjectWithArrayProps_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(1564);
/* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(873);
const ruleName = 'unit-disallowed-list';
const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_12__["default"])(ruleName, {
rejected: (unit) => `Unexpected unit "${unit}"`,
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/unit-disallowed-list',
};
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary, secondaryOptions) => {
return (root, result) => {
const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_14__["default"])(
result,
ruleName,
{
actual: primary,
possible: [_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isString],
},
{
optional: true,
actual: secondaryOptions,
possible: {
ignoreFunctions: [_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isRegExp],
ignoreProperties: [(0,_utils_validateObjectWithArrayProps_mjs__WEBPACK_IMPORTED_MODULE_13__["default"])(_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isRegExp)],
ignoreMediaFeatureNames: [(0,_utils_validateObjectWithArrayProps_mjs__WEBPACK_IMPORTED_MODULE_13__["default"])(_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_4__.isRegExp)],
},
},
);
if (!validOptions) {
return;
}
const primaryValues = [primary].flat();
/**
* Ignore wrong units within `url` function
* Ignore units within function that match `ignoreFunctions` option
*
* @param {import('@csstools/css-parser-algorithms').ComponentValue} componentValue
* @returns {boolean}
*/
function componentValueIsIgnored(componentValue) {
if (!(0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.isFunctionNode)(componentValue)) {
return false;
}
const name = componentValue.getName().toLowerCase();
return name === 'url' || (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_10__["default"])(secondaryOptions, 'ignoreFunctions', name);
}
/**
* @template {import('postcss').AtRule | import('postcss').Declaration} T
* @param {T} node
* @param {(node: T) => number} getIndex
* @param {import('@csstools/css-parser-algorithms').ComponentValue} componentValue
* @param {string} input
* @param {Record<string, unknown> | undefined} options
* @returns {void}
*/
function check(node, getIndex, componentValue, input, options) {
if (!(0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.isTokenNode)(componentValue)) return;
if (componentValue.value[0] !== _csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__.TokenType.Dimension) return;
const [, , , endIndex, { unit }] = componentValue.value;
const lowerCaseUnit = unit.toLowerCase();
if (!primaryValues.includes(lowerCaseUnit)) {
return;
}
// The unit has an ignore option for the specific input
if (options && (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_10__["default"])(options, lowerCaseUnit, input)) return;
const startIndex = getIndex(node) + (endIndex + 1) - unit.length;
(0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_11__["default"])({
index: startIndex,
endIndex: startIndex + unit.length,
message: messages.rejected,
messageArgs: [unit],
node,
result,
ruleName,
});
}
root.walkAtRules(_utils_regexes_mjs__WEBPACK_IMPORTED_MODULE_5__.atRuleRegexes.mediaName, (atRule) => {
const params = (0,_utils_getAtRuleParams_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(atRule);
if (!(0,_utils_hasDimension_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(params)) return;
(0,_csstools_media_query_list_parser__WEBPACK_IMPORTED_MODULE_2__.parseFromTokens)(tokenizeWithoutPercentages(params)).forEach((mediaQuery) => {
/** @type {{ mediaFeatureName: string | undefined }} */
const initialState = {
mediaFeatureName: undefined,
};
mediaQuery.walk(({ node, state }) => {
if (!state) return;
if ((0,_csstools_media_query_list_parser__WEBPACK_IMPORTED_MODULE_2__.isMediaFeature)(node)) {
state.mediaFeatureName = node.getName().toLowerCase();
}
if (!state.mediaFeatureName) return;
if (!(0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.isTokenNode)(node)) return;
check(
atRule,
_utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_3__.atRuleParamIndex,
node,
state.mediaFeatureName,
secondaryOptions?.ignoreMediaFeatureNames,
);
}, initialState);
});
});
root.walkDecls((decl) => {
if ((0,_utils_isUnicodeRangeDescriptor_mjs__WEBPACK_IMPORTED_MODULE_9__["default"])(decl)) return;
const value = (0,_utils_getDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(decl);
if (!(0,_utils_hasDimension_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(value)) return;
const initialState = {
ignored: false,
};
(0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.walk)(
(0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.parseListOfComponentValues)(tokenizeWithoutPercentages(value)),
({ node, state }) => {
if (!state) return;
if (state.ignored) return;
if ((0,_csstools_css_parser_algorithms__WEBPACK_IMPORTED_MODULE_1__.isTokenNode)(node)) {
check(decl, _utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_3__.declarationValueIndex, node, decl.prop, secondaryOptions?.ignoreProperties);
return;
}
if (componentValueIsIgnored(node)) {
state.ignored = true;
}
},
initialState,
);
});
};
};
/**
* In the CSS syntax percentages are a different token type than dimensions.
* For CSS authors however this distinction doesn't make sense, so we convert
* percentage tokens to dimension tokens with a unit of "%".
*
* Percentage tokens also aren't valid in media queries.
* Converting percentage tokens to dimension tokens simplifies any code checking for units.
*
* @param {string} css
* @returns {Array<import('@csstools/css-tokenizer').CSSToken>}
*/
function tokenizeWithoutPercentages(css) {
return (0,_csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__.tokenize)({ css }).map((x) => {
if (x[0] !== _csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__.TokenType.Percentage) return x;
return [
_csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__.TokenType.Dimension,
x[1],
x[2],
x[3],
{ value: x[4].value, unit: '%', type: _csstools_css_tokenizer__WEBPACK_IMPORTED_MODULE_0__.NumberType.Number },
];
});
}
rule.primaryOptionArray = true;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule);
/***/ }),
/***/ 1815:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasDimension)
/* harmony export */ });
const HAS_DIMENSION_LIKE_VALUES = /\d[%\w-]/;
/**
* Check if a value contains any dimension-like values.
*
* @param {string} value
* @returns {boolean}
*/
function hasDimension(value) {
return HAS_DIMENSION_LIKE_VALUES.test(value);
}
/***/ }),
/***/ 1816:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isUnicodeRangeDescriptor)
/* harmony export */ });
/* harmony import */ var _typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(886);
const IS_UNICODE_RANGE = /^unicode-range$/i;
const IS_AT_FONT_FACE = /^font-face$/i;
/**
* Check whether a declaration is the `unicode-range` descriptor of an `@font-face` rule.
*
* @param {import('postcss').Declaration} decl
* @returns {boolean}
*/
function isUnicodeRangeDescriptor(decl) {
if (!IS_UNICODE_RANGE.test(decl.prop)) {
return false;
}
const parent = decl.parent;
if (!parent || !(0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isAtRule)(parent)) {
return false;
}
return IS_AT_FONT_FACE.test(parent.name);
}
/***/ })
};
;
//# sourceMappingURL=88.extension.js.map