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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:12:03+00:00 2026-05-19T10:12:03+00:00

While I realize that each language has its own convention for indentation, I can’t

  • 0

While I realize that each language has its own convention for indentation, I can’t help but be annoyed with something I’ve recently discovered. Consider this code from the PHP manual:

switch ($i) {
    case "apple":
        echo "i is apple";
        break;
    case "bar":
        echo "i is bar";
        break;
    case "cake":
        echo "i is cake";
        break;
}

Notice that each case is indented from the switch statement. This makes sense, as the code is easier to read and the body of the block is contained one level inside of it.

However, when I test the equivalent JavaScript switch statement in JSLint:

switch (i) {
    case "apple":
        alert("i is apple");
        break;
    case "bar":
        alert("i is bar");
        break;
    case "cake":
        alert("i is cake");
        break;
}

…it displays an error telling me that it should appear like this instead:

switch (i) {
case "apple":
    alert("i is apple");
    break;
case "bar":
    alert("i is bar");
    break;
case "cake":
    alert("i is cake");
    break;
}

It seems counterintuitive, as each case is now inline with the switch block itself. I can’t imagine any reason why this would be considered better, much less trigger an error.

Is JSLint in err, or is it just following convention? If the latter is true, why wouldn’t the convention be to indent for clarity?

  • 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-05-19T10:12:04+00:00Added an answer on May 19, 2026 at 10:12 am

    It’s your code. Format it how you want to. Use jsLint, but if you disagree that its recommendations improve your code, don’t implement them. jsLint hurts your feelings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While I realize that this question has been asked once or twice ago but
I realize that each browser would implement it differently, but are there any references
I'm currently developing a web application that has one feature while allows input from
I realize this has been asked hundreds of times, however, I can't seem to
While writing a card shuffling algorithm I realized that there are 52! ~= 2^225
While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that
While I realize resources themselves are defined in XML files, if I have an
I haven't realized this for a while, but my depth map is messing up.
While making some final tests of a class-library that I'm writing for Windows Mobile
I have two different views that makes upwards of 500 partial view calls each

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.