X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Fstylelint%2Flib%2Futils%2FcheckAgainstRule.js;fp=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Fstylelint%2Flib%2Futils%2FcheckAgainstRule.js;h=f8406bbab6d9646da709265bb9e46de6bc8d797a;hb=3c06164f15bd10aed7d66b6314764a2961a14762;hp=0000000000000000000000000000000000000000;hpb=0e9c3ceb40901f4d44981c1376cb9e23a248e006;p=dotfiles%2F.git diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/checkAgainstRule.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/checkAgainstRule.js new file mode 100644 index 00000000..f8406bba --- /dev/null +++ b/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/checkAgainstRule.js @@ -0,0 +1,46 @@ +/* @flow */ +"use strict"; + +const normalizeRuleSettings = require("../normalizeRuleSettings"); +const Result = require("postcss/lib/result"); +const rules = require("../rules"); + +// Useful for third-party code (e.g. plugins) to run a PostCSS Root +// against a specific rule and do something with the warnings +module.exports = function( + options /*: { + ruleName: string, + ruleSettings: stylelint$configRuleSettings, + root: Object, + }*/, + callback /*: Function*/ +) { + if (!options) + throw new Error( + "checkAgainstRule requires an options object with 'ruleName', 'ruleSettings', and 'root' properties" + ); + if (!callback) throw new Error("checkAgainstRule requires a callback"); + if (!options.ruleName) + throw new Error("checkAgainstRule requires a 'ruleName' option"); + if (!rules[options.ruleName]) + throw new Error(`Rule '${options.ruleName}' does not exist`); + if (!options.ruleSettings) + throw new Error("checkAgainstRule requires a 'ruleSettings' option"); + if (!options.root) + throw new Error("checkAgainstRule requires a 'root' option"); + + const settings = normalizeRuleSettings( + options.ruleSettings, + options.ruleName + ); + if (!settings) { + return; + } + + const tmpPostcssResult = new Result(); + rules[options.ruleName](settings[0], settings[1], {})( + options.root, + tmpPostcssResult + ); + tmpPostcssResult.warnings().forEach(callback); +};