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.
321 lines (246 loc) • 9.44 kB
JavaScript
exports.id = 106;
exports.ids = [106];
exports.modules = {
/***/ 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;
}
/***/ }),
/***/ 1539:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isStandardSyntaxDeclaration)
/* harmony export */ });
/* harmony import */ var _typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(886);
/* harmony import */ var _isScssVariable_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1540);
/**
* Check whether a declaration is standard
*
* @param {import('postcss').Declaration | import('postcss-less').Declaration} decl
* @returns {boolean}
*/
function isStandardSyntaxDeclaration(decl) {
const prop = decl.prop;
const parent = decl.parent;
// SCSS var; covers map and list declarations
if ((0,_isScssVariable_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(prop)) {
return false;
}
// Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
if (prop[0] === '@' && prop[1] !== '{') {
return false;
}
// Less map declaration
if (parent && parent.type === 'atrule' && parent.raws.afterName === ':') {
return false;
}
// Less map (e.g. #my-map() { myprop: red; })
if (
parent &&
(0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isRule)(parent) &&
parent.selector &&
parent.selector.startsWith('#') &&
parent.selector.endsWith('()')
) {
return false;
}
// Sass nested properties (e.g. border: { style: solid; color: red; })
if (
parent &&
(0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isRule)(parent) &&
parent.selector &&
parent.selector[parent.selector.length - 1] === ':' &&
parent.selector.substring(0, 2) !== '--'
) {
return false;
}
// Less &:extend
if ('extend' in decl && decl.extend) {
return false;
}
return true;
}
/***/ }),
/***/ 1540:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isScssVariable)
/* harmony export */ });
/**
* Check whether a property is SCSS variable
*
* @param {string} property
* @returns {boolean}
*/
function isScssVariable(property) {
// SCSS var (e.g. $var: x), list (e.g. $list: (x)) or map (e.g. $map: (key:value))
if (property.startsWith('$')) {
return true;
}
// SCSS var within a namespace (e.g. namespace.$var: x)
if (property.includes('.$')) {
return true;
}
return false;
}
/***/ }),
/***/ 1611:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isStandardSyntaxProperty)
/* harmony export */ });
/* harmony import */ var _hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1524);
/* harmony import */ var _isScssVariable_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1540);
/**
* Check whether a property is standard
*
* @param {string} property
* @returns {boolean}
*/
function isStandardSyntaxProperty(property) {
// SCSS var
if ((0,_isScssVariable_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(property)) {
return false;
}
// Less var (e.g. @var: x)
if (property.startsWith('@')) {
return false;
}
// Less append property value with space (e.g. transform+_: scale(2))
if (property.endsWith('+') || property.endsWith('+_')) {
return false;
}
// SCSS or Less interpolation
if ((0,_hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(property)) {
return false;
}
return true;
}
/***/ }),
/***/ 1821:
/***/ ((__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_hasPrefix_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1796);
/* harmony import */ var _utils_isAutoprefixable_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1560);
/* harmony import */ var _utils_isStandardSyntaxDeclaration_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1539);
/* harmony import */ var _utils_isStandardSyntaxProperty_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1611);
/* harmony import */ var _utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(869);
/* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(945);
/* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(950);
/* harmony import */ var _utils_setDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1529);
/* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(873);
/* harmony import */ var _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1533);
/* harmony import */ var _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(579);
const ruleName = 'value-no-vendor-prefix';
const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(ruleName, {
rejected: (value) => `Unexpected vendor-prefixed value "${value}"`,
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/value-no-vendor-prefix',
fixable: true,
};
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary, secondaryOptions) => {
return (root, result) => {
const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_9__["default"])(
result,
ruleName,
{ actual: primary },
{
optional: true,
actual: secondaryOptions,
possible: {
ignoreValues: [_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_11__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_11__.isRegExp],
},
},
);
if (!validOptions) {
return;
}
/**
* @typedef {string | RegExp} IgnoreValue
* @type {{ raw: IgnoreValue[], unprefixed: IgnoreValue[] }}
* @todo use Object.groupBy once Node v20 support is dropped
*/
const groups = { raw: [], unprefixed: [] };
[secondaryOptions?.ignoreValues ?? []].flat().forEach((value) => {
const useRawValue = (0,_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_11__.isRegExp)(value) || (value.startsWith('/') && value.match(/\/i?$/));
const group = useRawValue ? 'raw' : 'unprefixed';
groups[group].push(value);
});
root.walkDecls((decl) => {
const { value } = decl;
if (!(0,_utils_hasPrefix_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(value)) return;
if (!(0,_utils_isStandardSyntaxDeclaration_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(decl) || !(0,_utils_isStandardSyntaxProperty_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(decl.prop)) {
return;
}
if ((0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])(groups, 'raw', value)) {
return;
}
/**
* @todo consolidate in the next major
* @see stylelint/stylelint#7542
*/
if ((0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])(groups, 'unprefixed', _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_10__["default"].unprefixed(value))) {
return;
}
const parsedValue = postcss_value_parser__WEBPACK_IMPORTED_MODULE_0__(value);
parsedValue.walk((node) => {
if (!_utils_isAutoprefixable_mjs__WEBPACK_IMPORTED_MODULE_2__["default"].propertyValue(node.value)) {
return;
}
const index = decl.prop.length + (decl.raws.between || '').length + node.sourceIndex;
const fix = () => {
node.value = _utils_isAutoprefixable_mjs__WEBPACK_IMPORTED_MODULE_2__["default"].unprefix(node.value);
(0,_utils_setDeclarationValue_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(decl, parsedValue.toString());
};
(0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])({
message: messages.rejected,
messageArgs: [node.value],
node: decl,
index,
endIndex: index + node.value.length,
result,
ruleName,
fix: {
apply: fix,
node: decl,
},
});
});
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule);
/***/ })
};
;
//# sourceMappingURL=106.extension.js.map
;