Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6668395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:02:14+00:00 2026-05-26T03:02:14+00:00

I code according to JSLint standards (excluding a couple of options) and I thought

  • 0

I code according to JSLint standards (excluding a couple of options) and I thought it might be a good idea to work this into my in-browser unit tests so that I don’t accidentally commit anything which doesn’t pass it. I’m using QUnit, but the same can probably be applied to any in-browser testing framework.

I tried this code first of all:

test("code passes JSLint", function () {
    var i, options;
    options = {
        browser : true,
        plusplus : true,
        unparam : true,
        maxlen : 120,
        indent : 4
    };

    // in QUnit `ok` is the equivalent of `assertTrue`
    ok(JSLINT(this.code, options));

    // Help me out a bit if it fails
    for (i = 0; i < JSLINT.errors.length; i++) {
        console.log(JSLINT.errors[i].line + ': ' + JSLINT.errors[i].reason);
    }
});

Edit: Forgot to mention, I declared in the setup that this.code = myFunction.toString();.

Which works great in Chrome, so I committed and continued merrily coding. When I tried it in FF, I found that FF seems to strip all the white-space out of functions when it converts them into strings, so it fails.

I’m coding and testing locally, so using AJAX to download the JS file isn’t really an option. Can anyone think of a better option, or is this just a complete waste of time? (Ignoring the benefits or drawbacks of JSLint as a whole please… that’s for a different discussion)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:02:15+00:00Added an answer on May 26, 2026 at 3:02 am

    What is your development environment? Jslint can be integrated into common IDEs like Eclipse and (I’m pretty sure) Visual Studio. I think that would be a better option then putting it into your unit tests even if it worked perfectly in the unit tests.

    Otherwise to stick with the unit test approach maybe you could put a conditional in to only run the Jslint test if in Chrome – the things Jslint checks for don’t need to be tested in multiple browsers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my supposed to work code according to Apress Android Recipes book: package
I know this issue was posted before, and i fixed my code according to
according to this code i dont understand about NSClassFromString how did i know viewControllerName
according to this code if i want to access imageView1 and imageView2 how can
EDIT: Note! This turned out to be a typo in my code According to
This code return true in Firefox: ('overrideMimeType') in (new XMLHttpRequest()) but jslint gives me
I attempted to run Clean Code according to this link, however nothing is happening.
Edite: refined the code according to advice in comments but still no luck Update:
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
According to my memory the following piece of code should compile fine on C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.