mirror of
https://gh.wpcy.net/https://github.com/djav1985/v-wordpress-plugin-updater.git
synced 2026-05-01 11:12:18 +08:00
72 lines
2 KiB
JavaScript
72 lines
2 KiB
JavaScript
// NOTICE: This file is generated by Rollup. To modify it,
|
|
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
|
|
'use strict';
|
|
|
|
const typeGuards = require('../../utils/typeGuards.cjs');
|
|
const findNodeUpToRoot = require('../../utils/findNodeUpToRoot.cjs');
|
|
const isInDocument = require('../../utils/isInDocument.cjs');
|
|
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration.cjs');
|
|
const atKeywords = require('../../reference/atKeywords.cjs');
|
|
const report = require('../../utils/report.cjs');
|
|
const ruleMessages = require('../../utils/ruleMessages.cjs');
|
|
const validateOptions = require('../../utils/validateOptions.cjs');
|
|
|
|
const ruleName = 'no-invalid-position-declaration';
|
|
|
|
const messages = ruleMessages(ruleName, {
|
|
rejected: 'Unexpected invalid position declaration',
|
|
});
|
|
|
|
const meta = {
|
|
url: 'https://stylelint.io/user-guide/rules/no-invalid-position-declaration',
|
|
};
|
|
|
|
/** @type {import('stylelint').CoreRules[ruleName]} */
|
|
const rule = (primary) => {
|
|
return (root, result) => {
|
|
const validOptions = validateOptions(result, ruleName, { actual: primary });
|
|
|
|
if (!validOptions) return;
|
|
|
|
root.walkDecls((decl) => {
|
|
// Skip checking declarations in embedded styles
|
|
if (isInDocument(decl)) return;
|
|
|
|
if (!isStandardSyntaxDeclaration(decl)) return;
|
|
|
|
const { parent } = decl;
|
|
|
|
if (!parent) return;
|
|
|
|
// Declarations are allowed in rules
|
|
if (typeGuards.isRule(parent)) return;
|
|
|
|
if (typeGuards.isAtRule(parent)) {
|
|
const atRuleName = parent.name.toLowerCase();
|
|
|
|
// Nesting-supported at-rules only allow declarations when nested inside a rule
|
|
if (atKeywords.nestingSupportedAtKeywords.has(atRuleName)) {
|
|
const parentRule = findNodeUpToRoot(decl, ({ type }) => type === 'rule');
|
|
|
|
if (parentRule) return;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
|
|
report({
|
|
message: messages.rejected,
|
|
messageArgs: [],
|
|
node: decl,
|
|
result,
|
|
ruleName,
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
rule.ruleName = ruleName;
|
|
rule.messages = messages;
|
|
rule.meta = meta;
|
|
|
|
module.exports = rule;
|