0
votes

Update I removed the env code and I'm still receiving 6 ESLint errors with my code and I'm not sure why.

Here are the errors:

ERROR: 'window' is not defined. [no-undef] if ($(window).width() <= 640) {

ERROR: 'initMap' is defined but never used. [no-unused-vars] function initMap() {

ERROR: 'google' is not defined. [no-undef] var map = new google.maps.Map(document.getElementById("map"), {

ERROR: 'document' is not defined. [no-undef] var map = new google.maps.Map(document.getElementById("map"), {

ERROR: 'marker' is assigned a value but never used. [no-unused-vars] var marker = new google.maps.Marker({

ERROR: 'google' is not defined. [no-undef] var marker = new google.maps.Marker({

Any help would be appreciated!

/*eslint-env jquery*/

if ($(window).width() <= 640) {
$(".cross").hide();
$(".menu").hide();
$(".hamburger").show();

$(".hamburger").on("click", function () {
    $(".menu").slideToggle("slow");
    $(".hamburger").hide();
    $(".cross").show();
});

$(".cross").on("click", function () {
    $(".menu").slideToggle("slow");
    $(".cross").hide();
    $(".hamburger").show();
});
}

function initMap() {
var pip = {
    lat: 22.421645,
    lng: -98.731555
};
var map = new google.maps.Map(document.getElementById("map"), {
    zoom: 13,
    center: pip,
});
var marker = new google.maps.Marker({
    position: pip,
    map: map
});
}
3
Because it is not a valid JavaScript code.Dima Parzhitsky

3 Answers

2
votes

The code you try to validate has a syntax error. This part:

"env": {
"browser": true,
"node": true,
"jasmine": true    
},

...is either extraneous, or you don't show the whole snippet.

1
votes

If "env" is meant to be a variable, I think you need something like this:

env = {
    "browser": true,
    "node": true,
    "jasmine": true
};

Proper indentation throughout would make this a lot easier to read

1
votes

As Drew stated above, if env is a variable, you'll need an equals sign, not a colon. In addition, you'll want to declare the type.

const env = {
    "browser": true,
    "node": true,
    "jasmine": true
};