首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.jsbeautifyrc不接受"\crlf“作为终止

.jsbeautifyrc不接受"\crlf“作为终止
EN

Stack Overflow用户
提问于 2019-09-13 17:56:08
回答 1查看 104关注 0票数 0

我在Windows10中使用这个配置和jsbeautify 1.10.2。

代码语言:javascript
复制
{
  "indent_size": "2",
  "indent_char": " ",
  "max_preserve_newlines": "1",
  "preserve_newlines": true,
  "keep_array_indentation": false,
  "break_chained_methods": false,
  "indent_scripts": "normal",
  "brace_style": "collapse-preserve-inline",
  "space_before_conditional": true,
  "unescape_strings": false,
  "jslint_happy": false,
  "end_with_newline": false,
  "wrap_line_length": "160",
  "indent_inner_html": false,
  "comma_first": false,
  "e4x": false,
  "indent_empty_lines": false,
  "wrap-attributes": "force-aligned",
  "end-with-newline": "true",
  "eol": "\crlf"
}`

并以这种方式调用jsbeautity:

代码语言:javascript
复制
js-beautify --config ./.jsbeautifyrc --replace ./apps/**/*.html

它抛出这个错误:

代码语言:javascript
复制
SyntaxError: Unexpected token c in JSON at position 599
    at JSON.parse (<anonymous>)
    at exports.parse (c:\center\node_modules\config-chain\index.js:54:19)
    at exports.json (c:\center\node_modules\config-chain\index.js:70:10)
    at module.exports (c:\center\node_modules\config-chain\index.js:17:15)
    at Object.exports.interpret (c:\center\node_modules\js-beautify\js\lib\cli.js:279:15)
    at Object.<anonymous> (c:\center\node_modules\js-beautify\js\bin\js-beautify.js:4:5)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
Error while loading beautifier configuration.
Configuration file chain included:
c:\center\.jsbeautifyrc
c:\center\.jsbeautifyrc
c:\center\node_modules\js-beautify\js\lib/../config/defaults.json

如果我删除eol键,它可以工作,但当然,它会以一种我不想要的方式设置行尾。

我已经尝试过\\crlf /\crlfcrlf。但这只是在每一行中都进行了精确的测试。

这是一个已知的问题吗?我说错了吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-13 18:09:46

回车符是\r (ASCII 13),换行符是\n (ASCII 10)。尝试:

代码语言:javascript
复制
"eol": "\r\n"

CRLF仅仅是缩写。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57921377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档