[英]WebStorm auto-formatting adds leading whitespace to SQL template literals
When auto-formatting injected SQL
code in a template literal in TypeScript
/ JavaScript
, WebStorm
automatically adds leading whitespace to align each line to the declaration line, ie 当使用TypeScript
/ JavaScript
在模板文字中自动格式化注入的SQL
代码时, WebStorm
自动添加前导空格以使每行与声明行对齐,即
const query = `
select field1 as x,
field123456789 as y,
from mytable
`;
instead of the preferred 而不是首选
const query = `
select field1 as x,
field123456789 as y,
from mytable
`;
This causes unnecessary whitespace in the string, especially when the declaration line itself is indented with a large margin. 这会在字符串中导致不必要的空格,尤其是在声明行本身以较大的空白缩进时。
In there a way to fix this? 有办法解决这个问题吗? Or am I doing this the wrong way? 还是我做错了这个方法?
您可以启用源代码格式,并使用outdent
包在运行时从字符串中删除前导空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.