mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 05:27:15 -04:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
"use strict"
|
|
|
|
const isCustomProperty = require("../../utils/isCustomProperty")
|
|
const report = require("../../utils/report")
|
|
const ruleMessages = require("../../utils/ruleMessages")
|
|
const validateOptions = require("../../utils/validateOptions")
|
|
|
|
const ruleName = "custom-property-no-outside-root"
|
|
|
|
const messages = ruleMessages(ruleName, {
|
|
rejected: "Unexpected custom property",
|
|
})
|
|
|
|
const rule = function (actual) {
|
|
return (root, result) => {
|
|
const validOptions = validateOptions(result, ruleName, { actual })
|
|
if (!validOptions) {
|
|
return
|
|
}
|
|
|
|
result.warn((
|
|
`'${ruleName}' has been deprecated and in 8.0 will be removed.`
|
|
), {
|
|
stylelintType: "deprecation",
|
|
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
|
|
})
|
|
|
|
root.walkRules(rule => {
|
|
// Ignore rules whose selector is just `:root`
|
|
if (rule.selector.toLowerCase().trim() === ":root") {
|
|
return
|
|
}
|
|
|
|
rule.walkDecls(decl => {
|
|
if (!isCustomProperty(decl.prop)) {
|
|
return
|
|
}
|
|
report({
|
|
message: messages.rejected,
|
|
node: decl,
|
|
result,
|
|
ruleName,
|
|
})
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
rule.ruleName = ruleName
|
|
rule.messages = messages
|
|
module.exports = rule
|