浏览代码

Easier to understand css offenders

Gaël Métais 10 年之前
父节点
当前提交
604857648b
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12 3
      lib/metadata/policies.js

+ 12 - 3
lib/metadata/policies.js

@@ -390,11 +390,20 @@ var policies = {
             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) {
                         return {
-                            error: parts[2],
+                            error: parts[2] || 'Unknown parsing error',
                             file: parts[1] || null,
                             line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
                             column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
@@ -406,11 +415,11 @@ var policies = {
 
                     if (parts) {
                         return {
-                            error: parts[1],
+                            error: parts[1] || 'Unknown parsing error',
                             file: parts[2] || null,
                             line: parseInt(parts[3], 10),
                             column: parseInt(parts[4], 10)
-                        }
+                        };
                     }