Giter Site home page Giter Site logo

grunt-html-validation's People

Contributors

areski avatar bitdeli-chef avatar cvrebert avatar cybear avatar elfreyshira avatar jimmerz28 avatar magarcia avatar maxterry avatar nschonni avatar ojacquemart avatar praveenvijayan avatar shinnn avatar sylvaincombes avatar teodragovic avatar vladikoff avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-html-validation's Issues

Got message "undefined is not a valid uri or options object" from the second time validation with grunt-este-watch

I'm using grunt-html-validation with grunt-este-watch.

esteWatch: {
  options: {
    dirs: ['source/**/']
  },
  slim: function(filepath) {
    if(filepath.match("source\/")) {
      grunt.config(['validation', 'options', 'remoteFiles'], [RegExp.rightContext.replace(/.slim/, '')]);
      return ['validation']
    }
  }
}

Then, first validation work fine.

But, from the second time is not work fine. I've got below message every after validation.

Warning: undefined is not a valid uri or options object.

Can't get it to work

I am unable to get it to work at all. I am trying to use it in ng-boilerplate. I get:

"Warning: must provide an include pattern"

related to the files: section.

I have tried:

        files: {
            src: ['<%=app_files.atpl%>', '<%=app_files.ctpl%>']
        },

and

        files: {
            src: ['src/app/home/*.html']
        },

and

        files: {
            src: ['src/app/home/home.html']
        },

but can't get past the error.

What should be entered here?

The docs need to be corrected/clearer, please. The overview says "In your project's Gruntfile, add a section named html_validation ..." but that's wrong, apparently. It should be "validation" as per the sample. What is this: "your_target:" and how is it used? What are the correct possibilities for files.src? The yeoman example doesn't help those of us not using it.

Thanks.

Ignore php blocks

Is there any way to tell the validator to skip over php tags? The project I'm currently working on relies heavily on php includes for factorization, but the files are otherwise 99% html.
The validator runs flawless on php files, I just need it to ignore whatever is between

Any ideas?

XML support?

Hi.

I was trying to automate my rss.xml validation through this plugin but it doesn't work right.

Are XML files supported? An example is this which passes the W3C online validator.

validation: {
    options: {
        charset: "utf-8",
        reportpath: false,
        reset: true
    },
    html: {
        options: {
            doctype: "HTML5"
        },
        src: ["_site/**/*.html"]
    },
    xml: {
        options: {
            doctype: "XML"
        },
        src: ["_site/**/*.xml"]
    }
},

Output:

C:\Users\xmr\Desktop\mpc-hc.org>grunt validation:xml
Running "validation:xml" (validation) task
Validation started for.. _site/rss.xml
1=> "delimiter \">\" invalid: only name, \"#IMPLIED\" and parameter separators a
re allowed" Line no: 2
2=> "cannot continue because of previous errors" Line no: 2
No of errors: 2
Validation started for.. _site/sitemap.xml
1=> "delimiter \">\" invalid: only name, \"#IMPLIED\" and parameter separators a
re allowed" Line no: 3
2=> "cannot continue because of previous errors" Line no: 3
No of errors: 2

Done, without errors.

Thanks in advance.

Task is not aborted when errors occurs / Sound notification

I'm on a mac and I find it very useful when I get a sound notification from the terminal when a warning/error occurs because I'm not always looking at the terminal or it is minimised. For example Sass:
screen shot 2014-12-11 at 02 41 31
That doesn't happen with this plugin when I have a validation error...
screen shot 2014-12-11 at 02 42 19
...and you can see that the task is not aborted which I think that's why there's no sound notification.

Here's my Grunt setup:

    validation: {
            options: {
                reset: true,
                stoponerror: true,
                failHard: true
            },
            files: {
                src: ['dev/{,*/}*.html']
            }
        }

So is there something wrong with my setup? Or is this an issue with the plugin?

syntax error causes failure because of - in html-validation

w3c-validation fork plugin does not work. grunt and my editor throw syntax errors because of the - in the plugin names. I was using the original html-validation plugin without problems. This is my config stanza.
html-validation: {
options: {
reset: grunt.option('reset') || false,
stoponerror: false,
relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."] //ignores these errors
},
files: {
src: '*.html'
}
}

This is the error message:
Loading "Gruntfile.js" tasks...ERROR

SyntaxError: Unexpected token -

IP Blocked due to excessive hits

Task works great, love it. However, I noticed, today, that it appeared that the task was failing to reach the W3C service due to what looked like network issues...the console output kept telling me the network was unavailable, 1st try, 2nd try and so forth before skipping each file.

