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.
724 lines (556 loc) • 20.3 kB
JavaScript
exports.id = 33;
exports.ids = [33];
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;
}
/***/ }),
/***/ 1523:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isStandardSyntaxValue)
/* harmony export */ });
/* harmony import */ var _hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1524);
/**
* Check whether a value is standard
*
* @param {string} value
* @returns {boolean}
*/
function isStandardSyntaxValue(value) {
let normalizedValue = value;
// Ignore operators before variables (example -$variable)
if (/^[-+*/]/.test(value.charAt(0))) {
normalizedValue = normalizedValue.slice(1);
}
// SCSS variable (example $variable)
// styled component interpolation (example ${foo => foo.bar})
if (normalizedValue.startsWith('$')) {
return false;
}
// SCSS namespace (example namespace.$variable)
if (/^.+\.\$/.test(value)) {
return false;
}
// SCSS namespace (example namespace.function-name())
if (/^.+\.[-\w]+\(/.test(value)) {
return false;
}
// Less variable
if (normalizedValue.startsWith('@')) {
return false;
}
// SCSS or Less interpolation
if ((0,_hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(normalizedValue)) {
return false;
}
// WebExtension replacement keyword used by Chrome/Firefox
// more information: https://developer.chrome.com/extensions/i18n
// and https://github.com/stylelint/stylelint/issues/4707
if (/__MSG_\S+__/.test(value)) {
return false;
}
return true;
}
/***/ }),
/***/ 1524:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasInterpolation)
/* harmony export */ });
/* harmony import */ var _hasLessInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1525);
/* harmony import */ var _hasPsvInterpolation_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1526);
/* harmony import */ var _hasScssInterpolation_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1527);
/* harmony import */ var _hasTplInterpolation_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1528);
/**
* Check whether a string has interpolation
*
* @param {string} string
* @returns {boolean} If `true`, a string has interpolation
*/
function hasInterpolation(string) {
// SCSS or Less interpolation
if (
(0,_hasLessInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(string) ||
(0,_hasScssInterpolation_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(string) ||
(0,_hasTplInterpolation_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(string) ||
(0,_hasPsvInterpolation_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(string)
) {
return true;
}
return false;
}
/***/ }),
/***/ 1525:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasLessInterpolation)
/* harmony export */ });
const HAS_LESS_INTERPOLATION = /@\{.+?\}/;
/**
* Check whether a string has less interpolation
*
* @param {string} string
* @returns {boolean} If `true`, a string has less interpolation
*/
function hasLessInterpolation(string) {
return HAS_LESS_INTERPOLATION.test(string);
}
/***/ }),
/***/ 1526:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasPsvInterpolation)
/* harmony export */ });
const HAS_PSV_INTERPOLATION = /\$\(.+?\)/;
/**
* Check whether a string has postcss-simple-vars interpolation
*
* @param {string} string
* @returns {boolean}
*/
function hasPsvInterpolation(string) {
return HAS_PSV_INTERPOLATION.test(string);
}
/***/ }),
/***/ 1527:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasScssInterpolation)
/* harmony export */ });
const HAS_SCSS_INTERPOLATION = /#\{.+?\}/s;
/**
* Check whether a string has scss interpolation
*
* @param {string} string
* @returns {boolean}
*/
function hasScssInterpolation(string) {
return HAS_SCSS_INTERPOLATION.test(string);
}
/***/ }),
/***/ 1528:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ hasTplInterpolation)
/* harmony export */ });
const HAS_TPL_INTERPOLATION = /\{.+?\}/s;
/**
* Check whether a string has JS template literal interpolation or HTML-like template
*
* @param {string} string
* @returns {boolean} If `true`, a string has template literal interpolation
*/
function hasTplInterpolation(string) {
return HAS_TPL_INTERPOLATION.test(string);
}
/***/ }),
/***/ 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+-/, '');
},
});
/***/ }),
/***/ 1649:
/***/ ((__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_functionArgumentsSearch_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1650);
/* harmony import */ var _utils_isStandardSyntaxValue_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1523);
/* 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_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(873);
/* harmony import */ var _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1533);
const ruleName = 'function-linear-gradient-no-nonstandard-direction';
const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])(ruleName, {
rejected: 'Unexpected nonstandard direction',
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/function-linear-gradient-no-nonstandard-direction',
};
const LINEAR_GRADIENT_FUNCTION = '(?:-webkit-|-moz-|-o-|-ms-)?linear-gradient';
const LINEAR_GRADIENT_FUNCTION_CALL = new RegExp(`${LINEAR_GRADIENT_FUNCTION}\\(`, 'i');
const LINEAR_GRADIENT_FUNCTION_NAME = new RegExp(`^${LINEAR_GRADIENT_FUNCTION}$`, 'i');
const DIRECTION = /top|left|bottom|right/i;
const DIRECTION_WITH_TO = new RegExp(`^to (${DIRECTION.source})(?: (${DIRECTION.source}))?$`, 'i');
const DIRECTION_WITHOUT_TO = new RegExp(`^(${DIRECTION.source})(?: (${DIRECTION.source}))?$`, 'i');
const DIGIT = /[\d.]/;
const ANGLE = /^[\d.]+(?:deg|grad|rad|turn)$/;
const IN_KEYWORD = /\bin\b/i;
/**
* @param {string} source
* @param {boolean} withToPrefix
*/
function isStandardDirection(source, withToPrefix) {
const regexp = withToPrefix ? DIRECTION_WITH_TO : DIRECTION_WITHOUT_TO;
const matches = source.match(regexp);
if (!matches) {
return false;
}
if (matches.length === 2) {
return true;
}
// Cannot repeat side-or-corner, e.g. "to top top"
if (matches.length === 3 && matches[1] !== matches[2]) {
return true;
}
return false;
}
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary) => {
return (root, result) => {
const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(result, ruleName, { actual: primary });
if (!validOptions) {
return;
}
root.walkDecls((decl) => {
if (!LINEAR_GRADIENT_FUNCTION_CALL.test(decl.value)) return;
postcss_value_parser__WEBPACK_IMPORTED_MODULE_0__(decl.value).walk((valueNode) => {
if (valueNode.type !== 'function') {
return;
}
(0,_utils_functionArgumentsSearch_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(
postcss_value_parser__WEBPACK_IMPORTED_MODULE_0__.stringify(valueNode).toLowerCase(),
LINEAR_GRADIENT_FUNCTION_NAME,
(expression, expressionIndex) => {
const args = expression.split(',');
const firstArg = (args[0] || '').trim();
// If the first arg is not standard, return early
if (!(0,_utils_isStandardSyntaxValue_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(firstArg)) {
return;
}
// Skip direction validation for CSS variables
if (firstArg.startsWith('var(')) {
return;
}
// Ignore gradients with modern syntax that have color space interpolation arguments
if (IN_KEYWORD.test(firstArg)) {
return;
}
// If the first character is a number, we can assume the user intends an angle
if (DIGIT.test(firstArg.charAt(0))) {
if (ANGLE.test(firstArg)) {
return;
}
complain();
return;
}
// The first argument may not be a direction: it may be an angle,
// or a color stop (in which case user gets default direction, "to bottom")
// cf. https://drafts.csswg.org/css-images-3/#linear-gradient-syntax
if (!DIRECTION.test(firstArg)) {
return;
}
const withToPrefix = !_utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_7__["default"].prefix(valueNode.value);
if (!isStandardDirection(firstArg, withToPrefix)) {
complain();
}
function complain() {
const index = (0,_utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__.declarationValueIndex)(decl) + valueNode.sourceIndex + expressionIndex;
const endIndex = index + (args[0] || '').trimEnd().length;
(0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])({
message: messages.rejected,
messageArgs: [],
node: decl,
index,
endIndex,
result,
ruleName,
});
}
},
);
});
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule);
/***/ }),
/***/ 1650:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ functionArgumentsSearch)
/* harmony export */ });
/* harmony import */ var balanced_match__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1651);
/* harmony import */ var postcss_value_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1514);
/* harmony import */ var _validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(579);
/** @typedef {(expression: string, expressionIndex: number, funcNode: valueParser.FunctionNode, parsedValue: valueParser.ParsedValue) => void} Callback */
/**
* Search a CSS string for functions by name.
* For every match, invoke the callback, passing the function's
* "argument(s) string" (whatever is inside the parentheses)
* as an argument.
*
* Callback will be called once for every matching function found,
* with the function's "argument(s) string" and its starting index
* as the arguments.
*
* @param {string} source
* @param {string | RegExp} functionName
* @param {Callback} callback
* @returns {valueParser.ParsedValue}
*/
function functionArgumentsSearch(source, functionName, callback) {
const parsedValue = postcss_value_parser__WEBPACK_IMPORTED_MODULE_1__(source);
return parsedValue.walk((node) => {
if (node.type !== 'function') return;
const { value } = node;
if ((0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__.isString)(functionName) && value !== functionName) return;
if ((0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__.isRegExp)(functionName) && !functionName.test(node.value)) return;
const parensMatch = balanced_match__WEBPACK_IMPORTED_MODULE_0__('(', ')', source.slice(node.sourceIndex));
(0,_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_2__.assert)(parensMatch);
const expression = parensMatch.body;
const parenLength = 1; // == '('
const expressionIndex = node.sourceIndex + value.length + parenLength;
callback(expression, expressionIndex, node, parsedValue);
});
}
/***/ }),
/***/ 1651:
/***/ ((module) => {
module.exports = balanced
function balanced (a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str)
if (b instanceof RegExp) b = maybeMatch(b, str)
const r = range(a, b, str)
return (
r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
}
)
}
function maybeMatch (reg, str) {
const m = str.match(reg)
return m ? m[0] : null
}
balanced.range = range
function range (a, b, str) {
let begs, beg, left, right, result
let ai = str.indexOf(a)
let bi = str.indexOf(b, ai + 1)
let i = ai
if (ai >= 0 && bi > 0) {
if (a === b) {
return [ai, bi]
}
begs = []
left = str.length
while (i >= 0 && !result) {
if (i === ai) {
begs.push(i)
ai = str.indexOf(a, i + 1)
} else if (begs.length === 1) {
result = [begs.pop(), bi]
} else {
beg = begs.pop()
if (beg < left) {
left = beg
right = bi
}
bi = str.indexOf(b, i + 1)
}
i = ai < bi && ai >= 0 ? ai : bi
}
if (begs.length) {
result = [left, right]
}
}
return result
}
/***/ })
};
;
//# sourceMappingURL=33.extension.js.map
;