It would be great to be able to define rules for the format code command.
Personnally, I would need to change the default indentation level for specific code lines (wrapped lines) and to disable the command for the comments. (They are indented when I wouldn't like to)
Also, this improvement can be used in different languages not in the same way, I recognize it could take time to make it available.
For which language would you like these settings?
Currently JavaScript.
The formatting support provided TypeScript supports settings which we currently do not expose to the user.
This would be very helpful. We have rules defined in .eslintrc.json that conflict with the MS-dictated formatting rules applied when using the format code command, so every time we use the command we have to fix formatting elsewhere in the file.
One example is we prefer spaces before and after the star in generator functions, whereas the format code command removes the space before the star.
It would be nice if there was an option to use one of the available linting plugins (jshint, eslint, etc) and hook into their rules, but even being able to statically define our own ruleset per-project would be okay.
As a JSLint user, I was precisely looking for a "double-indent" possibility for the setting "editor.wrappingIndent".
Is it possible? For example, now TS auto formatter does:
import { something } from 'something'
Is it possible to make it not add spaces between curly braces and text here:
import {something} from 'something'
?
I am looking for same feature as @whitecolor when auto formatting my JavaScript code. Actually our whole team has to fix lint errors after auto formatting code. This is annoying and reduces productivity because cleaning up the code after auto format feels nightmarish.
For the original issue:
TypeScript / JavaScript formatting options are exposed in settings (see javascript.format.* and typescript.format.*). Our built-in extension don't provide a way to do control these on a per-block or per-file basis. For more advanced formatting control like that, try using one of the dedicated formatting tools form the marketplace
@jdforsythe
@whitecolor
That is controlled by the settings:
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"
Closing as out of scope for the original feature request for per-block or per-line formatting options
Most helpful comment
This would be very helpful. We have rules defined in .eslintrc.json that conflict with the MS-dictated formatting rules applied when using the format code command, so every time we use the command we have to fix formatting elsewhere in the file.
One example is we prefer spaces before and after the star in generator functions, whereas the format code command removes the space before the star.
It would be nice if there was an option to use one of the available linting plugins (jshint, eslint, etc) and hook into their rules, but even being able to statically define our own ruleset per-project would be okay.