Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!

ADSAFE: Use the fragment option

When do I get this error?

JSLint (prior to version 2013-03-18) throws the "ADSAFE: Use the fragment option" error when the adsafe option is set to true (it's false by default) and you pass it a fragment of HTML without having set the fragment option to true. Here's an example:

Why do I get this error?

This error is raised because JSLint doesn't know how to continue. Since JSLint is primarily a JavaScript parser, it doesn't expect an HTML fragment by default. The error can be fixed simply by passing the fragment option to JSLint.

In a commit on 20th March 2013, HTML, CSS and ADsafe parsing functionality was removed from JSLint. If you rely upon this functionality, you will be unable to upgrade JSLint to a version beyond that date.

James Allardice

This article was written by James Allardice, an enthusiastic young JavaScript developer at Global Personals (we're looking for developers so please apply). He is passionate about writing clean, maintainable JavaScript and uses JSHint every day to help achieve this.

You can follow him on Twitter, fork him on GitHub and find him on Google+.

Proceeds generated by this site are donated to help advance other open source projects

comments powered by Disqus