Open prashantkoshta opened 9 years ago
Same issue here for https://github.com/mryvlin/grunt-w3c-validation. It's because of the 'use strict' in file html_validation.js in combination with the the first line of function getValidate. In strict mode, you are not allowed to overwrite a function name.
'use strict';
module.exports = function (grunt) {
...
var htmlValidation = 'html-validation';
var cssValidation = 'css-validation';
...
var validate = function() {
...
}
...
function getValidate(validationType){
validate.name = validationType;
return validate;
}
grunt.registerMultiTask(htmlValidation, 'HTML W3C validation.', getValidate(htmlValidation));
grunt.registerMultiTask(cssValidation, 'CSS W3C validation.', getValidate(cssValidation));
};
It could be fixed by replacing the function getValidate with:
function getValidate(validationType) {
return function () {
this.name = validationType || validate.name;
validate.apply(this, arguments);
};
}
I applied the above fix and eliminated the task-not-found error; however, I am now receiving an unexpected token error:
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: /Users/icn2you/Dropbox/Courses/Udacity/Nanodegrees/FEWD/Projects/portfolio/project1/Gruntfile.js:72
>> html-validation: {
>> ^
>> Unexpected token -
Warning: Task "default" not found. Use --force to continue.
The tasks in my Gruntfile.js are configured as follow. With some slight modification, I cut and pasted the task configuration from https://www.npmjs.com/package/grunt-w3c-validation.
/* Validate HTML to HTML5 standard. */
html-validation: {
options: {
reset: grunt.option('reset') || false,
stoponerror: false,
relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."]
},
files: {
src: ['src/*.html']
}
},
/* Validate CSS to CSS3 standard. */
css-validation: {
options: {
reset: grunt.option('reset') || false,
stoponerror:false,
relaxerror: [],
profile: 'css3',
medium: 'all',
warnings: '0'
},
files: {
src: ['src/styles/*.css']
}
},
Sorry if this is a trivial error, and I just can't see it. I'm weary! Thanks in advance for any help you can offer.
Hi @icn2you,
according to your console output there is a syntax error in line 72 in your Gruntfile.js. In JavaScript a valid identifier (-> valid variable names) cannot contain a hyphen symbol (see http://docstore.mik.ua/orelly/webprog/jscript/ch02_07.htm). The same rule applies to keys of key/value pairs in object literals. But you can use quoted property names in an object literal to circumvent this restriction like:
{ 'html-validation' : { ... } }
or
{ "html-validation" : { ... } }
Hope this information will help you to solve your problem.
I'm grateful for your help @jrauschenbusch; thank you.
Please pardon my ignorance of JS. It will be short-lived I assure you! I am a bit surprised the developer wasn't aware of this issue.
My best to you always. =)
Getting following error - C:\sample2>grunt
This what i have in Gruntfile.js
module.exports = function(grunt) {
// Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'),
});
};