Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error('Could not find import name for ' + rule);
}
if (PROTOCOL_RE.test(dep)) {
return;
}
// If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
// TODO: run CSSPackager on inline style tags.
let inlineHTML =
this.options.rendition && this.options.rendition.inlineHTML;
if (inlineHTML) {
name.value = this.addURLDependency(dep, {loc: rule.source.start});
rule.params = params.toString();
} else {
media = valueParser.stringify(media).trim();
this.addDependency(dep, {media, loc: rule.source.start});
rule.remove();
}
this.ast.dirty = true;
});
</style>
export default (node, localOpts, direction, decl, firstColumnSetLength, foundColumnsAndRows, prevSourceIndex, locallySpecified, lastColumnSetLength) => {
// Grab all the contents within the function and sort them into size sets.
const value: string = valueParser.stringify(node.nodes)
const sizeSets: Array = postcss.list.comma(value)
let totalSizes: number = 0
sizeSets.map(sizeSet => {
totalSizes += postcss.list.space(sizeSet).length
})
// Determine if this is the last/first columns() or rows() call in the declaration value.
let lastCall: boolean = false
let firstCall: boolean = false
if (node.sourceIndex > prevSourceIndex) {
lastCall = true
}
if (node.sourceIndex === 0){
firstCall = true
}
break
case `${localOpts.namespace}support`:
localOpts.support = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.support
break
case `${localOpts.namespace}pluck`:
localOpts.pluck = Number(valueParser.stringify(node.nodes)) ? Number(valueParser.stringify(node.nodes)) : opts.pluck
break
case `${localOpts.namespace}bump`:
localOpts.bump = ` ${valueParser.stringify(node.nodes)}` ? ` ${valueParser.stringify(node.nodes)}` : opts.bump
break
case `${localOpts.namespace}technique`:
localOpts.technique = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.technique
break
case `${localOpts.namespace}children`:
localOpts.children = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.children
break
default:
break
}
// Poorly erase the function (leaves whitespace). It would be nice if there was a .remove() method in valueParser.
node.value = ''
}
}, false) // shallow
function check(node, value, getIndex) {
// Get out quickly if there are no periods
if (value.indexOf(".") === -1) { return }
valueParser(value).walk(valueNode => {
// Ignore `url` function
if (valueNode.type === "function" && valueNode.value.toLowerCase() === "url") { return false }
// Ignore strings, comments, etc
if (valueNode.type !== "word") { return }
// Check leading zero
if (expectation === "always") {
const match = /(?:\D|^)(\.\d+)/.exec(valueNode.value)
if (match === null) { return }
// The regexp above consists of 2 capturing groups (or capturing parentheses).
// We need the index of the second group. This makes sanse when we have "-.5" as an input
// for regex. And we need the index of ".5".
const capturingGroupIndex = match[0].length - match[1].length
root.walkDecls(decl => {
const valueRoot = parseValue(decl.value);
let varFound = false;
valueRoot.walk(({ type, value }) => {
if (!varFound && type === 'function' && value === 'var') {
// Add the imported to results messages
const message = varFunctionMessage(value);
result.messages.push(message);
varFound = true;
}
});
});
}
function check(node, value, getIndex) {
valueParser(value).walk(function (valueNode) {
// Ignore wrong units within `url` function
if (valueNode.type === "function" && valueNode.value.toLowerCase() === "url") { return false }
const unit = getUnitFromValueNode(valueNode)
if (!unit) { return }
if (optionsMatches(options, "ignoreUnits", unit)) { return }
if (units.has(unit.toLowerCase())) { return }
report({
index: getIndex(node) + valueNode.sourceIndex,
message: messages.rejected(unit),
node,
result,
ruleName,
css.walkDecls(decl => {
if (decl.value.indexOf('sketch(') !== -1) {
let parsedValue = valueParser(decl.value);
let file = parsedValue.nodes[0].nodes[0].value;
// Resolve the file reference.
let fileRef;
if (decl.source.input.file)
fileRef = path.join(
path.dirname(decl.source.input.file),
file
); // Relative to CSS File
else fileRef = path.join(file); // No CSS file, probably testing
// Retrieve the sketch JSON dump
let sketchData = getSketchJSON(path.resolve(fileRef));
// Add a dependency.
root.walkDecls(decl => {
valueParser(decl.value).walk((node) => {
// Ignore wrong units within `url` function
if (node.type === "function" && node.value.toLowerCase() === "url") { return false }
const unit = getUnitFromValueNode(node)
if (!unit) { return }
const expectedUnit = expectation === "lower" ? unit.toLowerCase() : unit.toUpperCase()
if (unit === expectedUnit) { return }
report({
message: messages.expected(unit, expectedUnit),
node: decl,
index: declarationValueIndex(decl) + node.sourceIndex,
result,
_proto.oldWebkit = function oldWebkit(node) {
var nodes = node.nodes;
var string = parser.stringify(node.nodes);
if (this.name !== 'linear-gradient') {
return false;
}
if (nodes[0] && nodes[0].value.includes('deg')) {
return false;
}
if (string.includes('px') || string.includes('-corner') || string.includes('-side')) {
return false;
}
var params = [[]];
for (var _iterator4 = _createForOfIteratorHelperLoose(nodes), _step4; !(_step4 = _iterator4()).done;) {
Gradient.prototype.oldWebkit = function oldWebkit(node) {
var nodes = node.nodes;
var string = parser.stringify(node.nodes);
if (this.name !== 'linear-gradient') {
return false;
}
if (nodes[0] && nodes[0].value.indexOf('deg') !== -1) {
return false;
}
if (string.indexOf('px') !== -1 || string.indexOf('-corner') !== -1 || string.indexOf('-side') !== -1) {
return false;
}
var params = [[]];
for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {