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.
377 lines (291 loc) • 10.8 kB
JavaScript
exports.id = 93;
exports.ids = [93];
exports.modules = {
/***/ 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);
}
/***/ }),
/***/ 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;
}
/***/ }),
/***/ 1568:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isStandardSyntaxRule)
/* harmony export */ });
/* harmony import */ var _isStandardSyntaxSelector_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1569);
/**
* Check whether a Node is a standard rule
*
* @param {import('postcss').Rule | import('postcss-less').Rule} rule
* @returns {boolean}
*/
function isStandardSyntaxRule(rule) {
if (rule.type !== 'rule') {
return false;
}
// Ignore Less &:extend rule
if ('extend' in rule && rule.extend) {
return false;
}
if (!(0,_isStandardSyntaxSelector_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(rule.selector)) {
return false;
}
return true;
}
/***/ }),
/***/ 1569:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ isStandardSyntaxSelector)
/* harmony export */ });
/* harmony import */ var _hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1524);
/**
* Check whether a selector is standard
*
* @param {string} selector
* @returns {boolean}
*/
function isStandardSyntaxSelector(selector) {
// SCSS or Less interpolation
if ((0,_hasInterpolation_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(selector)) {
return false;
}
// SCSS placeholder selectors
if (selector.startsWith('%')) {
return false;
}
// SCSS nested properties
if (selector.endsWith(':')) {
return false;
}
// Less :extend()
if (/:extend(?:\(.*?\))?/.test(selector)) {
return false;
}
// Less mixin with resolved nested selectors (e.g. .foo().bar or .foo(@a, @b)[bar])
if (/\.[\w-]+\(.*\).+/.test(selector)) {
return false;
}
// Less non-outputting mixin definition (e.g. .mixin() {})
if (selector.endsWith(')') && !selector.includes(':')) {
return false;
}
// Less Parametric mixins (e.g. .mixin(@variable: x) {})
if (/\(@.*\)$/.test(selector)) {
return false;
}
// ERB template tags
if (selector.includes('<%') || selector.includes('%>')) {
return false;
}
// SCSS and Less comments
if (selector.includes('//')) {
return false;
}
return true;
}
/***/ }),
/***/ 1742:
/***/ ((__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_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(579);
/* harmony import */ var _utils_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(886);
/* harmony import */ var _utils_isStandardSyntaxAtRule_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1532);
/* harmony import */ var _utils_isStandardSyntaxRule_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1568);
/* harmony import */ var _utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(869);
/* 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 = 'no-invalid-position-at-import-rule';
const messages = (0,_utils_ruleMessages_mjs__WEBPACK_IMPORTED_MODULE_6__["default"])(ruleName, {
rejected: 'Unexpected invalid position @import rule',
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/no-invalid-position-at-import-rule',
};
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary, secondaryOptions) => {
return (root, result) => {
const validOptions = (0,_utils_validateOptions_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])(
result,
ruleName,
{ actual: primary },
{
actual: secondaryOptions,
possible: {
ignoreAtRules: [_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isString, _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isRegExp],
},
optional: true,
},
);
if (!validOptions) {
return;
}
let invalidPosition = false;
root.walk((node) => {
const nodeName = ('name' in node && node.name && node.name.toLowerCase()) || '';
if (
((0,_utils_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_1__.isAtRule)(node) &&
nodeName !== 'charset' &&
nodeName !== 'import' &&
nodeName !== 'layer' &&
!(0,_utils_optionsMatches_mjs__WEBPACK_IMPORTED_MODULE_4__["default"])(secondaryOptions, 'ignoreAtRules', node.name) &&
(0,_utils_isStandardSyntaxAtRule_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])(node)) ||
(node.type === 'rule' && (0,_utils_isStandardSyntaxRule_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(node))
) {
invalidPosition = true;
return;
}
if ((0,_utils_typeGuards_mjs__WEBPACK_IMPORTED_MODULE_1__.isAtRule)(node) && nodeName === 'import' && invalidPosition) {
(0,_utils_report_mjs__WEBPACK_IMPORTED_MODULE_5__["default"])({
message: messages.rejected,
messageArgs: [],
node,
result,
ruleName,
word: node.toString(),
});
}
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (rule);
/***/ })
};
;
//# sourceMappingURL=93.extension.js.map
;