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.

598 lines (473 loc) 16.4 kB
"use strict"; exports.id = 45; exports.ids = [45]; 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; } /***/ }), /***/ 1532: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ isStandardSyntaxAtRule) /* harmony export */ }); /** * Check whether a at-rule is standard * * @param {import('postcss').AtRule | import('postcss-less').AtRule} atRule postcss at-rule node * @returns {boolean} If `true`, the declaration is standard */ function isStandardSyntaxAtRule(atRule) { // Ignore `@charset` css rule (is parsed as at-rule) if (atRule.name.toLowerCase() === 'charset') { return false; } // Ignore scss `@content` inside mixins if (!atRule.nodes && atRule.params === '') { return false; } // Ignore Less mixins if ('mixin' in atRule && atRule.mixin) { return false; } // Ignore Less detached ruleset `@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }` if ( ('variable' in atRule && atRule.variable) || (!atRule.nodes && atRule.raws.afterName === '' && atRule.params[0] === '(') ) { return false; } return true; } /***/ }), /***/ 1535: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ atRuleRegexes: () => (/* binding */ atRuleRegexes), /* harmony export */ descriptorRegexes: () => (/* binding */ descriptorRegexes), /* harmony export */ functionRegexes: () => (/* binding */ functionRegexes), /* harmony export */ propertyRegexes: () => (/* binding */ propertyRegexes) /* harmony export */ }); /* harmony import */ var _reference_atKeywords_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1536); const atRuleRegexes = { mediaName: /^media$/i, keyframesName: /^(-(o|moz|ms|webkit)-)?keyframes$/i, propertyName: /^property$/i, importName: /^import$/i, unsupportedNestingNames: new RegExp( `^((?!${[..._reference_atKeywords_mjs__WEBPACK_IMPORTED_MODULE_0__.nestingSupportedAtKeywords.values()].join('|')}).)*$`, 'i', ), layerName: /^layer$/i, containerName: /^container$/i, scopeName: /^scope$/i, }; const descriptorRegexes = { syntaxName: /^syntax$/i, }; const functionRegexes = { layer: /layer\((.*?)\)/i, }; const propertyRegexes = { containerNameAndShorthandName: /^container(-name)?$/i, }; /***/ }), /***/ 1536: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ atKeywords: () => (/* binding */ atKeywords), /* harmony export */ deprecatedAtKeywords: () => (/* binding */ deprecatedAtKeywords), /* harmony export */ nestingSupportedAtKeywords: () => (/* binding */ nestingSupportedAtKeywords), /* harmony export */ pageMarginAtKeywords: () => (/* binding */ pageMarginAtKeywords) /* harmony export */ }); /* harmony import */ var _utils_uniteSets_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1537); /** @type {ReadonlySet<string>} */ const deprecatedAtKeywords = new Set(['document', 'nest', 'viewport']); /** * @see https://www.w3.org/TR/css-nesting-1/#conditionals * @type {ReadonlySet<string>} */ const nestingSupportedAtKeywords = new Set([ 'apply', 'container', 'layer', 'media', 'scope', 'starting-style', 'supports', ]); /** * @see https://www.w3.org/TR/css-page-3/#syntax-page-selector * @type {ReadonlySet<string>} */ const pageMarginAtKeywords = new Set([ 'top-left-corner', 'top-left', 'top-center', 'top-right', 'top-right-corner', 'bottom-left-corner', 'bottom-left', 'bottom-center', 'bottom-right', 'bottom-right-corner', 'left-top', 'left-middle', 'left-bottom', 'right-top', 'right-middle', 'right-bottom', ]); /** * @see https://www.w3.org/TR/css-fonts-4/#font-feature-values-font-feature-value-type * @type {ReadonlySet<string>} */ const fontFeatureValueTypes = new Set([ 'annotation', 'character-variant', 'historical-forms', 'ornaments', 'styleset', 'stylistic', 'swash', ]); /** * @see https://developer.mozilla.org/en/docs/Web/CSS/At-rule * @type {ReadonlySet<string>} */ const atKeywords = (0,_utils_uniteSets_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])( deprecatedAtKeywords, nestingSupportedAtKeywords, pageMarginAtKeywords, fontFeatureValueTypes, [ 'counter-style', 'custom-media', 'custom-selector', 'font-face', 'font-feature-values', 'font-palette-values', 'import', 'keyframes', 'namespace', 'page', 'position-try', 'property', 'scroll-timeline', 'view-transition', ], ); /***/ }), /***/ 1537: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ uniteSets) /* harmony export */ }); /** * Unite two or more sets * * @param {Iterable<string>[]} args * @see {@link https://github.com/microsoft/TypeScript/issues/57228|GitHub} */ function uniteSets(...args) { return new Set([...args].reduce((result, set) => [...result, ...set], [])); } /***/ }), /***/ 1538: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ getLexer) /* harmony export */ }); /** * @typedef {import('css-tree').Lexer} Lexer */ /** * @param {import('stylelint').RuleContext} context * @returns {Lexer} */ function getLexer(context) { if (!context?.lexer) { throw new Error('Expected a "lexer" object'); } return /** @type Lexer */ (context.lexer); } /***/ }), /***/ 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; } /***/ }), /***/ 1541: /***/ ((__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_regexes_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1535); /* harmony import */ var _utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1519); /* harmony import */ var _utils_getLexer_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1538); /* harmony import */ var _utils_isStandardSyntaxAtRule_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1532); /* harmony import */ var _utils_isStandardSyntaxDeclaration_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1539); /* harmony import */ var _utils_report_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(945); /* harmony import */ var _utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(950); /* harmony import */ var _utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(873); const ruleName = 'at-rule-descriptor-value-no-unknown'; const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(ruleName, { rejected: (descriptor, value) => `Unexpected unknown value "${value}" for descriptor "${descriptor}"`, }); const meta = { url: 'https://stylelint.io/user-guide/rules/at-rule-descriptor-value-no-unknown', }; /** @type {import('stylelint').CoreRules[ruleName]} */ const rule = (primary, _, context) => { return (root, result) => { const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(result, ruleName, { actual: primary }); if (!validOptions) { return; } root.walkAtRules(_utils_regexes_mjs__WEBPACK_IMPORTED_MODULE_0__.atRuleRegexes.unsupportedNestingNames, (atRule) => { if (!(0,_utils_isStandardSyntaxAtRule_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(atRule)) return; atRule.walkDecls((decl) => { if (!(0,_utils_isStandardSyntaxDeclaration_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(decl)) return; const { prop, value } = decl; const lexer = (0,_utils_getLexer_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(context); const { error } = lexer.matchAtruleDescriptor(atRule.name, prop, value); if (!error) return; if (error.name !== 'SyntaxMatchError') return; const index = (0,_utils_nodeFieldIndices_mjs__WEBPACK_IMPORTED_MODULE_1__.declarationValueIndex)(decl); const endIndex = index + value.length; (0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])({ message: messages.rejected, messageArgs: [prop, value], node: decl, index, endIndex, ruleName, result, }); }); }); }; }; rule.ruleName = ruleName; rule.messages = messages; rule.meta = meta; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule); /***/ }) }; ; //# sourceMappingURL=45.extension.js.map