Come to find out, my IP address has being blocked by the service itself due to too many validation requests, or what the W3C considered "unreasonable"

Is there any way around this apart from simply letting the block expire each time it happens?

first validate is good, but try again it did nothing!

Hi:

I use 'watch' to monitor files save status.

every time I save file, grunt will trigger the HTML validator to valide my HTML file.

but if my html file pass valifdation, I write some wrong code and try again, validator did nothing.

For example:

wrong html code -> validator output error message.
non-error html code -> validator output sucessful message.
wrong html code -> validator output nothing!

my console shows as follows:

Running "validation:normal" (validation) task // but my HTML code has some Error@@!

Running "watch:sass" (watch) task
Completed in 0.684s at Fri Jun 20 2014 18:33:50 GMT+0800 (CST) - Waiting...

Thank you for your attention :)

Hank

Loop issue.

The utility needs some work but I don't have the time to search through the code loops:

  • If you only have one page the code seems to loop twice and you get an undefined error.
  • If you have many pages the last page is not validated
  • JSON output mis-spelled. validation-staus.json (staus?)

Looping issue is caused when called in this manner:

// -----------------------------------
//
// TASK: validation  [Validate the html] 
//
// -----------------------------------

validation: {
  options: {
    reset: true,
  },
  files: {
    src: ["_site/**/*.html"]
  }
},

Wrong counting of files when using a wrapfile?

When using the wrapfile option I always encounter the following error after the last validated file:

Fatal error: Unable to read "undefined" file (Error code: ENOENT).

This is due to the code on L275:

w3cjs_options.input = wrapfile.replace("<!-- CONTENT -->", grunt.file.read(files[counter]));

Changing L265:

if (options.wrapfile) {

Into

if (options.wrapfile && files[counter]) {

Will fix this, but I think this is more a workaround and not the best fix. What do you think?

Grunt task does not stop on validation error

Running "validation:dist" (validation) task                                                                                                                                          
Validation started for.. src/index.html                                                                                                                                              
1=> "An a start tag seen but an element of the same type was already open." Line no: 321                                                                                             
2=> "Stray end tag a." Line no: 324                                                                                                                                                  
No of errors: 2                                                                                                                                                                      

Running "htmlmin:dist" (htmlmin) task                                                                                                                                                
File dist/index.html created.                                                                                                                                                        

Running "cssmin:dist" (cssmin) task                                                                                                                                                  
File dist/main.css created.    

Network error re-validating..

Hello

For about two days I'm constantly getting an error:
Network error re-validating.. 1 and it skips the file after three attempts.
This occurs on two different machines in two different networks (so I doubt it's a local issue)

Nothing changed in my task options.

Running multiple sub-tasks fails after first.

I have set up my grunt file as so...

    validation: {
        options: {
            reset: true
        },
        indexHtml: {
            src: 'app/views/index.html'
        },
        homeHtml: {
            src: 'app/views/home.html'
        }
    }

but if I have a task list like this:

 grunt.registerTask('dev', ['clear', 'jshint', 'validation', 'concat']);

the expected behaviour would be that index.html should be validated then home.html, however the validation exits after the first indexHtml task, and the homeHtml task isn't run.

The following task list also fails after the first file (index.html),

 grunt.registerTask('dev', ['clear', 'jshint', 'validation:indexHtml', 'validation:homeHtml', 'concat']);

so, this may be related to my previous issue #25

If I use grunt-watch, I am able to call the indexHtml and homeHtml as they are changed, if I watch both of the files separately.

Loading "html_validation.js" tasks...ERROR and exit....

Getting following error -
C:\sample2>grunt

Local Npm module "grunt-install-dependencies" not found. Is it installed?
Loading "html_validation.js" tasks...ERROR
TypeError: Cannot assign to read only property 'name' of function () {

    // Merge task-specific and/or target-specific options with these defa

ults.
va...... }
Warning: Task "css-validation" not found. Use --force to continue.

This what i have in Gruntfile.js

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

    'html-validation': {
        options: {
            reset: grunt.option('reset') || false,
            stoponerror: false,
            /*remotePath: "http://decodize.com/",
            remoteFiles: ["html/moving-from-wordpress-to-octopress/",
                            "css/site-preloading-methods/"], //or 
            remoteFiles: "validation-files.json", // JSON file contains array of page paths. 
            relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."] //ignores these errors */
        },
        files: {
            src: [
                'src/index.html',
                ]
        }
    },

    'css-validation': {
        options: {
            reset: grunt.option('reset') || false,
            stoponerror:false,
            relaxerror: [],
            profile: 'css3', // possible profiles are: none, css1, css2, css21, css3, svg, svgbasic, svgtiny, mobile, atsc-tv, tv 
            medium: 'all', // possible media are: all, aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation 
            warnings: '0' // possible warnings are: 2 (all), 1 (normal), 0 (most important), no (no warnings) 
          },
          files: {
            src: ['src/css/*.css']
          }
    }

});

grunt.loadNpmTasks('grunt-w3c-validation');
grunt.registerTask("default", ["html-validation"]);
grunt.registerTask("default", ["css-validation"]);

};

