1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 10:17:42 -04:00
notes/node_modules/stylelint/lib/rules/custom-property-no-outside-root/index.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
"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