Brackets: JSLint throwing error when using console.log()

Created on 4 Oct 2013  路  20Comments  路  Source: adobe/brackets

Steps:

1-open an empty JS file
2-type console.log('hello');
3-save

Expected:
-no errors shown in JSLint as we haven't done anything illegal

Observed:
-error message in JSLint 'console' was used before it was defined

move to backlog

Most helpful comment

Add this to your linter options:

"devel": true

All 20 comments

You need to define the JSLint devel option before you use console. The default settings for JSLint used in Brackets code, for example, are:

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ /*global define */

Gotcha. Since most people will use this for webdev it would be good to have it included so they don't get error messages. Just an idea!

Forgot to mention before that I find this project really awesome and look forward to see where it will lead.

Yeah, we should really have defaults for JSLint. We have a backlog item for this: https://trello.com/c/8PfQ0yBY that we'll hopefully get to in the not-too-distant future.

Closing as move to backlog.

Agreed some JSLint standards should be set for this issue. It is only minor, but regardless I am excited to see Brackets grow in functionality over time.

This issue is still not fixed in 2016!

Yep - just found that this still isn't fixed! Had a friend ask me about it who is new to JS and it really confused him (and me!)

Do not forget "this and that" :smile:

`(function (global) {

"use strict";
//Scope
var as = null;
(function () {
    var a = 5;
    as = a;
}());
console.log(as);


function aa(param) {
    var p = param;
    return function () {
        console.log(p);
        global.alert(p);
    };
}


var bb = aa('test');
bb();

}(this.window));`

Add this to your linter options:

"devel": true

Include this:
/jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/
global define, $, JSLINT, brackets */
on the top of your function, like so:

/jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/
global define, $, JSLINT, brackets */
ourRequest.onload = function () {
"use strict";
var ourData = JSON.parse(ourRequest.responseText);
console.log(ourData[1]);
};

window.console.log will resolve. window is the global object however.

Yeah, I see they were going to take care of this in defaults in 2013. Then they closed the discussion. Nice job.

??? Crowes' comment and two thumbs up??? window.console.log does NOT resolve.

@deemyboy , they have not yet resolved the issue as of Feb 08, 2018!

@annuranjan Lol... No. Five years later still waiting. Which is a shame, I like a lot of features in brackets, but issues like this stop me using it and keep going back to Atom and VSC

what is browser: true is good for then?

In 'options' at the bottom, try checking the 'assume ->Node.js' option, mine worked this way.

In my case, those tips won't work...
Running mac and google chrome: can it be the problem?

thanks for all the tips.
but this problem still remains...

In my case, those tips won't work...
Running mac and google chrome: can it be the problem?

What do these things have to with Brackets, a completely separate application?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edlau picture edlau  路  3Comments

theman1616 picture theman1616  路  4Comments

mrapino picture mrapino  路  3Comments

brendonmm picture brendonmm  路  4Comments

naphipps picture naphipps  路  4Comments