When multiple tasks declared it only runs on first task

If i create my task with the following json structure;

{
"options": {
"reportpath": false,
"stoponerror": false,
"path": "_Build/Shared Files/Temp/vaidation.json",
"failHard": true
},
"Accordion": {
"files": {
"src": "Accordion/preview/index.html"
}
},
"Blank": {
"files": {
"src": "Blank/preview/index.html"
}
},
"Chart": {
"files": {
"src": "Chart/preview/index.html"
}
},
"Figure": {
"files": {
"src": "Figure/preview/index.html"
}
}
}

It only runs the validation on the first task and then skips over the rest;

Running "validation:Accordion" (validation) task
Validation started for.. _Stream/Stream Templates/Accordion/preview/index.html

Validation successful..

Running "validation:Blank" (validation) task

Running "validation:Chart" (validation) task

Running "validation:Figure" (validation) task

Done, without errors.

The reason my json is like this is because i need separate watches that can run independently e.g. validation:Blank

Support for validating HTML snippets

Hello,

I'm trying to validate a series of HTML files which contain mustache templates. The file isn't exactly HTML, as it simply contains a bunch of script elements with type text/template, but I'd still like to validate the contents of that. Is there a way I can specify that I'm validating HTML5 document fragments?

Thanks,
Evan

version 0.1.16 fails all the time with indexOf warning

Just install 0.1.16 for the first time.
It fails all time, even tested on a simple empty html 5 document.
There's no use of indexOf anywere.

<title>Document</title>

$ grunt html-validation
Running "html-validation:files" (html-validation) task
Warning: Object # has no method 'indexOf' Use --force to continue.

Aborted due to warnings.

grunt settings in grunt file
"html-validation":{
options:{
reset: true,
stoponerror: false,
},
files:[{
expand:true,
cwd:'files/',
src:[
'foobar.html'
],
dest:'files/'
}]
},

Error on validation

Hi,

I've got this error using grunt-html-validation.

I'm using Yeoman and generator-angular.

I'm behind a corporate proxy.

Error: connect ETIMEDOUT
at errnoException (net.js:901:11)
at Object.afterConnect as oncomplete

Any idea ? Is it me ?

"Validated skipping"

cm-mbp:test callumacrae$ grunt validation
Running "validation:files" (validation) task
Validated skipping..app/index.html
Validated skipping..app/test.html

The text is green, but it isn't validating the files, even when I change the files. Any ideas why?

validation-report.json has double entries, but just on valid files

