|
@@ -371,7 +371,7 @@ var policies = {
|
|
|
},
|
|
|
"jQueryVersionsLoaded": {
|
|
|
"tool": "phantomas",
|
|
|
- "label": "Several versions loaded",
|
|
|
+ "label": "Several jQuery loaded",
|
|
|
"message": "<p>jQuery is a heavy library. You should <b>never</b> load jQuery more than once on the same page.</p>",
|
|
|
"isOkThreshold": 1,
|
|
|
"isBadThreshold": 2,
|
|
@@ -384,26 +384,48 @@ var policies = {
|
|
|
"message": "<p>Yellow Lab Tools failed to parse a CSS file. I doubt the problem comes from the css parser.</p><p>Maybe a <a href=\"http://jigsaw.w3.org/css-validator\" target=\"_blank\">CSS validator</a> can help you.</p>",
|
|
|
"isOkThreshold": 0,
|
|
|
"isBadThreshold": 1,
|
|
|
- "isAbnormalThreshold": 1,
|
|
|
+ "isAbnormalThreshold": 8,
|
|
|
"hasOffenders": true,
|
|
|
"offendersTransformFn": function(offenders) {
|
|
|
return {
|
|
|
count: offenders.length,
|
|
|
list: offenders.map(function(offender) {
|
|
|
+ if (offender === '[inline CSS] (Empty CSS was provided)') {
|
|
|
+ return {
|
|
|
+ error: 'Empty style tag',
|
|
|
+ file: null,
|
|
|
+ line: null,
|
|
|
+ column: null
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
|
|
|
|
|
|
- if (!parts) {
|
|
|
- debug('cssParsingErrors offenders transform function error with "%s"', offender);
|
|
|
+ if (parts) {
|
|
|
return {
|
|
|
- parseError: offender
|
|
|
+ error: parts[2] || 'Unknown parsing error' + (parts[1] ? '. The entire file was ignored. As a result, the other CSS metrics and scores are miscalculated.' : ''),
|
|
|
+ file: parts[1] || null,
|
|
|
+ line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
|
|
|
+ column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ // Try another syntax
|
|
|
+ parts = /^(.*) <(.*)> @ (\d+):(\d+)$/.exec(offender);
|
|
|
+
|
|
|
+ if (parts) {
|
|
|
+ return {
|
|
|
+ error: parts[1] || 'Unknown parsing error',
|
|
|
+ file: parts[2] || null,
|
|
|
+ line: parseInt(parts[3], 10),
|
|
|
+ column: parseInt(parts[4], 10)
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ debug('cssParsingErrors offenders transform function error with "%s"', offender);
|
|
|
return {
|
|
|
- error: parts[2],
|
|
|
- file: parts[1] || null,
|
|
|
- line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
|
|
|
- column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
|
|
|
+ parseError: offender
|
|
|
};
|
|
|
})
|
|
|
};
|