JSHint - Tabs Mixed with Spaces & Format Code

I am trying to start using JSHint and I have a problem in that it flags tabs mixed with spaces (we use tabs), but the Format Code keeps putting a space back after I remove it. I have JavaScript code style set to use tab character. What's causing this?

6 comments
Comment actions Permalink

This only occurs where I have function comments:
Capture.JPG

0
Comment actions Permalink

I was asking that myself, and I couldn't find an option that would change that behaviour. I though it would be the "Smart tabs" option in "Project Settings > Code Style > JavaScript > Tabs and Indents", however it doesn't seem to have any effect, also the documentation on this option is a little confusing:

If this check box is selected, WebStorm inserts tabs for indentation and reformatting, but fine alignment to a necessary column is done only via spaces. [...] If this check box is not selected, then spaces are used for alignment if necessary.


So it uses spaces no matter whether the option is selected? ?:|

However I didn't wanted it to change this behavior, I just wanted to suppress the messages, in case someone doesn't know, this can be done via JSHints smarttabs option:

/*jshint smarttabs: true */


Regards
Oliver

0
Comment actions Permalink

How do I use those options in PHPStorm?

0
Comment actions Permalink

Also, what is Predefined (, separated) for?

0
Comment actions Permalink

laurin1 wrote:

How do I use those options in PHPStorm?


Simply place the comment at the top (or wherever you want the option to start affecting the process) of your JavaScript document.

laurin1 wrote:

Also, what is Predefined (, separated) for?


This is where you can define globally available variables, that way they can be used within different files without being marked as errors. It's essentially what JSHints global option does: http://www.jshint.com/about/

Regards
Oliver

0
Comment actions Permalink

Smart tabs options in "Project Settings > Code Style > JavaScript > Tabs and Indents" allows you to indent your code with spaces using TAB key.
If Smart tabs option is enabled then spaces will be inserted only if spaces have already been used to indent a line.
To make things clear let's consider following example (Use tab characters and Smart tabs options are enabled, Tab size : 4, Indent: 4).

Initially code looks like this (the caret is on the third line and has one space indentation):
0-initial.png

Pressing TAB key adds three more spaces to make code indented properly:
1-smart-tabs-in-action.png

Now disable Smart tabs option, rollback changes made by pressing TAB key, position caret in its initial position (one space indentation) and press TAB key again:
2-usual-tab-character-insertion.png

As a result TAB character is inserted and now caret has one space and one tab indentation.

JSHint smarttabs option has no interconnection with Smart tabs option from "Project Settings > Code Style > JavaScript > Tabs and Indents".
At the moment it's only possible to change this JSHint option in /*jshint ... */ comment, as odey said.

0

Please sign in to leave a comment.