tags:

views:

31

answers:

2

Why JSLint is producing this kind of warning

Problem at line xxx character yyy: Expected 'X' to have an indentation at xx instead at yyy.

Why does it matter to have a different space formatting?

A: 

Well, since you didn't show us the line, we can only guess, but it's probably something like this.

 if(someCondition)
     DoThis();
     DoThat();

Since it would expect the indenting to be:

 if(someCondition)
     DoThis();
 DoThat();

It thinks you may want it to be:

 if(someCondition)
 {
     DoThis();
     DoThat();
 }
James Curran
A: 

Here is the code that produced these warnings Just copy and paste it to jslint and see

for (i = 0; i < results[0].address_components.length; i++)
            {
                addComp = results[0].address_components[i];
                switch (addComp.types[0])
                {
                    case "street_number": this.location.address.streetNumber = addComp.long_name;
                        break;
                    case "route": this.location.address.streetAddress = addComp.long_name;
                        break;
                    case "premise": this.location.address.premise = addComp.long_name;
                        break;
                    case "floor": this.location.address.floor = addComp.long_name;
                        break;
                    case "sublocality": this.location.address.sublocality = addComp.long_name;
                        break;
                    case "locality": this.location.address.locality = addComp.long_name;
                        break;
                    case "administrative_area_level_2": this.location.address.county = addComp.long_name;
                        this.location.address.countyCode = addComp.short_name;
                        break;
                    case "administrative_area_level_1": this.location.address.region = addComp.long_name;
                        this.location.address.regionCode = addComp.short_name;
                        break;
                    case "country": this.location.address.country = addComp.long_name;
                        this.location.address.countryCode = addComp.short_name;
                        break;
                    case "postal_code": this.location.address.postalCode = addComp.long_name;
                        break;
                }
            }