10

I'm getting this error in Brackets.

I want to stress the fact that it's literally the second time I opened a JS file. As I stressed It I want also to emphasize the fact that I have no clue what Eslint and node.js are.

All the fixes on the StackOverflow and other sites assume knowing how abovementioned entities work.

Please help to a complete newb to fix the problem and learn something new.

Thank you in advance!

Here's the piece of code, but I don't think it will help with anything.

Html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript</title>

</head>
<body>
<h1>Javascript starter</h1>

    <script src=Script.js> </script>
</body>
</html>

Javascript:

var now = 2018;
var yearJohn = 1989;
var fullAge = 18;

//Multiple operators
var isFullAge = now - yearJohn >= fullAge; //true
сonsole.log(isFullAge);

//Grouping

    var ageJohn = now - yearJohn;
    var ageMark = 35;
    var average = (ageJohn + ageMark)/2;
    console.log(average);

    // Multiple assigments
    var x, y;
    x = y = (3 + 5) * 4 - 6; // 8 * 4 - 6 // 32 - 6 // 26

    console.log(x, y);

    // More operators
    x *= 2;
    console.log(x);
    x += 10;
    // eslint-disable-next-line no-console
    console.log(x);
Segal Pal
  • 111
  • 1
  • 1
  • 4

6 Answers6

21

If it really is ESLint that is causing errors for this change, you can fix it by disabling the rule for that particular line:

// eslint-disable-next-line no-console
console.log(isFullAge);
Dr_Derp
  • 1,185
  • 6
  • 17
  • How? If I add the line without comment tag it does nothing. If I add the line with the comment tag it obviously does nothing. Why the code worked the first time I created the file and it doesn't now? Why in every single tutorial for beginners there's no such a thing as disabling this rule? All these questions might sound obvious or dead-stupid, but I just don't get it. – Segal Pal Jun 01 '19 at 20:24
  • 3
    If you add the line with the comment tag it won't disable the line, it will just tell eslint to not run the given rule for that line. You might need to post the entire file in the question, so we have better understanding of the whole context. Some tutorials for beginners tackle ESLint but many do not, which is why, I suspect, you haven't seen this before. Also disabling a lint rule is not something that's generally encouraged, since it tends to result in code that doesn't conform to the standard. – Dr_Derp Jun 01 '19 at 20:36
  • The javascript file is called Script.js? And it is located in the same folder as the HTML? Are you getting any errors in your browser console when you load this file? Any errors in the network tab? – Dr_Derp Jun 01 '19 at 21:05
  • Yes it is. I closed the folder in an editor and opened it up again. As a result, the error in Brackets disappeared but the browser console gives me this now "Uncaught ReferenceError: сonsole is not defined at Script.js:89" the line 89 correlates with сonsole.log(isFullAge); – Segal Pal Jun 01 '19 at 21:20
  • Are you using any sort of a transpiler on this code? For console to not be defined is extremely strange. – Dr_Derp Jun 01 '19 at 21:22
  • No. There was a mistake. The variable called fullAge. But I use isFullAge. But. It was giving me the same mistake after I fix it until I just delete and inserted the console.log(isFullAge) a few times. What's sort of alchemy is this. And still, I haven't figured out what caused the problem I've described in the topic and how I fixed it. – Segal Pal Jun 01 '19 at 21:29
  • I wish I could say.... I don't understand the whole project well enough to see. But I'm glad you got it working. – Dr_Derp Jun 01 '19 at 21:32
  • I appreciate that. I wish I could have helped more. – Dr_Derp Jun 01 '19 at 21:33
8

Just add "no-console": 0 to the rules part of .eslintrc.js file.

E.g.

"rules": {
    "no-console": 0
},
4b0
  • 21,981
  • 30
  • 95
  • 142
Apetu Gideon
  • 136
  • 1
  • 5
4

Add the following to your .eslintrc.js file

"no-console": ["error", { "allow": ["warn", "error"] }]
Kamil
  • 2,712
  • 32
  • 39
ParagDineshGupta
  • 210
  • 2
  • 10
  • How would that look in a yaml file? The following does not work. ```yaml no-console: - error - allow - warn - error ``` – Corné Jan 04 '22 at 22:14
2

Install the "brackets-eslint" extension and reload your Brackets editor

img1

Traian GEICU
  • 1,750
  • 3
  • 14
  • 26
Mohit.Dev
  • 21
  • 2
-2

Please try to change console.log to document.write

and then open your html file in browser

var now = 2018;
var yearJohn = 1989;
var fullAge = 18;

//Multiple operators
var isFullAge = now - yearJohn >= fullAge; //true
document.write(isFullAge);

//Grouping

var ageJohn = now - yearJohn;
var ageMark = 35;
var average = (ageJohn + ageMark)/2;
document.write(average);

// Multiple assigments
var x, y;
x = y = (3 + 5) * 4 - 6; // 8 * 4 - 6 // 32 - 6 // 26

document.write(x, y);

// More operators
x *= 2;
document.write(x);
x += 10;
// eslint-disable-next-line no-console
document.write(x);
verejava
  • 7
  • 5
-4

Use console.warn(""); instead of console.log

m4n0
  • 29,823
  • 27
  • 76
  • 89