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.

742 lines (587 loc) 22.1 kB
"use strict"; exports.id = 90; exports.ids = [90]; exports.modules = { /***/ 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+-/, ''); }, }); /***/ }), /***/ 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; } /***/ }), /***/ 1607: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ isCustomProperty) /* harmony export */ }); /** * Check whether a property is a custom one * @param {string} property * @returns {boolean} */ function isCustomProperty(property) { return property.startsWith('--'); } /***/ }), /***/ 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; } /***/ }), /***/ 1613: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ eachDeclarationBlock) /* harmony export */ }); /* harmony import */ var _typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(886); /** @typedef {import('postcss').Root} Root */ /** @typedef {import('postcss').Root} Document */ /** @typedef {import('postcss').Node} PostcssNode */ /** @typedef {import('postcss').Container} PostcssContainerNode */ /** @typedef {import('postcss').Declaration} Declaration */ /** @typedef {(callbackFn: (decl: Declaration, index: number, decls: Declaration[]) => void) => void} EachDeclaration */ /** * @param {PostcssNode} node * @returns {node is PostcssContainerNode} */ function isContainerNode(node) { return (0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isRule)(node) || (0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isAtRule)(node) || (0,_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_0__.isRoot)(node); } /** * In order to accommodate nested blocks (postcss-nested), * we need to run a shallow loop (instead of eachDecl() or eachRule(), * which loop recursively) and allow each nested block to accumulate * its own list of properties -- so that a property in a nested rule * does not conflict with the same property in the parent rule * executes a provided function once for each declaration block. * * @param {Root | Document} root - root element of file. * @param {(eachDecl: EachDeclaration) => void} callback - Function to execute for each declaration block * * @returns {void} */ function eachDeclarationBlock(root, callback) { /** * @param {PostcssNode} statement * * @returns {void} */ function each(statement) { if (!isContainerNode(statement)) return; if (statement.nodes && statement.nodes.length) { /** @type {Declaration[]} */ const decls = []; for (const node of statement.nodes) { if (node.type === 'decl') { decls.push(node); } each(node); } if (decls.length) { callback(decls.forEach.bind(decls)); } } } each(root); } /***/ }), /***/ 1614: /***/ ((__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 css_tree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(581); /* harmony import */ var _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(579); /* harmony import */ var _reference_properties_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(832); /* harmony import */ var _utils_eachDeclarationBlock_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1613); /* harmony import */ var _utils_isCustomProperty_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1607); /* harmony import */ var _utils_isStandardSyntaxProperty_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); /* harmony import */ var _utils_isStandardSyntaxValue_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1523); /* harmony import */ var _reference_keywords_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1591); /* harmony import */ var _utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(869); /* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(945); /* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(950); /* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(873); /* harmony import */ var _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1533); const ruleName = 'declaration-block-no-duplicate-properties'; const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_10__["default"])(ruleName, { rejected: (property) => `Unexpected duplicate "${property}"`, }); const meta = { url: 'https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties', fixable: true, }; /** @typedef {import('css-tree').CssNode} CssNode */ /** @typedef {import('postcss').Declaration} Declaration */ /** @type {(node: CssNode) => node is CssNode & { children: import('css-tree').List<CssNode> }} */ const hasChildren = (node) => 'children' in node && node.children instanceof css_tree__WEBPACK_IMPORTED_MODULE_0__.List; /** @type {(node1: CssNode[], node2: CssNode[], property: string) => boolean} */ const isEqualValueNodes = (nodes1, nodes2, property) => { // Different lengths indicate different syntaxes. if (nodes1.length !== nodes2.length) { return false; } for (let i = 0; i < nodes1.length; i++) { const node1 = nodes1[i]; const node2 = nodes2[i]; // Different types indicate different syntaxes. if (typeof node1 === 'undefined' || typeof node2 === 'undefined' || node1.type !== node2.type) { return false; } const node1Name = 'name' in node1 ? String(node1.name) : ''; const node2Name = 'name' in node2 ? String(node2.name) : ''; // Custom properties have unknown value syntaxes but are equal for CSS parsers. if ( node1.type === 'Identifier' && (0,_utils_isCustomProperty_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(node1Name) && node2.type === 'Identifier' && (0,_utils_isCustomProperty_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(node2Name) ) { continue; } // Named colors have the same syntax even if the names differ // This applies only to color properties (both single and multi-value) if ( node1.type === 'Identifier' && node2.type === 'Identifier' && _reference_properties_mjs__WEBPACK_IMPORTED_MODULE_2__.colorProperties.has(property.toLowerCase()) && _reference_keywords_mjs__WEBPACK_IMPORTED_MODULE_7__.namedColorsKeywords.has(node1Name.toLowerCase()) && _reference_keywords_mjs__WEBPACK_IMPORTED_MODULE_7__.namedColorsKeywords.has(node2Name.toLowerCase()) ) { continue; } // Different ident or function names indicate different syntaxes. if (node1Name.toLowerCase() !== node2Name.toLowerCase()) { return false; } const node1Unit = 'unit' in node1 ? node1.unit : ''; const node2Unit = 'unit' in node2 ? node2.unit : ''; // Different units indicate different syntaxes. if (node1Unit !== node2Unit) { return false; } const node1Children = hasChildren(node1) ? node1.children.toArray() : null; const node2Children = hasChildren(node2) ? node2.children.toArray() : null; if (Array.isArray(node1Children) && Array.isArray(node2Children)) { if (isEqualValueNodes(node1Children, node2Children, property)) { continue; } else { return false; } } } return true; }; /** @type {(value1: string, value2: string, property: string) => boolean} */ const isEqualValueSyntaxes = (value1, value2, property) => { if (value1 === value2) { return true; } if (!((0,_utils_isStandardSyntaxValue_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(value1) && (0,_utils_isStandardSyntaxValue_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(value2))) { return false; } let value1Node; let value2Node; try { value1Node = (0,css_tree__WEBPACK_IMPORTED_MODULE_0__.parse)(value1, { context: 'value' }); value2Node = (0,css_tree__WEBPACK_IMPORTED_MODULE_0__.parse)(value2, { context: 'value' }); } catch { return false; } const node1Children = hasChildren(value1Node) ? value1Node.children.toArray() : []; const node2Children = hasChildren(value2Node) ? value2Node.children.toArray() : []; return isEqualValueNodes(node1Children, node2Children, property); }; /** @type {import('stylelint').CoreRules[ruleName]} */ const rule = (primary, secondaryOptions) => { return (root, result) => { const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_11__["default"])( result, ruleName, { actual: primary }, { actual: secondaryOptions, possible: { ignore: [ 'consecutive-duplicates', 'consecutive-duplicates-with-different-values', 'consecutive-duplicates-with-different-syntaxes', 'consecutive-duplicates-with-same-prefixless-values', ], ignoreProperties: [_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_1__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_1__.isRegExp], }, optional: true, }, ); if (!validOptions) { return; } const ignoreDuplicates = (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(secondaryOptions, 'ignore', 'consecutive-duplicates'); const ignoreDiffValues = (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])( secondaryOptions, 'ignore', 'consecutive-duplicates-with-different-values', ); const ignoreDiffSyntaxes = (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])( secondaryOptions, 'ignore', 'consecutive-duplicates-with-different-syntaxes', ); const ignorePrefixlessSameValues = (0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])( secondaryOptions, 'ignore', 'consecutive-duplicates-with-same-prefixless-values', ); /** @param {Declaration} node */ const fixer = (node) => () => { node.remove(); }; (0,_utils_eachDeclarationBlock_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(root, (eachDecl) => { /** @type {Declaration[]} */ const decls = []; eachDecl((decl) => { const prop = decl.prop; const lowerProp = decl.prop.toLowerCase(); const value = decl.value; const important = decl.important; if (!(0,_utils_isStandardSyntaxProperty_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])(prop)) { return; } if ((0,_utils_isCustomProperty_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(prop)) { return; } // Return early if the property is to be ignored if ((0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(secondaryOptions, 'ignoreProperties', prop)) { return; } // Ignore the src property as commonly duplicated in at-fontface if (lowerProp === 'src') { return; } const indexDuplicate = decls.findIndex((d) => d.prop.toLowerCase() === lowerProp); if (indexDuplicate === -1) { decls.push(decl); } const duplicateDecl = decls[indexDuplicate]; if (!duplicateDecl) { return; } const duplicateValue = duplicateDecl.value || ''; const duplicateImportant = duplicateDecl.important || false; const duplicateIsMoreImportant = !important && duplicateImportant; const duplicatesAreConsecutive = indexDuplicate === decls.length - 1; const unprefixedDuplicatesAreEqual = _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_12__["default"].unprefixed(value) === _utils_vendor_mjs__WEBPACK_IMPORTED_MODULE_12__["default"].unprefixed(duplicateValue); const fixOrReport = () => { const node = duplicateIsMoreImportant ? decl : duplicateDecl; const word = duplicateIsMoreImportant ? prop : duplicateDecl.prop; if (!duplicateIsMoreImportant) { // replace previous "active" decl with current one decls[indexDuplicate] = decl; } (0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_9__["default"])({ message: messages.rejected, messageArgs: [word], node, result, ruleName, word, fix: { apply: fixer(node), node: node.parent, }, }); }; if (ignoreDiffValues || ignoreDiffSyntaxes || ignorePrefixlessSameValues) { if ( !duplicatesAreConsecutive || (ignorePrefixlessSameValues && !unprefixedDuplicatesAreEqual) ) { fixOrReport(); return; } if (ignoreDiffSyntaxes) { const duplicateValueSyntaxesAreEqual = isEqualValueSyntaxes( value, duplicateValue, prop, ); if (duplicateValueSyntaxesAreEqual) { fixOrReport(); return; } } if (value !== duplicateValue) { return; } return (0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_9__["default"])({ message: messages.rejected, messageArgs: [duplicateDecl.prop], node: duplicateDecl, result, ruleName, word: duplicateDecl.prop, fix: { apply: fixer(duplicateDecl), node: duplicateDecl.parent, }, }); } if (ignoreDuplicates && duplicatesAreConsecutive) { return; } fixOrReport(); }); }); }; }; rule.ruleName = ruleName; rule.messages = messages; rule.meta = meta; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule); /***/ }) }; ; //# sourceMappingURL=90.extension.js.map