3 const _ = require("lodash");
4 const isAutoprefixable = require("../../utils/isAutoprefixable");
5 const isStandardSyntaxDeclaration = require("../../utils/isStandardSyntaxDeclaration");
6 const isStandardSyntaxProperty = require("../../utils/isStandardSyntaxProperty");
7 const optionsMatches = require("../../utils/optionsMatches");
8 const postcss = require("postcss");
9 const report = require("../../utils/report");
10 const ruleMessages = require("../../utils/ruleMessages");
11 const styleSearch = require("style-search");
12 const validateOptions = require("../../utils/validateOptions");
14 const ruleName = "value-no-vendor-prefix";
16 const messages = ruleMessages(ruleName, {
17 rejected: value => `Unexpected vendor-prefix "${value}"`
20 const valuePrefixes = ["-webkit-", "-moz-", "-ms-", "-o-"];
22 const rule = function(actual, options) {
23 return (root, result) => {
24 const validOptions = validateOptions(
32 ignoreValues: [_.isString]
41 root.walkDecls(decl => {
43 !isStandardSyntaxDeclaration(decl) ||
44 !isStandardSyntaxProperty(decl.prop) ||
50 const prop = decl.prop,
52 unprefixedValue = postcss.vendor.unprefixed(value);
54 //return early if value is to be ignored
55 if (optionsMatches(options, "ignoreValues", unprefixedValue)) {
59 // Search the full declaration in order to get an accurate index
62 { source: value.toLowerCase(), target: valuePrefixes },
64 const fullIdentifier = /^(-[a-z-]+)\b/i.exec(
65 value.slice(match.startIndex)
67 if (!isAutoprefixable.propertyValue(prop, fullIdentifier)) {
72 message: messages.rejected(fullIdentifier),
75 prop.length + (decl.raws.between || "").length + match.startIndex,
85 rule.ruleName = ruleName;
86 rule.messages = messages;
87 module.exports = rule;