gulp-rb-validate-html
Advanced tools
Comparing version 0.0.5 to 0.0.6
42
index.js
@@ -21,4 +21,4 @@ /*jslint node: true*/ | ||
if (mistake.length > 80) { | ||
mistake = mistake.substr(0, 80) + "..."; | ||
if (mistake.length > 60) { | ||
mistake = mistake.substr(0, 60) + "..."; | ||
} else if (mistake.length === 0) { | ||
@@ -32,6 +32,6 @@ mistake = '[whitespace only]'; | ||
if (abort) { | ||
gutil.log('[' + guideline + '] ' + gutil.colors.white(tag + ": ") + gutil.colors.red(mistake) + " [Level: RED]"); | ||
gutil.log('[' + guideline + '] ' + gutil.colors.white(tag + ": ") + gutil.colors.red(mistake) + " [Level Red]"); | ||
errorBreak = true; | ||
} else { | ||
gutil.log('[' + guideline + '] ' + gutil.colors.white(tag + ": ") + gutil.colors.yellow(mistake)); | ||
gutil.log('[' + guideline + '] ' + gutil.colors.white(tag + ": ") + gutil.colors.yellow(mistake) + " [Level Orange]"); | ||
} | ||
@@ -63,6 +63,6 @@ } | ||
if (style && style.length > 0) { | ||
validationError("Never use CSS inline styles in the <body> section", '', 'CI-FE-2006', true); | ||
validationError("Frontend performance", 'Never use CSS inline styles in the <body> section', 'CI-FE-1009', false); | ||
} | ||
if (stylesheet && stylesheet.length > 0) { | ||
validationError("Never link CSS stylesheets in the <body> section", '', 'CI-FE-2006', true); | ||
validationError("Frontend performance", 'Never link CSS stylesheets in the <body> section', 'CI-FE-1009', false); | ||
} | ||
@@ -81,3 +81,3 @@ } | ||
} else { | ||
validationError('Do not load resources from remote servers', '<' + name + '>: ' + sourcelink.substr(0, 30) + '...', 'CI-FE-1018a', false); | ||
validationError('External resources - Do not load resources from remote servers', '<' + name + '>: ' + sourcelink.substr(0, 30) + '...', 'CI-FE-1018a', false); | ||
} | ||
@@ -110,16 +110,16 @@ } | ||
else if (name === "img" && !attribs.alt) { | ||
validationError("Missing or empty ALT tag", '<' + name + ' src="' + attribs.src + '">', 'CI-FE-2006', true); | ||
validationError("Missing or empty 'alt' tag", '<' + name + ' src="' + attribs.src + '">', 'CI-FE-2006', true); | ||
} | ||
// Iframes | ||
else if (name === "iframe") { | ||
validationError('Iframes must not be used (exception if ordered)', '<' + name + '>', 'CI-FE-2010', false); | ||
validationError('Iframes should not be used', '<' + name + '>', 'CI-FE-2010', false); | ||
} | ||
if (!isLowerCase(name)) { | ||
validationError('All elements have to be lower case', '<' + name + '>', 'CI-FE-2001', true); | ||
validationError('Markup must always be written in lowercase', '<' + name + '>', 'CI-FE-2001', true); | ||
} | ||
if (attribs.type === "text/javascript") { | ||
validationError('type="text/javascript" is superfluous', '<' + name + ' type="' + attribs.type + '" ...>', 'CI-FE-2007', true); | ||
validationError('JavaScript includes - Remove type="text/javascript"', '<' + name + ' type="' + attribs.type + '" ...>', 'CI-FE-2007', true); | ||
} else if (attribs.type === "text/css") { | ||
validationError('type="text/css" is superfluous', '<' + name + ' type="' + attribs.type + '" ...>', 'CI-FE-2007', true); | ||
validationError('CSS includes - Remove type="text/css"', '<' + name + ' type="' + attribs.type + '" ...>', 'CI-FE-2007', true); | ||
} | ||
@@ -131,3 +131,3 @@ | ||
if (!isLowerCase(name)) { | ||
validationError("All attributes have to be lower case", 'Attribute "' + name + '"', 'CI-FE-2001', false); | ||
validationError("Markup must always be written in lowercase", 'Attribute "' + name + '"', 'CI-FE-2001', false); | ||
} | ||
@@ -162,3 +162,3 @@ } | ||
if (!nospace.includes('user-scalable=no') || !nospace.includes('width=device-width') || !nospace.includes('initial-scale=1') || !nospace.includes('maximum-scale=1')) { | ||
validationError('Viewport tag is incorrect', attribs.content, 'CI-FE-2004', false); | ||
validationError('Viewport settings - Viewport tag is incorrect', attribs.content, 'CI-FE-2004b', false); | ||
} | ||
@@ -174,3 +174,3 @@ } | ||
if (!found) { | ||
validationError('Viewport tag is missing', '<head>', 'CI-FE-2004', false); | ||
validationError('Viewport settings - Viewport tag is missing', '<head>', 'CI-FE-2004', false); | ||
} | ||
@@ -211,3 +211,3 @@ } | ||
if (area.length > 0) { | ||
validationError('Wrong indentation on line ' + count, line, 'CI-FE-2001', false); | ||
validationError('Wrong indentation (line ' + count + '). Use auto formatter', line, 'CI-FE-2001', false); | ||
} | ||
@@ -227,3 +227,3 @@ } | ||
if (res && res.length > 0) { | ||
validationError('No single quotes allowed on attributes', res, 'CI-FE-2001', false); | ||
validationError('Always use double quotes, never single quotes, on attributes', res, 'CI-FE-2001', false); | ||
} | ||
@@ -280,11 +280,11 @@ } | ||
if (str.includes('<head>') && !str.includes('charset="utf-8"') && !str.includes('charset=utf-8')) { | ||
validationError('Encoding', 'Undefined or wrong encoding, must be: charset="utf-8"', 'CI-FE-2002', true); | ||
validationError('Undefined or wrong encoding', 'It should be: charset="utf-8"', 'CI-FE-2002', true); | ||
} | ||
} | ||
if (error) { | ||
gutil.log(gutil.colors.cyan("File: " + file.path)); | ||
if (options.abortOnError && errorBreak) { | ||
gutil.log(gutil.colors.red("Critical validation error -> ABORT")); | ||
if (options.exitOnError && errorBreak) { | ||
gutil.log(gutil.colors.red("Critical validation error -> EXIT") + " (exitOnError is active)"); | ||
process.exit(1); | ||
@@ -291,0 +291,0 @@ } |
{ | ||
"name": "gulp-rb-validate-html", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Gulp plugin to validate HTML files according to Web Frontend Guidelines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
11173