You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for disabling formatter for a code block #33772
This is a feature request. I wanted a way to disable formatter for a block of code based on some sort of annotations. This will be handy for cases that are not yet supported by VSCode formatter. For example, support for dynamic imports were added in v1.14. Before that import() statements were not getting formatted properly.
Here is a sample format that could be used. This is not just a workaround for shortcomings. This can be useful for cases where developers want to format a section of code differently.
constgenerateData=()=>{constitems=[];for(leti=0;i<100;i++){/* formatter: off */constitem={id : i,name : `item${i}`,category : 'some category'}/* formatter: on */items.push(item);}}
Activity
jrieken commentedon Sep 4, 2017
Like what? Can provide a sample? Is this for one specific language? And is this just a workaround for shortcomings of the formatter?
varunkumar commentedon Sep 4, 2017
Here is a sample format that could be used. This is not just a workaround for shortcomings. This can be useful for cases where developers want to format a section of code differently.
varunkumar commentedon Sep 4, 2017
JS Beautify has its own set of directives -- https://github.com/beautify-web/js-beautify#directives-to-ignore-or-preserve-sections-javascript-only
jrieken commentedon Sep 4, 2017
This seems JS/TS specific
mjbvz commentedon Sep 5, 2017
I've opened microsoft/TypeScript#18261 to track for our built-in JavaScript and TypeScript formatter
Closing as upstream