var tidyBlock = require('./tidy-block');
var tidyAtRule = require('./tidy-at-rule');
var split = require('../utils/split');
+var formatPosition = require('../utils/format-position');
var Token = require('../tokenizer/token');
var Marker = require('../tokenizer/marker');
if (property.value.length === 0) {
propertyToken = property.all[property.position];
- context.warnings.push('Empty property \'' + name + '\' at line ' + propertyToken[1][2][0][0] + ', column ' + propertyToken[1][2][0][1] + '. Ignoring.');
+ context.warnings.push('Empty property \'' + name + '\' at ' + formatPosition(propertyToken[1][2][0]) + '. Ignoring.');
property.unused = true;
}
if (valueIsUrl && !context.validator.isValidUrl(value)) {
property.unused = true;
- context.warnings.push('Broken URL \'' + value + '\' at line ' + property.value[j][2][0][0] + ', column ' + property.value[j][2][0][1] + '. Ignoring.');
+ context.warnings.push('Broken URL \'' + value + '\' at ' + formatPosition(property.value[j][2][0]) + '. Ignoring.');
break;
}
var Marker = require('../tokenizer/marker');
+var formatPosition = require('../utils/format-position');
var RELATION_PATTERN = /[>\+~]/;
var WHITESPACE_PATTERN = /\s/;
var reduced = rule[1];
if (hasInvalidCharacters(reduced)) {
- warnings.push('Invalid selector \'' + rule[1] + '\' at line ' + rule[2][0][0] + ', column ' + rule[2][0][1] + '. Ignoring.');
+ warnings.push('Invalid selector \'' + rule[1] + '\' at ' + formatPosition(rule[2][0]) + '. Ignoring.');
continue;
}
var InvalidPropertyError = require('./invalid-property-error');
var Token = require('../tokenizer/token');
+var formatPosition = require('../utils/format-position');
var MULTIPLEX_SEPARATOR = ',';
origin.value = clip.value.slice(0);
if (!anyValueSet) {
- throw new InvalidPropertyError('Invalid background value.');
+ throw new InvalidPropertyError('Invalid background value at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
}
return components;
}
if (splitAt === 0 || splitAt === values.length - 1) {
- throw new InvalidPropertyError('Invalid border-radius value.');
+ throw new InvalidPropertyError('Invalid border-radius value at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
}
var target = _wrapDefault(property.name, property, compactable);
var Marker = require('./marker');
var Token = require('./token');
+var formatPosition = require('../utils/format-position');
+
var Level = {
BLOCK: 'block',
COMMENT: 'comment',
seekingValue = false;
} else if (character == Marker.CLOSE_BRACE && level == Level.BLOCK && !isNested && position.index <= source.length - 1) {
// stray close brace at block level, e.g. a{color:red}color:blue}<--
- externalContext.warnings.push('Unexpected \'}\' at line ' + position.line + ', column ' + position.column + '.');
+ externalContext.warnings.push('Unexpected \'}\' at ' + formatPosition([position.line, position.column, position.source]) + '.');
buffer.push(character);
} else if (character == Marker.CLOSE_BRACE && level == Level.BLOCK) {
// close brace at block level, e.g. @media screen {...}<--
}
if (seekingValue) {
- externalContext.warnings.push('Missing \'}\' at line ' + position.line + ', column ' + position.column + '.');
+ externalContext.warnings.push('Missing \'}\' at ' + formatPosition([position.line, position.column, position.source]) + '.');
}
if (seekingValue && buffer.length > 0) {
--- /dev/null
+function formatPosition(metadata) {
+ var line = metadata[0];
+ var column = metadata[1];
+ var source = metadata[2];
+
+ return source ?
+ source + ':' + line + ':' + column :
+ line + ':' + column;
+}
+
+module.exports = formatPosition;
},
'should raise one warning': function (error, minified) {
assert.lengthOf(minified.warnings, 1);
- assert.equal(minified.warnings[0], 'Unexpected \'}\' at line 1, column 16.');
+ assert.equal(minified.warnings[0], 'Unexpected \'}\' at 1:16.');
}
},
'warnings on unexpected body': {
},
'should raise one warning': function (error, minified) {
assert.lengthOf(minified.warnings, 2);
- assert.equal(minified.warnings[0], 'Unexpected \'}\' at line 1, column 29.');
- assert.equal(minified.warnings[1], 'Invalid selector \'color:#535353}p\' at line 1, column 16. Ignoring.');
+ assert.equal(minified.warnings[0], 'Unexpected \'}\' at 1:29.');
+ assert.equal(minified.warnings[1], 'Invalid selector \'color:#535353}p\' at 1:16. Ignoring.');
}
},
'warnings on empty properties': {
},
'should raise one warning': function (error, minified) {
assert.lengthOf(minified.warnings, 1);
- assert.equal(minified.warnings[0], 'Empty property \'color\' at line 1, column 2. Ignoring.');
+ assert.equal(minified.warnings[0], 'Empty property \'color\' at 1:2. Ignoring.');
}
},
'warnings on broken urls': {
},
'should raise one warning': function (error, minified) {
assert.lengthOf(minified.warnings, 2);
- assert.equal(minified.warnings[0], 'Missing \'}\' at line 1, column 24.');
- assert.equal(minified.warnings[1], 'Broken URL \'url(image/\' at line 1, column 13. Ignoring.');
+ assert.equal(minified.warnings[0], 'Missing \'}\' at 1:24.');
+ assert.equal(minified.warnings[1], 'Broken URL \'url(image/\' at 1:13. Ignoring.');
}
},
'no errors': {
[
'property',
['property-name', 'border-radius'],
- ['property-value', '0px'],
+ ['property-value', '0px', [[1, 20, undefined]]],
['property-value', '/']
]
]);
[
'property',
['property-name', 'border-radius'],
- ['property-value', '/'],
+ ['property-value', '/', [[1, 20, undefined]]],
['property-value', '0px']
]
]);
return warnings;
},
'logs them correctly': function (warnings) {
- assert.deepEqual(warnings, ['Missing \'}\' at line 1, column 15.']);
+ assert.deepEqual(warnings, ['Missing \'}\' at one.css:1:15.']);
}
}
})