{
"filename": "dist/docs/book_liberation_manifesto/Book_Liberation_Manifesto.html",
"error": []
},
{
"filename": "dist/docs/book_liberation_manifesto/Book_Liberation_Manifesto.html",
"error": []
},
{
"filename": "dist/docs/documentation/documentation.html",
"error": [
{
"lastLine": 28,
"lastColumn": 39,
....

Validation service changed

Looks like the W3C are throwing a new warning out when using their service:

1=> "This interface to HTML5 document checking is deprecated. Use the Nu Html Checker at https://validator.w3.org/nu/ directly instead." Line no: undefined
No of errors: 1

Might be a good idea to update the plugin to use https://validator.w3.org/nu/

Relax Error is not working for a particular string.

Relax error works fine for me for these:

"Attribute <br is not serializable as XML 1.0."
"No space between attributes."

But not this line...

"Element tags-input not allowed as child of element div in this context. (Suppressing further errors from this subtree.)"

Thought it might be something to do with your matching algorithm, maybe given the two full-stops?

Async errors

It appears that this task doesn't sync up with other grunt tasks. That is, the validator seems to be fired asynchronously for each file, but the task as a whole doesn't block until all validations are done. This allows other grunt tasks to execute while the validations are still running. This means the console output from grunt is threaded with output from other tasks.

Not to mention that the 'validated file' messages are not synced properly with the 'done, without errors' messages.

combination of stoponerror and failHard doesn't work as expected

stoponerror stops the validation of additional files
failHard stops any further grunt tasks from executing

Given both stoponerror and failHard are true
When multiple files have errors
Then I should see the errors output for the first file
And no further grunt tasks should be executed

Actual:
I see the error output for the first file
But additional grunt tasks continue executing.

It appears that the presence of stoponerror=true breaks the failHard behavior.

No file is specified in the path!

Hey folks,

I want to validate a folder which is not yet existing. I cannot skip this message, except to quit the Grunt task:

PATH:- No file is specified in the path!

My conf:

validation: {
    options: {
        failHard: false,
        stoponerror: false,
        reset: false,       
    },
    notExistingFolder: {
        src: [
            './src/notExistingFolder/**/*.html',
        ]
    }
},

In the future of the project there will be some html files.

Error on HTML5

Works fine on default doctype but if i set it to HTML5 it fails with this message:

"delimiter ">" invalid: only name, "#IMPLIED" and parameter separators are allowed" Line no: 1

My first line is just this:

Allow for automatic re-validation by detecting file changes for previously validated files

Obviously one could run a watch task to trigger a forced (--reset=true) re-validation of a file but this is not the best approach and makes things less flexible.

I propose that the existing "validation cache" file store a hash of the file to be used for comparison to detect if a files content has changed. If so, re-validate it.

For those with performance worries, it could be an option:

"revalidationCacheCheck: true"

BTW, consider renaming the option "reset" to "alwaysRevalidate" to avoid some first run problems a lot of people seem to be having.

Ignore all warnings

It would be nice if there was an option to ignore all warnings. At present warnings like this:

"The date input type is not supported in all browsers. Please be sure to test, and consider using a polyfill."

Cause the task to think there was an error and thus return fail (assuming failHard is on). I know this can be added to the relaxerror option, but it feels like warnings from the validation service should not be considered errors. An option like ignoreWarnings: true would be nice or even better, if warning are shown but do not cause it to fail - even when failHard is true.

Thanks!

Consider using h1 elements as top-level headings only

We are getting "Consider using h1 elements as top-level headings only (all h1 elements are treated as top-level headings by many screen readers and other tools).".

Even though I add this in relaxerror, I still get the warnings.

validation: {
  options: {
    charset: 'utf-8',
    doctype: 'HTML5',
    failHard: true,
    reset: true,
    relaxerror: [
      'Attribute ontouchstart not allowed on element body at this point.',
      'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
      'Consider using h1 elements as top-level headings only (all h1 elements are treated as top-level headings by many screen readers and other tools).'
    ]
  },
  files: {
    src: '_site/**/*.html'
  }
},

Is this because this isn't really an error but a help message? Is there any way to suppress this kind of errors?

Incomplete regex implementation

I just came across a regex issue on ignoring XML error reports on Bad value 6d0a884808fd72fcdbac270585981015metadata3320 for attribute id on element metadata: Not a valid XML 1.0 name.

The regex used: Bad value [\w]+ for attribute id on element metadata: Not a valid XML 1.0 name.

The regex that actually worked: Bad value [A-Za-z0-9]+ for attribute id on element metadata: Not a valid XML 1.0 name.

In terms of regex, both should actually be equally usable, but unfortunately are not. I guess it's a slash issue?

Validation causes grunt task list to quit.

I have a grunt task list something like this:

grunt.registerTask('dev', ['jshint',  'validation',  'concat', 'watch']);

but 'validation' quits the task list, so concat and watch don't get called, even if there are no reported errors. Am not sure if there is an option flag or something else I'm missing?

Better label for validated files

I was confused by "Validated skipping" for valid files, had to check the source to see whether those files were being excluded...

validFile: "Validated skipping..",

I think "Validated" or "Validated completed for" or something similar would be more clear.

Edit: Didn't realize this is only shown for already validated files, makes sense now.

Plugin seems totally broken

Hey there, first of all this is a great idea for a plugin. However we need to fix some stuff up.

Nevermind, ignore this issue

I'm gonna PR a test update.

How to specify which files are validated?

I'm unclear about how to specify which files to validate, and how validation-status.json works.

I want to validate all index.html files in directories under my/path. For example: my/path/dir1/index.html, my/path/dir2/index.html and my/path/dir3/index.html.

My Gruntfile.js has this:

files: {
        src: ['my/path/**/index.html']
},
options: {
    reset: true
}

However, only two files in the directories under my/path get validated when I run grunt validation.

validation-status.json has only this (i.e. only a reference to the first file/subdirectory):

{"my/path/dir1/index.html":true}

What am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.