【发布时间】:2018-03-04 21:11:34
【问题描述】:
ESLint:403行超过最大行长120(max-len)
我有一个长字符串,我使用 ES6 模板字符串构建,但我希望它没有换行符:
var string = `Let me be the 'throws Exception’ to your 'public static void
main (String[] args)’. I will accept whatever you give me my ${love}.`
console.log(string);
结果:
Let me be the 'throws Exception’ to your 'public static void
main (String[] args)’. I will accept whatever you give me xxx.
我的期望:
Let me be the 'throws Exception’ to your 'public static void main (String[] args)’. I will accept whatever you give me xxx.
要求:
我无法禁用 eslint 规则,因为必须强制执行。
我不能将数据放在单独的文件中,因为数据是动态的。
我无法连接多个较短的字符串,因为那工作量太大。
【问题讨论】:
-
不想换行就不要写了?
-
ESLint:第403行超过最大行长120(max-len)
-
myStr.replace("\n",""); -
Ragarding
c,它很可爱,但并不像你期望的那样工作。可以使用自定义标记功能使其转换字符串。查看更新。 -
你能改一下规则吗?它有eslint.org/docs/rules/max-len#ignoretemplateliterals 作为选项。
标签: javascript ecmascript-6 template-strings