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 8369059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:32:58+00:00 2026-06-09T13:32:58+00:00

Is it possible to run JSLint on one or more .js files by having

  • 0

Is it possible to run JSLint on one or more .js files by having JSLint loaded afterwards in the header from debugging/developer console in chrome or firefox?

The reason that I want to do that is that I want to print in console.log() the parsing of JSLint in JSON,it says in documentation:

// You can obtain the parse tree that JSLint constructed while parsing. The
// latest tree is kept in JSLINT.tree. A nice stringication can be produced
// with
//     JSON.stringify(JSLINT.tree, [
//         'string',  'arity', 'name',  'first',
//         'second', 'third', 'block', 'else'
//     ], 4));
  • 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-06-09T13:32:59+00:00Added an answer on June 9, 2026 at 1:32 pm

    You can run JSLint on JavaScript code using the below syntax:

    var code = "var a = 1 + 2;";
    JSLINT(code);
    

    And you can print the syntax tree as you have mentioned in the question.

    Now in your case, you need to read the JavaScript source from JavaScript files. You can make an AJAX call to read the source code of the JavaScript file into a variable. Then make a call to JSLINT as above passing that variable. A sample using jQuery would be like below.

    $(function() {
        // Include jslint.js
        $('<script src="http://localhost/yourapp/jslint.js">').appendTo("head");
    
        // Read JavaScript file contents into 'code'
        $.get('http://localhost/yourapp/somescript.js', function(code) {
    
            // Run JSLINT over code
                JSLINT(code);
    
            // Print the parse tree
            console.log(JSON.stringify(JSLINT.tree, [
                        'string',  'arity', 'name',  'first',
                        'second', 'third', 'block', 'else'
                        ], 4));
            });
    });
    

    Depending on what you are trying to achieve, a standalone JavaScript console (eg. NodeJS) would be a better alternative than a browser console. I guess there exist Node packages for JSLint. But if you want to include it manually you can simply do it as below.

    First add the below line at the end of jslint.js

    exports.JSLINT = JSLINT;
    

    Then write your code in say mycode.js.

    var fs = require("fs");
    var jslint = require("./jslint.js");
    
    fs.readFile("./test.js", function(err, code) {
        var source = code.toString('ascii');    
    
        jslint.JSLINT(source);
    
        console.log(JSON.stringify(jslint.JSLINT.tree, [
             'string',  'arity', 'name',  'first',
             'second', 'third', 'block', 'else'
            ], 4));
    },"text");
    

    Then run your code from console as:

    node mycode.js
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Run one instance from the application let's suppose i make an application
Is it possible to run rails console in one shell and then rails server
It is possible to run bcp utility for sybase database from .net code? I
Is it possible to run .pkg files in Ubuntu or Fedora. If so, how
Is it possible to run hip-hop php in cygwin which is using more script
Is it possible to run a windows xp bat script remotely from a ubuntu
Is it possible to run vim filter command(:!) for only one word. Not on
Is it possible to run package.skeleton('pkgname') and have all of the .R files end
Is it possible to run some code when an assembly is loaded, without doing
Is it possible to run SQL Server Management Studio Express from CD without installing

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.